From 2bf20a62b0b15763c08c3aeec50a7f31964af9d3 Mon Sep 17 00:00:00 2001 From: "stainless-sdks[bot]" <167585319+stainless-sdks[bot]@users.noreply.github.com> Date: Sat, 16 Aug 2025 17:05:02 +0000 Subject: [PATCH 001/125] Initial commit --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..0847dff7 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# imagekit-java \ No newline at end of file From 042cc51b99283ec25baf47fac916914758774dea Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 16 Aug 2025 17:07:17 +0000 Subject: [PATCH 002/125] chore: configure new SDK language --- .devcontainer/Dockerfile | 23 + .devcontainer/devcontainer.json | 20 + .gitattributes | 5 + .github/workflows/ci.yml | 85 + .gitignore | 7 + .stats.yml | 4 + LICENSE | 201 + README.md | 629 +- 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 0 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 251 + gradlew.bat | 94 + image-kit-java-client-okhttp/build.gradle.kts | 14 + .../api/client/okhttp/ImageKitOkHttpClient.kt | 308 + .../okhttp/ImageKitOkHttpClientAsync.kt | 308 + .../api/client/okhttp/OkHttpClient.kt | 246 + image-kit-java-core/build.gradle.kts | 41 + .../com/imagekit/api/client/ImageKitClient.kt | 92 + .../api/client/ImageKitClientAsync.kt | 96 + .../api/client/ImageKitClientAsyncImpl.kt | 114 + .../imagekit/api/client/ImageKitClientImpl.kt | 108 + .../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 | 440 + .../com/imagekit/api/core/ObjectMappers.kt | 167 + .../kotlin/com/imagekit/api/core/Params.kt | 16 + .../com/imagekit/api/core/PhantomReachable.kt | 56 + .../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 + .../models/accounts/AccountGetUsageParams.kt | 235 + .../accounts/AccountGetUsageResponse.kt | 359 + .../bulkjobs/BulkJobCopyFolderParams.kt | 609 + .../bulkjobs/BulkJobCopyFolderResponse.kt | 159 + .../bulkjobs/BulkJobMoveFolderParams.kt | 521 + .../bulkjobs/BulkJobMoveFolderResponse.kt | 159 + .../bulkjobs/BulkJobRetrieveStatusParams.kt | 195 + .../bulkjobs/BulkJobRetrieveStatusResponse.kt | 226 + .../CustomMetadataFieldCreateParams.kt | 2316 +++ .../CustomMetadataFieldCreateResponse.kt | 2017 +++ .../CustomMetadataFieldDeleteParams.kt | 238 + .../CustomMetadataFieldDeleteResponse.kt | 120 + .../CustomMetadataFieldListParams.kt | 218 + .../CustomMetadataFieldListResponse.kt | 2017 +++ .../CustomMetadataFieldUpdateParams.kt | 2037 +++ .../CustomMetadataFieldUpdateResponse.kt | 2017 +++ .../imagekit/api/models/files/ExifDetails.kt | 1142 ++ .../imagekit/api/models/files/ExifImage.kt | 522 + .../api/models/files/FileAddTagsParams.kt | 533 + .../api/models/files/FileAddTagsResponse.kt | 189 + .../api/models/files/FileCopyParams.kt | 602 + .../api/models/files/FileCopyResponse.kt | 112 + .../api/models/files/FileDeleteParams.kt | 234 + .../api/models/files/FileListParams.kt | 553 + .../api/models/files/FileListResponse.kt | 1353 ++ .../api/models/files/FileMoveParams.kt | 512 + .../api/models/files/FileMoveResponse.kt | 112 + .../models/files/FileRemoveAiTagsParams.kt | 538 + .../models/files/FileRemoveAiTagsResponse.kt | 189 + .../api/models/files/FileRemoveTagsParams.kt | 534 + .../models/files/FileRemoveTagsResponse.kt | 189 + .../api/models/files/FileRenameParams.kt | 649 + .../api/models/files/FileRenameResponse.kt | 166 + .../api/models/files/FileUploadV1Params.kt | 3127 ++++ .../api/models/files/FileUploadV1Response.kt | 11793 ++++++++++++++++ .../api/models/files/FileUploadV2Params.kt | 2861 ++++ .../api/models/files/FileUploadV2Response.kt | 11793 ++++++++++++++++ .../com/imagekit/api/models/files/Gps.kt | 178 + .../api/models/files/Interoperability.kt | 201 + .../imagekit/api/models/files/Thumbnail.kt | 359 + .../models/files/batch/BatchDeleteParams.kt | 451 + .../models/files/batch/BatchDeleteResponse.kt | 189 + .../files/details/DetailRetrieveParams.kt | 189 + .../files/details/DetailRetrieveResponse.kt | 1353 ++ .../files/details/DetailUpdateParams.kt | 2818 ++++ .../files/details/DetailUpdateResponse.kt | 2037 +++ .../files/metadata/MetadataFromUrlParams.kt | 203 + .../files/metadata/MetadataFromUrlResponse.kt | 1110 ++ .../files/metadata/MetadataRetrieveParams.kt | 195 + .../metadata/MetadataRetrieveResponse.kt | 1110 ++ .../models/files/purge/PurgeExecuteParams.kt | 415 + .../files/purge/PurgeExecuteResponse.kt | 160 + .../models/files/purge/PurgeStatusParams.kt | 189 + .../models/files/purge/PurgeStatusResponse.kt | 285 + .../files/versions/VersionDeleteParams.kt | 262 + .../files/versions/VersionDeleteResponse.kt | 113 + .../files/versions/VersionListParams.kt | 189 + .../files/versions/VersionListResponse.kt | 1353 ++ .../files/versions/VersionRestoreParams.kt | 258 + .../files/versions/VersionRestoreResponse.kt | 1353 ++ .../files/versions/VersionRetrieveParams.kt | 217 + .../files/versions/VersionRetrieveResponse.kt | 1353 ++ .../api/models/folder/FolderCreateParams.kt | 550 + .../api/models/folder/FolderCreateResponse.kt | 113 + .../api/models/folder/FolderDeleteParams.kt | 421 + .../api/models/folder/FolderDeleteResponse.kt | 113 + .../api/services/async/AccountServiceAsync.kt | 70 + .../services/async/AccountServiceAsyncImpl.kt | 84 + .../api/services/async/BulkJobServiceAsync.kt | 186 + .../services/async/BulkJobServiceAsyncImpl.kt | 170 + .../async/CustomMetadataFieldServiceAsync.kt | 293 + .../CustomMetadataFieldServiceAsyncImpl.kt | 218 + .../api/services/async/FileServiceAsync.kt | 467 + .../services/async/FileServiceAsyncImpl.kt | 510 + .../api/services/async/FolderServiceAsync.kt | 99 + .../services/async/FolderServiceAsyncImpl.kt | 126 + .../services/async/files/BatchServiceAsync.kt | 72 + .../async/files/BatchServiceAsyncImpl.kt | 86 + .../async/files/DetailServiceAsync.kt | 201 + .../async/files/DetailServiceAsyncImpl.kt | 133 + .../async/files/MetadataServiceAsync.kt | 152 + .../async/files/MetadataServiceAsyncImpl.kt | 128 + .../services/async/files/PurgeServiceAsync.kt | 145 + .../async/files/PurgeServiceAsyncImpl.kt | 130 + .../async/files/VersionServiceAsync.kt | 290 + .../async/files/VersionServiceAsyncImpl.kt | 237 + .../api/services/blocking/AccountService.kt | 66 + .../services/blocking/AccountServiceImpl.kt | 80 + .../api/services/blocking/BulkJobService.kt | 185 + .../services/blocking/BulkJobServiceImpl.kt | 160 + .../blocking/CustomMetadataFieldService.kt | 290 + .../CustomMetadataFieldServiceImpl.kt | 202 + .../api/services/blocking/FileService.kt | 463 + .../api/services/blocking/FileServiceImpl.kt | 470 + .../api/services/blocking/FolderService.kt | 95 + .../services/blocking/FolderServiceImpl.kt | 119 + .../services/blocking/files/BatchService.kt | 70 + .../blocking/files/BatchServiceImpl.kt | 82 + .../services/blocking/files/DetailService.kt | 194 + .../blocking/files/DetailServiceImpl.kt | 126 + .../blocking/files/MetadataService.kt | 149 + .../blocking/files/MetadataServiceImpl.kt | 121 + .../services/blocking/files/PurgeService.kt | 141 + .../blocking/files/PurgeServiceImpl.kt | 123 + .../services/blocking/files/VersionService.kt | 282 + .../blocking/files/VersionServiceImpl.kt | 224 + .../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 + .../accounts/AccountGetUsageParamsTest.kt | 38 + .../accounts/AccountGetUsageResponseTest.kt | 50 + .../bulkjobs/BulkJobCopyFolderParamsTest.kt | 48 + .../bulkjobs/BulkJobCopyFolderResponseTest.kt | 32 + .../bulkjobs/BulkJobMoveFolderParamsTest.kt | 31 + .../bulkjobs/BulkJobMoveFolderResponseTest.kt | 32 + .../BulkJobRetrieveStatusParamsTest.kt | 23 + .../BulkJobRetrieveStatusResponseTest.kt | 45 + .../CustomMetadataFieldCreateParamsTest.kt | 126 + .../CustomMetadataFieldCreateResponseTest.kt | 131 + .../CustomMetadataFieldDeleteParamsTest.kt | 23 + .../CustomMetadataFieldDeleteResponseTest.kt | 31 + .../CustomMetadataFieldListParamsTest.kt | 34 + .../CustomMetadataFieldListResponseTest.kt | 121 + .../CustomMetadataFieldUpdateParamsTest.kt | 113 + .../CustomMetadataFieldUpdateResponseTest.kt | 131 + .../api/models/files/ExifDetailsTest.kt | 113 + .../api/models/files/ExifImageTest.kt | 68 + .../api/models/files/FileAddTagsParamsTest.kt | 34 + .../models/files/FileAddTagsResponseTest.kt | 36 + .../api/models/files/FileCopyParamsTest.kt | 48 + .../api/models/files/FileCopyResponseTest.kt | 30 + .../api/models/files/FileDeleteParamsTest.kt | 23 + .../api/models/files/FileListParamsTest.kt | 61 + .../api/models/files/FileListResponseTest.kt | 121 + .../api/models/files/FileMoveParamsTest.kt | 31 + .../api/models/files/FileMoveResponseTest.kt | 30 + .../files/FileRemoveAiTagsParamsTest.kt | 34 + .../files/FileRemoveAiTagsResponseTest.kt | 36 + .../models/files/FileRemoveTagsParamsTest.kt | 34 + .../files/FileRemoveTagsResponseTest.kt | 36 + .../api/models/files/FileRenameParamsTest.kt | 48 + .../models/files/FileRenameResponseTest.kt | 34 + .../models/files/FileUploadV1ParamsTest.kt | 161 + .../models/files/FileUploadV1ResponseTest.kt | 1335 ++ .../models/files/FileUploadV2ParamsTest.kt | 152 + .../models/files/FileUploadV2ResponseTest.kt | 1335 ++ .../com/imagekit/api/models/files/GpsTest.kt | 30 + .../api/models/files/InteroperabilityTest.kt | 41 + .../api/models/files/ThumbnailTest.kt | 53 + .../files/batch/BatchDeleteParamsTest.kt | 31 + .../files/batch/BatchDeleteResponseTest.kt | 36 + .../files/details/DetailRetrieveParamsTest.kt | 23 + .../details/DetailRetrieveResponseTest.kt | 125 + .../files/details/DetailUpdateParamsTest.kt | 243 + .../files/details/DetailUpdateResponseTest.kt | 153 + .../metadata/MetadataFromUrlParamsTest.kt | 24 + .../metadata/MetadataFromUrlResponseTest.kt | 294 + .../metadata/MetadataRetrieveParamsTest.kt | 23 + .../metadata/MetadataRetrieveResponseTest.kt | 294 + .../files/purge/PurgeExecuteParamsTest.kt | 29 + .../files/purge/PurgeExecuteResponseTest.kt | 32 + .../files/purge/PurgeStatusParamsTest.kt | 23 + .../files/purge/PurgeStatusResponseTest.kt | 34 + .../files/versions/VersionDeleteParamsTest.kt | 24 + .../versions/VersionDeleteResponseTest.kt | 30 + .../files/versions/VersionListParamsTest.kt | 23 + .../files/versions/VersionListResponseTest.kt | 125 + .../versions/VersionRestoreParamsTest.kt | 24 + .../versions/VersionRestoreResponseTest.kt | 170 + .../versions/VersionRetrieveParamsTest.kt | 24 + .../versions/VersionRetrieveResponseTest.kt | 125 + .../models/folder/FolderCreateParamsTest.kt | 31 + .../models/folder/FolderCreateResponseTest.kt | 30 + .../models/folder/FolderDeleteParamsTest.kt | 23 + .../models/folder/FolderDeleteResponseTest.kt | 30 + .../api/services/ErrorHandlingTest.kt | 929 ++ .../api/services/ServiceParamsTest.kt | 89 + .../services/async/AccountServiceAsyncTest.kt | 38 + .../services/async/BulkJobServiceAsyncTest.kt | 79 + .../CustomMetadataFieldServiceAsyncTest.kt | 160 + .../services/async/FileServiceAsyncTest.kt | 304 + .../services/async/FolderServiceAsyncTest.kt | 58 + .../async/files/BatchServiceAsyncTest.kt | 37 + .../async/files/DetailServiceAsyncTest.kt | 128 + .../async/files/MetadataServiceAsyncTest.kt | 49 + .../async/files/PurgeServiceAsyncTest.kt | 53 + .../async/files/VersionServiceAsyncTest.kt | 93 + .../services/blocking/AccountServiceTest.kt | 37 + .../services/blocking/BulkJobServiceTest.kt | 76 + .../CustomMetadataFieldServiceTest.kt | 156 + .../api/services/blocking/FileServiceTest.kt | 293 + .../services/blocking/FolderServiceTest.kt | 56 + .../blocking/files/BatchServiceTest.kt | 36 + .../blocking/files/DetailServiceTest.kt | 126 + .../blocking/files/MetadataServiceTest.kt | 46 + .../blocking/files/PurgeServiceTest.kt | 51 + .../blocking/files/VersionServiceTest.kt | 89 + image-kit-java-example/build.gradle.kts | 28 + image-kit-java-lib/.keep | 4 + image-kit-java-proguard-test/build.gradle.kts | 103 + .../api/proguard/ProGuardCompatibilityTest.kt | 102 + image-kit-java-proguard-test/test.pro | 8 + image-kit-java/build.gradle.kts | 29 + scripts/build | 8 + scripts/format | 8 + scripts/lint | 8 + scripts/mock | 41 + scripts/test | 56 + settings.gradle.kts | 14 + 290 files changed, 95186 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .stats.yml create mode 100644 LICENSE 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 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat 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/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/accounts/AccountGetUsageParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponse.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/CustomMetadataFieldCreateResponse.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/CustomMetadataFieldListResponse.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/custommetadatafields/CustomMetadataFieldUpdateResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifDetails.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifImage.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsResponse.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/FileListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListResponse.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/FileRemoveAiTagsParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponse.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/FileUploadV1Params.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Response.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Params.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Response.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Gps.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Interoperability.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Thumbnail.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponse.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/VersionListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.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/files/versions/VersionRestoreResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteResponse.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/BulkJobServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncImpl.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/files/BatchServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncImpl.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/PurgeServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncImpl.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/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/BulkJobService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobServiceImpl.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/files/BatchService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailServiceImpl.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/PurgeService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceImpl.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/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/accounts/AccountGetUsageParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponseTest.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/CustomMetadataFieldCreateResponseTest.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/CustomMetadataFieldListResponseTest.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/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifDetailsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifImageTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsResponseTest.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/FileListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListResponseTest.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/FileRemoveAiTagsParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponseTest.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/FileUploadV1ParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/GpsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/InteroperabilityTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ThumbnailTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponseTest.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/VersionListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.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/files/versions/VersionRestoreResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteResponseTest.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/AccountServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncTest.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/files/BatchServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncTest.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/PurgeServiceAsyncTest.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/blocking/AccountServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/BulkJobServiceTest.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/files/BatchServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/DetailServiceTest.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/PurgeServiceTest.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-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 create mode 100755 scripts/build create mode 100755 scripts/format create mode 100755 scripts/lint create mode 100755 scripts/mock create mode 100755 scripts/test 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/.gitignore b/.gitignore new file mode 100644 index 00000000..b1346e6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.prism.log +.gradle +.idea +.kotlin +build/ +codegen.log +kls_database.db diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..e0223abb --- /dev/null +++ b/.stats.yml @@ -0,0 +1,4 @@ +configured_endpoints: 31 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0ffd73f83f6d2c3ad75d943fab8f4511847a7b1f8db10fb26a08f075ec814cc9.yml +openapi_spec_hash: afa5d5b601dc01949e9b9acff127ae0d +config_hash: d5947210e5a105aee14f8dc6b47ba6bb diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..e7a4d160 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + 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 0847dff7..607670b1 100644 --- a/README.md +++ b/README.md @@ -1 +1,628 @@ -# imagekit-java \ No newline at end of file +# 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) 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). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). + +## Installation + +### Gradle + +```kotlin +implementation("com.imagekit.api:image-kit-java:0.0.1") +``` + +### Maven + +```xml + + com.imagekit.api + image-kit-java + 0.0.1 + +``` + +## Requirements + +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.FileUploadV1Params; +import com.imagekit.api.models.files.FileUploadV1Response; + +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClient client = ImageKitOkHttpClient.fromEnv(); + +FileUploadV1Params params = FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .build(); +FileUploadV1Response response = client.files().uploadV1(params); +``` + +## Client configuration + +Configure the client using system properties or environment variables: + +```java +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; + +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` 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; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .privateApiKey("My Private API 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; + +ImageKitClient client = ImageKitOkHttpClient.builder() + // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties + // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables + .fromEnv() + .privateApiKey("My Private API Key") + .build(); +``` + +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.orgMyPasswordToken` | `ORG_MY_PASSWORD_TOKEN` | false | `"does_not_matter"` | +| `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 +> thread pools, which are more efficient to share between requests. + +### Modifying configuration + +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; + +ImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + +## 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. + +For example, `client.files().uploadV1(...)` should be called with an instance of `FileUploadV1Params`, and it will return an instance of `FileUploadV1Response`. + +## Immutability + +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. + +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. + +Because each class is immutable, builder modification will _never_ affect already built class instances. + +## Asynchronous execution + +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.FileUploadV1Params; +import com.imagekit.api.models.files.FileUploadV1Response; +import java.util.concurrent.CompletableFuture; + +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClient client = ImageKitOkHttpClient.fromEnv(); + +FileUploadV1Params params = FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .build(); +CompletableFuture response = client.async().files().uploadV1(params); +``` + +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.FileUploadV1Params; +import com.imagekit.api.models.files.FileUploadV1Response; +import java.util.concurrent.CompletableFuture; + +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); + +FileUploadV1Params params = FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .build(); +CompletableFuture response = client.files().uploadV1(params); +``` + +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. + +## Raw responses + +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. + +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.FileUploadV1Params; +import com.imagekit.api.models.files.FileUploadV1Response; + +FileUploadV1Params params = FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .build(); +HttpResponseFor response = client.files().withRawResponse().uploadV1(params); + +int statusCode = response.statusCode(); +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.FileUploadV1Response; + +FileUploadV1Response parsedResponse = response.parse(); +``` + +## Error handling + +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: + + | 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) | + +- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/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. + +- [`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. + +- [`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. + +## Logging + +The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). + +Enable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`: + +```sh +$ export IMAGE_KIT_LOG=info +``` + +Or to `debug` for more verbose logging: + +```sh +$ export IMAGE_KIT_LOG=debug +``` + +## ProGuard and R8 + +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). + +ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary. + +## Jackson + +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. + +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). + +> [!CAUTION] +> We make no guarantee that the SDK works correctly when the Jackson version check is disabled. + +## Network options + +### Retries + +The SDK automatically retries 2 times by default, 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. + +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; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + .maxRetries(4) + .build(); +``` + +### Timeouts + +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.FileUploadV1Response; + +FileUploadV1Response response = client.files().uploadV1( + params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() +); +``` + +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 java.time.Duration; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + .timeout(Duration.ofSeconds(30)) + .build(); +``` + +### Proxies + +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 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(); +``` + +### HTTPS + +> [!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 +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(); +``` + +### Custom HTTP client + +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 +- `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 + +This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies. + +#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) + +> [!TIP] +> Try the available [network options](#network-options) before replacing the default client. + +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 + +### 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 + +## Undocumented API functionality + +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. + +### Parameters + +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.FileUploadV1Params; + +FileUploadV1Params params = FileUploadV1Params.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build(); +``` + +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. + +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.custommetadatafields.CustomMetadataFieldCreateParams; + +CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder() + .schema(CustomMetadataFieldCreateParams.Schema.builder() + .putAdditionalProperty("secretProperty", JsonValue.from("42")) + .build()) + .build(); +``` + +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 +import com.imagekit.api.core.JsonValue; +import com.imagekit.api.models.files.FileUploadV1Params; + +FileUploadV1Params params = FileUploadV1Params.builder() + .file(JsonValue.from(42)) + .fileName("fileName") + .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: + +```java +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!"); + +// 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 + ) +)); +``` + +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): + +```java +import com.imagekit.api.core.JsonMissing; +import com.imagekit.api.models.files.FileUploadV1Params; + +FileUploadV1Params params = FileUploadV1Params.builder() + .fileName("fileName") + .file(JsonMissing.of()) + .build(); +``` + +### Response properties + +To access undocumented response properties, call the `_additionalProperties()` method: + +```java +import com.imagekit.api.core.JsonValue; +import java.util.Map; + +Map additionalProperties = client.files().uploadV1(params)._additionalProperties(); +JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); + +String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { + @Override + public String visitNull() { + return "It's null!"; + } + + @Override + public String visitBoolean(boolean value) { + return "It's a boolean!"; + } + + @Override + public String visitNumber(Number value) { + return "It's a number!"; + } + + // 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 +}); +``` + +To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: + +```java +import com.imagekit.api.core.JsonField; +import java.util.Optional; + +JsonField file = client.files().uploadV1(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); +} +``` + +### Response validation + +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. + +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.FileUploadV1Response; + +FileUploadV1Response response = client.files().uploadV1(params).validate(); +``` + +Or configure the method call to validate the response using the `responseValidation` method: + +```java +import com.imagekit.api.models.files.FileUploadV1Response; + +FileUploadV1Response response = client.files().uploadV1( + params, RequestOptions.builder().responseValidation(true).build() +); +``` + +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; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + .responseValidation(true) + .build(); +``` + +## FAQ + +### Why don't you use plain `enum` classes? + +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. + +### Why do you represent fields using `JsonField` instead of just plain `T`? + +Using `JsonField` enables a few features: + +- 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 + +### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)? + +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. + +### Why don't you use checked exceptions? + +Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason. + +Checked exceptions: + +- 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 + +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: + +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. + +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..37ae6e26 --- /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") + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..a4b76b9530d66f5e68d973ea569d8e19de379189 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 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..cea7a793 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..f3b75f3b --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# 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 +# +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +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 + +# 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 + +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 ;; #( + 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 + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + 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" && ! "$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 + +# 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" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + 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 + # 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 +fi + + +# 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 new file mode 100644 index 00000000..9d21a218 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@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..81f5e3f3 --- /dev/null +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -0,0 +1,308 @@ +// 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 key starts with `private_`. */ + fun privateApiKey(privateApiKey: String) = apply { + clientOptions.privateApiKey(privateApiKey) + } + + /** + * Do not set this, its value is ignored + * + * Defaults to `"does_not_matter"`. + */ + fun password(password: String?) = apply { clientOptions.password(password) } + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional) = password(password.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..89193a36 --- /dev/null +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -0,0 +1,308 @@ +// 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 key starts with `private_`. */ + fun privateApiKey(privateApiKey: String) = apply { + clientOptions.privateApiKey(privateApiKey) + } + + /** + * Do not set this, its value is ignored + * + * Defaults to `"does_not_matter"`. + */ + fun password(password: String?) = apply { clientOptions.password(password) } + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional) = password(password.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..cfb877a8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt @@ -0,0 +1,92 @@ +// 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.BulkJobService +import com.imagekit.api.services.blocking.CustomMetadataFieldService +import com.imagekit.api.services.blocking.FileService +import com.imagekit.api.services.blocking.FolderService +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 folder(): FolderService + + fun bulkJobs(): BulkJobService + + fun accounts(): AccountService + + /** + * 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 folder(): FolderService.WithRawResponse + + fun bulkJobs(): BulkJobService.WithRawResponse + + fun accounts(): AccountService.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..7be195f3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt @@ -0,0 +1,96 @@ +// 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.BulkJobServiceAsync +import com.imagekit.api.services.async.CustomMetadataFieldServiceAsync +import com.imagekit.api.services.async.FileServiceAsync +import com.imagekit.api.services.async.FolderServiceAsync +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 folder(): FolderServiceAsync + + fun bulkJobs(): BulkJobServiceAsync + + fun accounts(): AccountServiceAsync + + /** + * 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 folder(): FolderServiceAsync.WithRawResponse + + fun bulkJobs(): BulkJobServiceAsync.WithRawResponse + + fun accounts(): AccountServiceAsync.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..ca9f5ca3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt @@ -0,0 +1,114 @@ +// 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.BulkJobServiceAsync +import com.imagekit.api.services.async.BulkJobServiceAsyncImpl +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 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 folder: FolderServiceAsync by lazy { + FolderServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val bulkJobs: BulkJobServiceAsync by lazy { + BulkJobServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val accounts: AccountServiceAsync by lazy { + AccountServiceAsyncImpl(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 folder(): FolderServiceAsync = folder + + override fun bulkJobs(): BulkJobServiceAsync = bulkJobs + + override fun accounts(): AccountServiceAsync = accounts + + override fun close() = clientOptions.httpClient.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 folder: FolderServiceAsync.WithRawResponse by lazy { + FolderServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val bulkJobs: BulkJobServiceAsync.WithRawResponse by lazy { + BulkJobServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val accounts: AccountServiceAsync.WithRawResponse by lazy { + AccountServiceAsyncImpl.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 folder(): FolderServiceAsync.WithRawResponse = folder + + override fun bulkJobs(): BulkJobServiceAsync.WithRawResponse = bulkJobs + + override fun accounts(): AccountServiceAsync.WithRawResponse = accounts + } +} 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..9abcbac7 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt @@ -0,0 +1,108 @@ +// 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.BulkJobService +import com.imagekit.api.services.blocking.BulkJobServiceImpl +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 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 folder: FolderService by lazy { FolderServiceImpl(clientOptionsWithUserAgent) } + + private val bulkJobs: BulkJobService by lazy { BulkJobServiceImpl(clientOptionsWithUserAgent) } + + private val accounts: AccountService by lazy { AccountServiceImpl(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 folder(): FolderService = folder + + override fun bulkJobs(): BulkJobService = bulkJobs + + override fun accounts(): AccountService = accounts + + override fun close() = clientOptions.httpClient.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 folder: FolderService.WithRawResponse by lazy { + FolderServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val bulkJobs: BulkJobService.WithRawResponse by lazy { + BulkJobServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val accounts: AccountService.WithRawResponse by lazy { + AccountServiceImpl.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 folder(): FolderService.WithRawResponse = folder + + override fun bulkJobs(): BulkJobService.WithRawResponse = bulkJobs + + override fun accounts(): AccountService.WithRawResponse = accounts + } +} 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..a9c2b13a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -0,0 +1,440 @@ +// 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. + */ + @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 key starts with `private_`. */ + @get:JvmName("privateApiKey") val privateApiKey: String, + private val password: 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 + + /** + * Do not set this, its value is ignored + * + * Defaults to `"does_not_matter"`. + */ + fun password(): Optional = Optional.ofNullable(password) + + 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? = "does_not_matter" + + @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 + } + + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `image-kit-java-client-okhttp` or implement your own. + */ + 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 key starts with `private_`. */ + fun privateApiKey(privateApiKey: String) = apply { this.privateApiKey = privateApiKey } + + /** + * Do not set this, its value is ignored + * + * Defaults to `"does_not_matter"`. + */ + fun password(password: String?) = apply { this.password = password } + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional) = password(password.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.orgMyPasswordToken` |`ORG_MY_PASSWORD_TOKEN` |false |`"does_not_matter"` | + * |`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.orgMyPasswordToken") + ?: System.getenv("ORG_MY_PASSWORD_TOKEN")) + ?.let { password(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, + ) + } + } +} 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/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/accounts/AccountGetUsageParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParams.kt new file mode 100644 index 00000000..5f85926e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParams.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts + +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 AccountGetUsageParams +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 [AccountGetUsageParams]. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountGetUsageParams]. */ + 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(accountGetUsageParams: AccountGetUsageParams) = apply { + endDate = accountGetUsageParams.endDate + startDate = accountGetUsageParams.startDate + additionalHeaders = accountGetUsageParams.additionalHeaders.toBuilder() + additionalQueryParams = accountGetUsageParams.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 [AccountGetUsageParams]. + * + * 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(): AccountGetUsageParams = + AccountGetUsageParams( + 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 AccountGetUsageParams && + 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() = + "AccountGetUsageParams{endDate=$endDate, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponse.kt new file mode 100644 index 00000000..8ea6ef2a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponse.kt @@ -0,0 +1,359 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts + +import 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 AccountGetUsageResponse +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 [AccountGetUsageResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountGetUsageResponse]. */ + 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(accountGetUsageResponse: AccountGetUsageResponse) = apply { + bandwidthBytes = accountGetUsageResponse.bandwidthBytes + extensionUnitsCount = accountGetUsageResponse.extensionUnitsCount + mediaLibraryStorageBytes = accountGetUsageResponse.mediaLibraryStorageBytes + originalCacheStorageBytes = accountGetUsageResponse.originalCacheStorageBytes + videoProcessingUnitsCount = accountGetUsageResponse.videoProcessingUnitsCount + additionalProperties = accountGetUsageResponse.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 [AccountGetUsageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccountGetUsageResponse = + AccountGetUsageResponse( + bandwidthBytes, + extensionUnitsCount, + mediaLibraryStorageBytes, + originalCacheStorageBytes, + videoProcessingUnitsCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccountGetUsageResponse = 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 AccountGetUsageResponse && + 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() = + "AccountGetUsageResponse{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/bulkjobs/BulkJobCopyFolderParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParams.kt new file mode 100644 index 00000000..33271fd7 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParams.kt @@ -0,0 +1,609 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +import 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 BulkJobCopyFolderParams +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 [BulkJobCopyFolderParams]. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFolderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkJobCopyFolderParams]. */ + 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(bulkJobCopyFolderParams: BulkJobCopyFolderParams) = apply { + body = bulkJobCopyFolderParams.body.toBuilder() + additionalHeaders = bulkJobCopyFolderParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkJobCopyFolderParams.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 [BulkJobCopyFolderParams]. + * + * 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(): BulkJobCopyFolderParams = + BulkJobCopyFolderParams( + 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 BulkJobCopyFolderParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkJobCopyFolderParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponse.kt new file mode 100644 index 00000000..177f822d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponse.kt @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +import 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 BulkJobCopyFolderResponse +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 (e.g. if the + * server responded with an unexpected value). + */ + fun jobId(): Optional = jobId.getOptional("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 [BulkJobCopyFolderResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkJobCopyFolderResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkJobCopyFolderResponse: BulkJobCopyFolderResponse) = apply { + jobId = bulkJobCopyFolderResponse.jobId + additionalProperties = bulkJobCopyFolderResponse.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 [BulkJobCopyFolderResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkJobCopyFolderResponse = + BulkJobCopyFolderResponse(jobId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BulkJobCopyFolderResponse = 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 BulkJobCopyFolderResponse && + jobId == other.jobId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkJobCopyFolderResponse{jobId=$jobId, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParams.kt new file mode 100644 index 00000000..6d36fb85 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParams.kt @@ -0,0 +1,521 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +import 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 BulkJobMoveFolderParams +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 [BulkJobMoveFolderParams]. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFolderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkJobMoveFolderParams]. */ + 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(bulkJobMoveFolderParams: BulkJobMoveFolderParams) = apply { + body = bulkJobMoveFolderParams.body.toBuilder() + additionalHeaders = bulkJobMoveFolderParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkJobMoveFolderParams.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 [BulkJobMoveFolderParams]. + * + * 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(): BulkJobMoveFolderParams = + BulkJobMoveFolderParams( + 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 BulkJobMoveFolderParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkJobMoveFolderParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponse.kt new file mode 100644 index 00000000..cc966b42 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponse.kt @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +import 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 BulkJobMoveFolderResponse +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 (e.g. if the + * server responded with an unexpected value). + */ + fun jobId(): Optional = jobId.getOptional("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 [BulkJobMoveFolderResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkJobMoveFolderResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkJobMoveFolderResponse: BulkJobMoveFolderResponse) = apply { + jobId = bulkJobMoveFolderResponse.jobId + additionalProperties = bulkJobMoveFolderResponse.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 [BulkJobMoveFolderResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkJobMoveFolderResponse = + BulkJobMoveFolderResponse(jobId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BulkJobMoveFolderResponse = 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 BulkJobMoveFolderResponse && + jobId == other.jobId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkJobMoveFolderResponse{jobId=$jobId, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParams.kt new file mode 100644 index 00000000..da3b93de --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +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 BulkJobRetrieveStatusParams +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(): BulkJobRetrieveStatusParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [BulkJobRetrieveStatusParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkJobRetrieveStatusParams]. */ + 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(bulkJobRetrieveStatusParams: BulkJobRetrieveStatusParams) = apply { + jobId = bulkJobRetrieveStatusParams.jobId + additionalHeaders = bulkJobRetrieveStatusParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkJobRetrieveStatusParams.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 [BulkJobRetrieveStatusParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkJobRetrieveStatusParams = + BulkJobRetrieveStatusParams( + 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 BulkJobRetrieveStatusParams && + jobId == other.jobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(jobId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkJobRetrieveStatusParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponse.kt new file mode 100644 index 00000000..3b098f35 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponse.kt @@ -0,0 +1,226 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +import 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 BulkJobRetrieveStatusResponse +private constructor( + private val jobId: JsonField, + private val status: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("jobId") @ExcludeMissing jobId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(jobId, 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") + + /** + * Status of the bulk job. Possible values - `Pending`, `Completed`. + * + * @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. Possible values - `COPY_FOLDER`, `MOVE_FOLDER`. + * + * @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 [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 + * [BulkJobRetrieveStatusResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkJobRetrieveStatusResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkJobRetrieveStatusResponse: BulkJobRetrieveStatusResponse) = apply { + jobId = bulkJobRetrieveStatusResponse.jobId + status = bulkJobRetrieveStatusResponse.status + type = bulkJobRetrieveStatusResponse.type + additionalProperties = bulkJobRetrieveStatusResponse.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 } + + /** Status of the bulk job. Possible values - `Pending`, `Completed`. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] 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. Possible values - `COPY_FOLDER`, `MOVE_FOLDER`. */ + 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 [BulkJobRetrieveStatusResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkJobRetrieveStatusResponse = + BulkJobRetrieveStatusResponse(jobId, status, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BulkJobRetrieveStatusResponse = apply { + if (validated) { + return@apply + } + + jobId() + status() + 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 (jobId.asKnown().isPresent) 1 else 0) + + (if (status.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 BulkJobRetrieveStatusResponse && + jobId == other.jobId && + status == other.status && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(jobId, status, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkJobRetrieveStatusResponse{jobId=$jobId, status=$status, type=$type, 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..9d950bf8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -0,0 +1,2316 @@ +// 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.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s)`. + */ + fun defaultValueOfUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) + ) + + /** + * 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 TEXT_AREA = 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, + TEXT_AREA, + 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, + TEXT_AREA, + 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 + TEXT_AREA -> Value.TEXT_AREA + 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 + TEXT_AREA -> Known.TEXT_AREA + 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 unnamedSchemaWithArrayParent3s: 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 unnamedSchemaWithArrayParent3s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent3s) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isUnnamedSchemaWithArrayParent3s(): Boolean = unnamedSchemaWithArrayParent3s != 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 asUnnamedSchemaWithArrayParent3s(): List = + unnamedSchemaWithArrayParent3s.getOrThrow("unnamedSchemaWithArrayParent3s") + + 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) + unnamedSchemaWithArrayParent3s != null -> + visitor.visitUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) + 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 visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) { + unnamedSchemaWithArrayParent3s.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 visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = unnamedSchemaWithArrayParent3s.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 && + unnamedSchemaWithArrayParent3s == other.unnamedSchemaWithArrayParent3s + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent3s) + + override fun toString(): String = + when { + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent3s != null -> + "DefaultValue{unnamedSchemaWithArrayParent3s=$unnamedSchemaWithArrayParent3s}" + _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 ofUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent3s = + unnamedSchemaWithArrayParent3s.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 visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: 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( + unnamedSchemaWithArrayParent3s = 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.unnamedSchemaWithArrayParent3s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent3s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DefaultValue") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) + class UnnamedSchemaWithArrayParent3 + 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(): UnnamedSchemaWithArrayParent3 = 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 UnnamedSchemaWithArrayParent3 && + 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 -> "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) = UnnamedSchemaWithArrayParent3(string = string) + + @JvmStatic + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent3(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent3(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent3] 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 [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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent3(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent3(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent3(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 -> 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 + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent3::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent3, + 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 UnnamedSchemaWithArrayParent3") + } + } + } + } + } + + /** + * 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/CustomMetadataFieldCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt new file mode 100644 index 00000000..62d1b09c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt @@ -0,0 +1,2017 @@ +// 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 CustomMetadataFieldCreateResponse +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 + * [CustomMetadataFieldCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .label() + * .name() + * .schema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataFieldCreateResponse]. */ + 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(customMetadataFieldCreateResponse: CustomMetadataFieldCreateResponse) = + apply { + id = customMetadataFieldCreateResponse.id + label = customMetadataFieldCreateResponse.label + name = customMetadataFieldCreateResponse.name + schema = customMetadataFieldCreateResponse.schema + additionalProperties = + customMetadataFieldCreateResponse.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 [CustomMetadataFieldCreateResponse]. + * + * 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(): CustomMetadataFieldCreateResponse = + CustomMetadataFieldCreateResponse( + checkRequired("id", id), + checkRequired("label", label), + checkRequired("name", name), + checkRequired("schema", schema), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadataFieldCreateResponse = 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.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s)`. + */ + fun defaultValueOfUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) + ) + + /** 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 TEXT_AREA = 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, + TEXT_AREA, + 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, + TEXT_AREA, + 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 + TEXT_AREA -> Value.TEXT_AREA + 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 + TEXT_AREA -> Known.TEXT_AREA + 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 unnamedSchemaWithArrayParent0s: 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 unnamedSchemaWithArrayParent0s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent0s) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isUnnamedSchemaWithArrayParent0s(): Boolean = unnamedSchemaWithArrayParent0s != 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 asUnnamedSchemaWithArrayParent0s(): List = + unnamedSchemaWithArrayParent0s.getOrThrow("unnamedSchemaWithArrayParent0s") + + 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) + unnamedSchemaWithArrayParent0s != null -> + visitor.visitUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) + 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 visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List + ) { + unnamedSchemaWithArrayParent0s.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 visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List + ) = unnamedSchemaWithArrayParent0s.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 && + unnamedSchemaWithArrayParent0s == other.unnamedSchemaWithArrayParent0s + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent0s) + + override fun toString(): String = + when { + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent0s != null -> + "DefaultValue{unnamedSchemaWithArrayParent0s=$unnamedSchemaWithArrayParent0s}" + _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 ofUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent0s = + unnamedSchemaWithArrayParent0s.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 visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: 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( + unnamedSchemaWithArrayParent0s = 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.unnamedSchemaWithArrayParent0s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent0s) + 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 CustomMetadataFieldCreateResponse && + 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() = + "CustomMetadataFieldCreateResponse{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/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..545434fd --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt @@ -0,0 +1,218 @@ +// 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. Default value is + * `false`. + */ + 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. Default value is + * `false`. + */ + 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/CustomMetadataFieldListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt new file mode 100644 index 00000000..85ed99cb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt @@ -0,0 +1,2017 @@ +// 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 CustomMetadataFieldListResponse +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 + * [CustomMetadataFieldListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .label() + * .name() + * .schema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataFieldListResponse]. */ + 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(customMetadataFieldListResponse: CustomMetadataFieldListResponse) = + apply { + id = customMetadataFieldListResponse.id + label = customMetadataFieldListResponse.label + name = customMetadataFieldListResponse.name + schema = customMetadataFieldListResponse.schema + additionalProperties = + customMetadataFieldListResponse.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 [CustomMetadataFieldListResponse]. + * + * 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(): CustomMetadataFieldListResponse = + CustomMetadataFieldListResponse( + checkRequired("id", id), + checkRequired("label", label), + checkRequired("name", name), + checkRequired("schema", schema), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadataFieldListResponse = 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.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s)`. + */ + fun defaultValueOfUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) + ) + + /** 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 TEXT_AREA = 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, + TEXT_AREA, + 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, + TEXT_AREA, + 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 + TEXT_AREA -> Value.TEXT_AREA + 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 + TEXT_AREA -> Known.TEXT_AREA + 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 unnamedSchemaWithArrayParent2s: 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 unnamedSchemaWithArrayParent2s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent2s) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isUnnamedSchemaWithArrayParent2s(): Boolean = unnamedSchemaWithArrayParent2s != 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 asUnnamedSchemaWithArrayParent2s(): List = + unnamedSchemaWithArrayParent2s.getOrThrow("unnamedSchemaWithArrayParent2s") + + 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) + unnamedSchemaWithArrayParent2s != null -> + visitor.visitUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) + 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 visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) { + unnamedSchemaWithArrayParent2s.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 visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = unnamedSchemaWithArrayParent2s.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 && + unnamedSchemaWithArrayParent2s == other.unnamedSchemaWithArrayParent2s + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent2s) + + override fun toString(): String = + when { + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent2s != null -> + "DefaultValue{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" + _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 ofUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent2s = + unnamedSchemaWithArrayParent2s.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 visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: 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( + unnamedSchemaWithArrayParent2s = 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.unnamedSchemaWithArrayParent2s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent2s) + 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 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 CustomMetadataFieldListResponse && + 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() = + "CustomMetadataFieldListResponse{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/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt new file mode 100644 index 00000000..d8f5d652 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -0,0 +1,2037 @@ +// 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.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s)`. + */ + fun defaultValueOfUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) + ) + + /** + * 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 unnamedSchemaWithArrayParent4s: 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 unnamedSchemaWithArrayParent4s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent4s) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isUnnamedSchemaWithArrayParent4s(): Boolean = unnamedSchemaWithArrayParent4s != 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 asUnnamedSchemaWithArrayParent4s(): List = + unnamedSchemaWithArrayParent4s.getOrThrow("unnamedSchemaWithArrayParent4s") + + 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) + unnamedSchemaWithArrayParent4s != null -> + visitor.visitUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) + 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 visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) { + unnamedSchemaWithArrayParent4s.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 visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = unnamedSchemaWithArrayParent4s.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 && + unnamedSchemaWithArrayParent4s == other.unnamedSchemaWithArrayParent4s + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent4s) + + override fun toString(): String = + when { + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent4s != null -> + "DefaultValue{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" + _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 ofUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent4s = + unnamedSchemaWithArrayParent4s.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 visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: 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( + unnamedSchemaWithArrayParent4s = 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.unnamedSchemaWithArrayParent4s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent4s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DefaultValue") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent4.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) + class UnnamedSchemaWithArrayParent4 + 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(): UnnamedSchemaWithArrayParent4 = 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 UnnamedSchemaWithArrayParent4 && + 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 -> "UnnamedSchemaWithArrayParent4{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent4{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent4{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = UnnamedSchemaWithArrayParent4(string = string) + + @JvmStatic + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent4(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent4(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent4] 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 [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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent4(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent4(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent4(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 -> UnnamedSchemaWithArrayParent4(_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( + UnnamedSchemaWithArrayParent4::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent4, + 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 UnnamedSchemaWithArrayParent4") + } + } + } + } + } + + /** + * 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/custommetadatafields/CustomMetadataFieldUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt new file mode 100644 index 00000000..934e3321 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt @@ -0,0 +1,2017 @@ +// 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 CustomMetadataFieldUpdateResponse +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 + * [CustomMetadataFieldUpdateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .label() + * .name() + * .schema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataFieldUpdateResponse]. */ + 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(customMetadataFieldUpdateResponse: CustomMetadataFieldUpdateResponse) = + apply { + id = customMetadataFieldUpdateResponse.id + label = customMetadataFieldUpdateResponse.label + name = customMetadataFieldUpdateResponse.name + schema = customMetadataFieldUpdateResponse.schema + additionalProperties = + customMetadataFieldUpdateResponse.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 [CustomMetadataFieldUpdateResponse]. + * + * 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(): CustomMetadataFieldUpdateResponse = + CustomMetadataFieldUpdateResponse( + checkRequired("id", id), + checkRequired("label", label), + checkRequired("name", name), + checkRequired("schema", schema), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadataFieldUpdateResponse = 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.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s)`. + */ + fun defaultValueOfUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) + ) + + /** 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 TEXT_AREA = 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, + TEXT_AREA, + 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, + TEXT_AREA, + 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 + TEXT_AREA -> Value.TEXT_AREA + 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 + TEXT_AREA -> Known.TEXT_AREA + 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 unnamedSchemaWithArrayParent1s: 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 unnamedSchemaWithArrayParent1s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent1s) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isUnnamedSchemaWithArrayParent1s(): Boolean = unnamedSchemaWithArrayParent1s != 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 asUnnamedSchemaWithArrayParent1s(): List = + unnamedSchemaWithArrayParent1s.getOrThrow("unnamedSchemaWithArrayParent1s") + + 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) + unnamedSchemaWithArrayParent1s != null -> + visitor.visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) + 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 visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List + ) { + unnamedSchemaWithArrayParent1s.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 visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List + ) = unnamedSchemaWithArrayParent1s.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 && + unnamedSchemaWithArrayParent1s == other.unnamedSchemaWithArrayParent1s + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent1s) + + override fun toString(): String = + when { + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent1s != null -> + "DefaultValue{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" + _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 ofUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent1s = + unnamedSchemaWithArrayParent1s.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 visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: 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( + unnamedSchemaWithArrayParent1s = 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.unnamedSchemaWithArrayParent1s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent1s) + 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 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 CustomMetadataFieldUpdateResponse && + 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() = + "CustomMetadataFieldUpdateResponse{id=$id, label=$label, name=$name, schema=$schema, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifDetails.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifDetails.kt new file mode 100644 index 00000000..7d10aeb9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifDetails.kt @@ -0,0 +1,1142 @@ +// 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 + +/** Object containing Exif details. */ +class ExifDetails +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 [ExifDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExifDetails]. */ + 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(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) = 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 [ExifDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExifDetails = + ExifDetails( + 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(): ExifDetails = 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 ExifDetails && + 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() = + "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}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifImage.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifImage.kt new file mode 100644 index 00000000..40bef130 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifImage.kt @@ -0,0 +1,522 @@ +// 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 + +/** Object containing EXIF image information. */ +class ExifImage +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 [ExifImage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExifImage]. */ + 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(exifImage: ExifImage) = apply { + exifOffset = exifImage.exifOffset + gpsInfo = exifImage.gpsInfo + make = exifImage.make + model = exifImage.model + modifyDate = exifImage.modifyDate + orientation = exifImage.orientation + resolutionUnit = exifImage.resolutionUnit + software = exifImage.software + xResolution = exifImage.xResolution + yCbCrPositioning = exifImage.yCbCrPositioning + yResolution = exifImage.yResolution + additionalProperties = exifImage.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 [ExifImage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExifImage = + ExifImage( + exifOffset, + gpsInfo, + make, + model, + modifyDate, + orientation, + resolutionUnit, + software, + xResolution, + yCbCrPositioning, + yResolution, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExifImage = 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 ExifImage && + 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() = + "ExifImage{exifOffset=$exifOffset, gpsInfo=$gpsInfo, make=$make, model=$model, modifyDate=$modifyDate, orientation=$orientation, resolutionUnit=$resolutionUnit, software=$software, xResolution=$xResolution, yCbCrPositioning=$yCbCrPositioning, yResolution=$yResolution, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsParams.kt new file mode 100644 index 00000000..ce23d3e6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsParams.kt @@ -0,0 +1,533 @@ +// 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.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 FileAddTagsParams +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 [FileAddTagsParams]. + * + * The following fields are required: + * ```java + * .fileIds() + * .tags() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileAddTagsParams]. */ + 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(fileAddTagsParams: FileAddTagsParams) = apply { + body = fileAddTagsParams.body.toBuilder() + additionalHeaders = fileAddTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = fileAddTagsParams.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 [FileAddTagsParams]. + * + * 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(): FileAddTagsParams = + FileAddTagsParams( + 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 FileAddTagsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileAddTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsResponse.kt new file mode 100644 index 00000000..14a1888e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsResponse.kt @@ -0,0 +1,189 @@ +// 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 + +class FileAddTagsResponse +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 [FileAddTagsResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileAddTagsResponse]. */ + class Builder internal constructor() { + + private var successfullyUpdatedFileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileAddTagsResponse: FileAddTagsResponse) = apply { + successfullyUpdatedFileIds = + fileAddTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = fileAddTagsResponse.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 [FileAddTagsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileAddTagsResponse = + FileAddTagsResponse( + (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FileAddTagsResponse = 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 FileAddTagsResponse && + successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(successfullyUpdatedFileIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileAddTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, 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/FileListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListParams.kt new file mode 100644 index 00000000..74812123 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListParams.kt @@ -0,0 +1,553 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +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 FileListParams +private constructor( + private val fileType: String?, + private val limit: String?, + private val path: String?, + private val searchQuery: String?, + private val skip: String?, + private val sort: String?, + private val type: Type?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Type of files to include in the result set. Accepts three values: + * + * `all` - include all types of files in the result set. `image` - only search in image type + * files. `non-image` - only search in files that are not images, e.g., JS or CSS or video + * files. + * + * Default value - `all` + */ + fun fileType(): Optional = Optional.ofNullable(fileType) + + /** + * The maximum number of results to return in response: + * + * Minimum value - 1 + * + * Maximum value - 1000 + * + * Default value - 1000 + */ + 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. + */ + 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: + * + * Minimum value - 0 + * + * Default value - 0 + */ + fun skip(): Optional = Optional.ofNullable(skip) + + /** + * You can sort based on the following fields: + * 1. name - `ASC_NAME` or `DESC_NAME` + * 2. createdAt - `ASC_CREATED` or `DESC_CREATED` + * 3. updatedAt - `ASC_UPDATED` or `DESC_UPDATED` + * 4. height - `ASC_HEIGHT` or `DESC_HEIGHT` + * 5. width - `ASC_WIDTH` or `DESC_WIDTH` + * 6. size - `ASC_SIZE` or `DESC_SIZE` + * + * Default value - `ASC_CREATED` + */ + fun sort(): Optional = Optional.ofNullable(sort) + + /** + * Limit search to one of `file`, `file-version`, or `folder`. Pass `all` to include `files` and + * `folders` in search results (`file-version` will not be included in this case). + * + * Default value - `file` + */ + 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(): FileListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FileListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileListParams]. */ + class Builder internal constructor() { + + private var fileType: String? = null + private var limit: String? = null + private var path: String? = null + private var searchQuery: String? = null + private var skip: String? = null + private var sort: String? = null + private var type: Type? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(fileListParams: FileListParams) = apply { + fileType = fileListParams.fileType + limit = fileListParams.limit + path = fileListParams.path + searchQuery = fileListParams.searchQuery + skip = fileListParams.skip + sort = fileListParams.sort + type = fileListParams.type + additionalHeaders = fileListParams.additionalHeaders.toBuilder() + additionalQueryParams = fileListParams.additionalQueryParams.toBuilder() + } + + /** + * Type of files to include in the result set. Accepts three values: + * + * `all` - include all types of files in the result set. `image` - only search in image type + * files. `non-image` - only search in files that are not images, e.g., JS or CSS or video + * files. + * + * Default value - `all` + */ + fun fileType(fileType: String?) = 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: + * + * Minimum value - 1 + * + * Maximum value - 1000 + * + * Default value - 1000 + */ + fun limit(limit: String?) = apply { this.limit = limit } + + /** 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. + */ + 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: + * + * Minimum value - 0 + * + * Default value - 0 + */ + fun skip(skip: String?) = apply { this.skip = skip } + + /** Alias for calling [Builder.skip] with `skip.orElse(null)`. */ + fun skip(skip: Optional) = skip(skip.getOrNull()) + + /** + * You can sort based on the following fields: + * 1. name - `ASC_NAME` or `DESC_NAME` + * 2. createdAt - `ASC_CREATED` or `DESC_CREATED` + * 3. updatedAt - `ASC_UPDATED` or `DESC_UPDATED` + * 4. height - `ASC_HEIGHT` or `DESC_HEIGHT` + * 5. width - `ASC_WIDTH` or `DESC_WIDTH` + * 6. size - `ASC_SIZE` or `DESC_SIZE` + * + * Default value - `ASC_CREATED` + */ + fun sort(sort: String?) = apply { this.sort = sort } + + /** Alias for calling [Builder.sort] with `sort.orElse(null)`. */ + fun sort(sort: Optional) = sort(sort.getOrNull()) + + /** + * Limit search to one of `file`, `file-version`, or `folder`. Pass `all` to include `files` + * and `folders` in search results (`file-version` will not be included in this case). + * + * Default value - `file` + */ + 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 [FileListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileListParams = + FileListParams( + 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) } + limit?.let { put("limit", it) } + path?.let { put("path", it) } + searchQuery?.let { put("searchQuery", it) } + skip?.let { put("skip", it) } + sort?.let { put("sort", it) } + type?.let { put("type", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** + * Limit search to one of `file`, `file-version`, or `folder`. Pass `all` to include `files` and + * `folders` in search results (`file-version` will not be included in this case). + * + * Default value - `file` + */ + 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 FileListParams && + 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() = + "FileListParams{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/files/FileListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListResponse.kt new file mode 100644 index 00000000..83cb3a96 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListResponse.kt @@ -0,0 +1,1353 @@ +// 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 + +/** Object containing details of a file or file version. */ +class FileListResponse +private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + 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: JsonValue = 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, + 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. */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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 [FileListResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileListResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonValue = 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(fileListResponse: FileListResponse) = apply { + aiTags = fileListResponse.aiTags.map { it.toMutableList() } + createdAt = fileListResponse.createdAt + customCoordinates = fileListResponse.customCoordinates + customMetadata = fileListResponse.customMetadata + fileId = fileListResponse.fileId + filePath = fileListResponse.filePath + fileType = fileListResponse.fileType + hasAlpha = fileListResponse.hasAlpha + height = fileListResponse.height + isPrivateFile = fileListResponse.isPrivateFile + isPublished = fileListResponse.isPublished + mime = fileListResponse.mime + name = fileListResponse.name + size = fileListResponse.size + tags = fileListResponse.tags.map { it.toMutableList() } + thumbnail = fileListResponse.thumbnail + type = fileListResponse.type + updatedAt = fileListResponse.updatedAt + url = fileListResponse.url + versionInfo = fileListResponse.versionInfo + width = fileListResponse.width + additionalProperties = fileListResponse.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: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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: 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 } + + /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [FileListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileListResponse = + FileListResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + 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(): FileListResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type() + 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) + + (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) + + (if (type.asKnown().isPresent) 1 else 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 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 FileListResponse && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + 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() = + "FileListResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/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/FileRemoveAiTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParams.kt new file mode 100644 index 00000000..2ac2780f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParams.kt @@ -0,0 +1,538 @@ +// 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.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 FileRemoveAiTagsParams +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 [FileRemoveAiTagsParams]. + * + * The following fields are required: + * ```java + * .aiTags() + * .fileIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileRemoveAiTagsParams]. */ + 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(fileRemoveAiTagsParams: FileRemoveAiTagsParams) = apply { + body = fileRemoveAiTagsParams.body.toBuilder() + additionalHeaders = fileRemoveAiTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = fileRemoveAiTagsParams.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 [FileRemoveAiTagsParams]. + * + * 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(): FileRemoveAiTagsParams = + FileRemoveAiTagsParams( + 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 FileRemoveAiTagsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileRemoveAiTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponse.kt new file mode 100644 index 00000000..ed7ef4da --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponse.kt @@ -0,0 +1,189 @@ +// 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 + +class FileRemoveAiTagsResponse +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 [FileRemoveAiTagsResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileRemoveAiTagsResponse]. */ + class Builder internal constructor() { + + private var successfullyUpdatedFileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileRemoveAiTagsResponse: FileRemoveAiTagsResponse) = apply { + successfullyUpdatedFileIds = + fileRemoveAiTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = fileRemoveAiTagsResponse.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 [FileRemoveAiTagsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileRemoveAiTagsResponse = + FileRemoveAiTagsResponse( + (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FileRemoveAiTagsResponse = 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 FileRemoveAiTagsResponse && + successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(successfullyUpdatedFileIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileRemoveAiTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsParams.kt new file mode 100644 index 00000000..c3b029c8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsParams.kt @@ -0,0 +1,534 @@ +// 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.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 FileRemoveTagsParams +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 [FileRemoveTagsParams]. + * + * The following fields are required: + * ```java + * .fileIds() + * .tags() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileRemoveTagsParams]. */ + 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(fileRemoveTagsParams: FileRemoveTagsParams) = apply { + body = fileRemoveTagsParams.body.toBuilder() + additionalHeaders = fileRemoveTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = fileRemoveTagsParams.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 [FileRemoveTagsParams]. + * + * 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(): FileRemoveTagsParams = + FileRemoveTagsParams( + 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 FileRemoveTagsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileRemoveTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponse.kt new file mode 100644 index 00000000..351e603c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponse.kt @@ -0,0 +1,189 @@ +// 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 + +class FileRemoveTagsResponse +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 [FileRemoveTagsResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileRemoveTagsResponse]. */ + class Builder internal constructor() { + + private var successfullyUpdatedFileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileRemoveTagsResponse: FileRemoveTagsResponse) = apply { + successfullyUpdatedFileIds = + fileRemoveTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = fileRemoveTagsResponse.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 [FileRemoveTagsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileRemoveTagsResponse = + FileRemoveTagsResponse( + (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FileRemoveTagsResponse = 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 FileRemoveTagsResponse && + successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(successfullyUpdatedFileIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileRemoveTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, 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/FileUploadV1Params.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Params.kt new file mode 100644 index 00000000..9e452bcb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Params.kt @@ -0,0 +1,3127 @@ +// 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.JsonValue +import com.imagekit.api.core.MultipartField +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 com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * 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 `expiration` 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 FileUploadV1Params +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please ensure + * that our servers can access the URL. In case ImageKit is unable to download the file from the + * specified URL, a `400` error response is returned. This will also result in a `400` error if + * the file download request is aborted if response headers are not received in 8 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 file(): String = 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() + + /** + * Stringified JSON key-value data to be associated with the asset. + * + * @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() + + /** + * 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() + + /** + * Stringified JSON object with an array of extensions to be applied to the image. Refer to + * extensions schema in + * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). + * + * @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() + + /** + * Comma-separated values of the fields that you want the API to return in the response. + * + * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get the + * value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. + * + * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, + * `isPublished`, `customMetadata`, and `metadata`. + * + * @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. + * + * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all + * characters should not exceed 500. `%` is not allowed. + * + * If this field is not specified and the file is overwritten then the 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() + + /** + * Stringified JSON object with properties for pre and post transformations: + * + * `pre` - Accepts a "string" containing a valid transformation used for requesting a + * pre-transformation for an image or a video file. + * + * `post` - Accepts an array of objects with properties: + * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive bitrate + * streaming). + * - `value`: A "string" corresponding to the required transformation. Required if `type` is + * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. + * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. + * + * Read more about [Adaptive bitrate streaming (ABS)](/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 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 [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 [FileUploadV1Params]. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadV1Params]. */ + 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(fileUploadV1Params: FileUploadV1Params) = apply { + body = fileUploadV1Params.body.toBuilder() + additionalHeaders = fileUploadV1Params.additionalHeaders.toBuilder() + additionalQueryParams = fileUploadV1Params.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() } + + /** + * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please + * ensure that our servers can access the URL. In case ImageKit is unable to download the + * file from the specified URL, a `400` error response is returned. This will also result in + * a `400` error if the file download request is aborted if response headers are not + * received in 8 seconds. + */ + 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 [String] 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 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) + } + + /** Stringified JSON key-value data to be associated with the asset. */ + fun customMetadata(customMetadata: String) = apply { body.customMetadata(customMetadata) } + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed [String] 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) + } + + /** + * 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: String) = apply { body.expire(expire) } + + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [String] 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) } + + /** + * Stringified JSON object with an array of extensions to be applied to the image. Refer to + * extensions schema in + * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). + */ + fun extensions(extensions: String) = apply { body.extensions(extensions) } + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed [String] 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) } + + /** + * 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: IsPrivateFile) = apply { + body.isPrivateFile(isPrivateFile) + } + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [IsPrivateFile] 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: IsPublished) = apply { body.isPublished(isPublished) } + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [IsPublished] 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: OverwriteAiTags) = apply { + body.overwriteAiTags(overwriteAiTags) + } + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [OverwriteAiTags] + * 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: OverwriteCustomMetadata) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) + } + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed + * [OverwriteCustomMetadata] 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: String) = apply { body.overwriteFile(overwriteFile) } + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [String] 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: OverwriteTags) = apply { + body.overwriteTags(overwriteTags) + } + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [OverwriteTags] 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) } + + /** + * Comma-separated values of the fields that you want the API to return in the response. + * + * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get + * the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. + * + * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, + * `isPublished`, `customMetadata`, and `metadata`. + */ + fun responseFields(responseFields: String) = apply { body.responseFields(responseFields) } + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] 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(responseFields: MultipartField) = apply { + body.responseFields(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. + */ + 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. + * + * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all + * characters should not exceed 500. `%` is not allowed. + * + * If this field is not specified and the file is overwritten then the tags will be removed. + */ + fun tags(tags: String) = apply { body.tags(tags) } + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed [String] 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) } + + /** + * Stringified JSON object with properties for pre and post transformations: + * + * `pre` - Accepts a "string" containing a valid transformation used for requesting a + * pre-transformation for an image or a video file. + * + * `post` - Accepts an array of objects with properties: + * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive + * bitrate streaming). + * - `value`: A "string" corresponding to the required transformation. Required if `type` is + * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. + * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. + * + * Read more about [Adaptive bitrate streaming (ABS)](/docs/adaptive-bitrate-streaming). + */ + fun transformation(transformation: String) = apply { body.transformation(transformation) } + + /** + * Sets [Builder.transformation] to an arbitrary multipart 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: 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: UseUniqueFileName) = apply { + body.useUniqueFileName(useUniqueFileName) + } + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [UseUniqueFileName] + * 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 [FileUploadV1Params]. + * + * 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(): FileUploadV1Params = + FileUploadV1Params( + 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(), + "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 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, + ) { + + /** + * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please + * ensure that our servers can access the URL. In case ImageKit is unable to download the + * file from the specified URL, a `400` error response is returned. This will also result in + * a `400` error if the file download request is aborted if response headers are not + * received in 8 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 file(): String = 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") + + /** + * Stringified JSON key-value data to be associated with the asset. + * + * @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") + + /** + * 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") + + /** + * Stringified JSON object with an array of extensions to be applied to the image. Refer to + * extensions schema in + * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). + * + * @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") + + /** + * Comma-separated values of the fields that you want the API to return in the response. + * + * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get + * the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. + * + * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, + * `isPublished`, `customMetadata`, and `metadata`. + * + * @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. + * + * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all + * characters should not exceed 500. `%` is not allowed. + * + * If this field is not specified and the file is overwritten then the 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") + + /** + * Stringified JSON object with properties for pre and post transformations: + * + * `pre` - Accepts a "string" containing a valid transformation used for requesting a + * pre-transformation for an image or a video file. + * + * `post` - Accepts an array of objects with properties: + * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive + * bitrate streaming). + * - `value`: A "string" corresponding to the required transformation. Required if `type` is + * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. + * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. + * + * Read more about [Adaptive bitrate streaming (ABS)](/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 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 [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 expire: MultipartField = MultipartField.of(null) + private var extensions: MultipartField = MultipartField.of(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 = MultipartField.of(null) + private var signature: MultipartField = MultipartField.of(null) + private var tags: 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() + + @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 + expire = body.expire + extensions = body.extensions + 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 + signature = body.signature + tags = body.tags + transformation = body.transformation + useUniqueFileName = body.useUniqueFileName + webhookUrl = body.webhookUrl + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please + * ensure that our servers can access the URL. In case ImageKit is unable to download + * the file from the specified URL, a `400` error response is returned. This will also + * result in a `400` error if the file download request is aborted if response headers + * are not received in 8 seconds. + */ + 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 [String] 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 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 + } + + /** Stringified JSON key-value data to be associated with the asset. */ + fun customMetadata(customMetadata: String) = + customMetadata(MultipartField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed [String] 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 + } + + /** + * 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: String) = expire(MultipartField.of(expire)) + + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [String] 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 } + + /** + * Stringified JSON object with an array of extensions to be applied to the image. Refer + * to extensions schema in + * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). + */ + fun extensions(extensions: String) = extensions(MultipartField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed [String] 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 + } + + /** + * 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: IsPrivateFile) = + isPrivateFile(MultipartField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [IsPrivateFile] + * 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: IsPublished) = isPublished(MultipartField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [IsPublished] 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: OverwriteAiTags) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [OverwriteAiTags] + * 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: OverwriteCustomMetadata) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed + * [OverwriteCustomMetadata] 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: String) = + overwriteFile(MultipartField.of(overwriteFile)) + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [String] 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: OverwriteTags) = + overwriteTags(MultipartField.of(overwriteTags)) + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [OverwriteTags] + * 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 } + + /** + * Comma-separated values of the fields that you want the API to return in the response. + * + * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to + * get the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. + * + * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, + * `embeddedMetadata`, `isPublished`, `customMetadata`, and `metadata`. + */ + fun responseFields(responseFields: String) = + responseFields(MultipartField.of(responseFields)) + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] 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(responseFields: MultipartField) = apply { + this.responseFields = 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. + */ + 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. + * + * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of + * all characters should not exceed 500. `%` is not allowed. + * + * If this field is not specified and the file is overwritten then the tags will be + * removed. + */ + fun tags(tags: String) = tags(MultipartField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed [String] 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 } + + /** + * Stringified JSON object with properties for pre and post transformations: + * + * `pre` - Accepts a "string" containing a valid transformation used for requesting a + * pre-transformation for an image or a video file. + * + * `post` - Accepts an array of objects with properties: + * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive + * bitrate streaming). + * - `value`: A "string" corresponding to the required transformation. Required if + * `type` is `transformation` or `abs`. Optional if `type` is `gif-to-video` or + * `thumbnail`. + * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. + * + * Read more about [Adaptive bitrate streaming (ABS)](/docs/adaptive-bitrate-streaming). + */ + fun transformation(transformation: String) = + transformation(MultipartField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary multipart 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: 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: UseUniqueFileName) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed + * [UseUniqueFileName] 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, + expire, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + responseFields, + signature, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + fileName() + token() + checks() + customCoordinates() + customMetadata() + expire() + extensions() + folder() + isPrivateFile().ifPresent { it.validate() } + isPublished().ifPresent { it.validate() } + overwriteAiTags().ifPresent { it.validate() } + overwriteCustomMetadata().ifPresent { it.validate() } + overwriteFile() + overwriteTags().ifPresent { it.validate() } + publicKey() + responseFields() + signature() + tags() + transformation() + useUniqueFileName().ifPresent { it.validate() } + 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 && + 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, + 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, 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}" + } + + /** + * 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. + */ + class IsPrivateFile @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = IsPrivateFile(JsonField.of(value)) + } + + /** An enum containing [IsPrivateFile]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [IsPrivateFile]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IsPrivateFile] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [IsPrivateFile] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown IsPrivateFile: $value") + } + + /** + * Returns this class 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(): IsPrivateFile = 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 IsPrivateFile && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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. + */ + class IsPublished @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = IsPublished(JsonField.of(value)) + } + + /** An enum containing [IsPublished]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [IsPublished]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IsPublished] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [IsPublished] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown IsPublished: $value") + } + + /** + * Returns this class 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(): IsPublished = 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 IsPublished && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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. + */ + class OverwriteAiTags @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = OverwriteAiTags(JsonField.of(value)) + } + + /** An enum containing [OverwriteAiTags]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [OverwriteAiTags]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [OverwriteAiTags] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [OverwriteAiTags] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown OverwriteAiTags: $value") + } + + /** + * Returns this class 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(): OverwriteAiTags = 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 OverwriteAiTags && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + class OverwriteCustomMetadata + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = OverwriteCustomMetadata(JsonField.of(value)) + } + + /** An enum containing [OverwriteCustomMetadata]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [OverwriteCustomMetadata]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [OverwriteCustomMetadata] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [OverwriteCustomMetadata] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> + throw ImageKitInvalidDataException("Unknown OverwriteCustomMetadata: $value") + } + + /** + * Returns this class 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(): OverwriteCustomMetadata = 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 OverwriteCustomMetadata && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + class OverwriteTags @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = OverwriteTags(JsonField.of(value)) + } + + /** An enum containing [OverwriteTags]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [OverwriteTags]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [OverwriteTags] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [OverwriteTags] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown OverwriteTags: $value") + } + + /** + * Returns this class 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(): OverwriteTags = 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 OverwriteTags && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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. + */ + class UseUniqueFileName @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = UseUniqueFileName(JsonField.of(value)) + } + + /** An enum containing [UseUniqueFileName]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [UseUniqueFileName]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UseUniqueFileName] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [UseUniqueFileName] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown UseUniqueFileName: $value") + } + + /** + * Returns this class 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(): UseUniqueFileName = 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 UseUniqueFileName && 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 FileUploadV1Params && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileUploadV1Params{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Response.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Response.kt new file mode 100644 index 00000000..29242de7 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Response.kt @@ -0,0 +1,11793 @@ +// 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 successful upload. */ +class FileUploadV1Response +private constructor( + private val aiTags: JsonField>, + private val audioCodec: JsonField, + private val bitRate: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + 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: JsonValue = 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, + 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. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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 [FileUploadV1Response]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadV1Response]. */ + 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: JsonValue = 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(fileUploadV1Response: FileUploadV1Response) = apply { + aiTags = fileUploadV1Response.aiTags.map { it.toMutableList() } + audioCodec = fileUploadV1Response.audioCodec + bitRate = fileUploadV1Response.bitRate + customCoordinates = fileUploadV1Response.customCoordinates + customMetadata = fileUploadV1Response.customMetadata + duration = fileUploadV1Response.duration + embeddedMetadata = fileUploadV1Response.embeddedMetadata + extensionStatus = fileUploadV1Response.extensionStatus + fileId = fileUploadV1Response.fileId + filePath = fileUploadV1Response.filePath + fileType = fileUploadV1Response.fileType + height = fileUploadV1Response.height + isPrivateFile = fileUploadV1Response.isPrivateFile + isPublished = fileUploadV1Response.isPublished + metadata = fileUploadV1Response.metadata + name = fileUploadV1Response.name + size = fileUploadV1Response.size + tags = fileUploadV1Response.tags.map { it.toMutableList() } + thumbnailUrl = fileUploadV1Response.thumbnailUrl + url = fileUploadV1Response.url + versionInfo = fileUploadV1Response.versionInfo + videoCodec = fileUploadV1Response.videoCodec + width = fileUploadV1Response.width + additionalProperties = fileUploadV1Response.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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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 [FileUploadV1Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileUploadV1Response = + FileUploadV1Response( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + 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(): FileUploadV1Response = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + audioCodec() + bitRate() + customCoordinates() + 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) + + (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}" + } + + /** + * 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 + private constructor( + private val aboutCvTermCvId: JsonField, + private val aboutCvTermId: JsonField, + private val aboutCvTermName: JsonField, + private val aboutCvTermRefinedAbout: JsonField, + private val additionalModelInformation: JsonField, + private val applicationRecordVersion: JsonField, + private val artist: JsonField, + private val artworkCircaDateCreated: JsonField, + private val artworkContentDescription: JsonField, + private val artworkContributionDescription: JsonField, + private val artworkCopyrightNotice: JsonField, + private val artworkCopyrightOwnerId: JsonField, + private val artworkCopyrightOwnerName: JsonField, + private val artworkCreator: JsonField>, + private val artworkCreatorId: JsonField>, + private val artworkDateCreated: JsonField, + private val artworkLicensorId: JsonField, + private val artworkLicensorName: JsonField, + private val artworkPhysicalDescription: JsonField, + private val artworkSource: JsonField, + private val artworkSourceInventoryNo: JsonField, + private val artworkSourceInvUrl: JsonField, + private val artworkStylePeriod: JsonField>, + private val artworkTitle: JsonField, + private val authorsPosition: JsonField, + private val byline: JsonField, + private val bylineTitle: JsonField, + private val caption: JsonField, + private val captionAbstract: JsonField, + private val captionWriter: JsonField, + private val city: JsonField, + private val colorSpace: JsonField, + private val componentsConfiguration: JsonField, + private val copyright: JsonField, + private val copyrightNotice: JsonField, + private val copyrightOwnerId: JsonField>, + private val copyrightOwnerName: JsonField>, + private val country: JsonField, + private val countryCode: JsonField, + private val countryPrimaryLocationCode: JsonField, + private val countryPrimaryLocationName: JsonField, + private val creator: JsonField, + private val creatorAddress: JsonField, + private val creatorCity: JsonField, + private val creatorCountry: JsonField, + private val creatorPostalCode: JsonField, + private val creatorRegion: JsonField, + private val creatorWorkEmail: JsonField, + private val creatorWorkTelephone: JsonField, + private val creatorWorkUrl: JsonField, + private val credit: JsonField, + private val dateCreated: JsonField, + private val dateTimeCreated: JsonField, + private val dateTimeOriginal: JsonField, + private val description: JsonField, + private val digitalImageGuid: JsonField, + private val digitalSourceType: JsonField, + private val embeddedEncodedRightsExpr: JsonField, + private val embeddedEncodedRightsExprLangId: JsonField, + private val embeddedEncodedRightsExprType: JsonField, + private val event: JsonField, + private val exifVersion: JsonField, + private val flashpixVersion: JsonField, + private val genreCvId: JsonField, + private val genreCvTermId: JsonField, + private val genreCvTermName: JsonField, + private val genreCvTermRefinedAbout: JsonField, + private val headline: JsonField, + private val imageCreatorId: JsonField, + private val imageCreatorImageId: JsonField, + private val imageCreatorName: JsonField, + private val imageDescription: JsonField, + private val imageRegionBoundaryH: JsonField>, + private val imageRegionBoundaryRx: JsonField>, + private val imageRegionBoundaryShape: JsonField>, + private val imageRegionBoundaryUnit: JsonField>, + private val imageRegionBoundaryVerticesX: JsonField>, + private val imageRegionBoundaryVerticesY: JsonField>, + private val imageRegionBoundaryW: JsonField>, + private val imageRegionBoundaryX: JsonField>, + private val imageRegionBoundaryY: JsonField>, + private val imageRegionCtypeIdentifier: JsonField>, + private val imageRegionCtypeName: JsonField>, + private val imageRegionId: JsonField>, + private val imageRegionName: JsonField>, + private val imageRegionOrganisationInImageName: JsonField>, + private val imageRegionPersonInImage: JsonField>, + private val imageRegionRoleIdentifier: JsonField>, + private val imageRegionRoleName: JsonField>, + private val imageSupplierId: JsonField, + private val imageSupplierImageId: JsonField, + private val imageSupplierName: JsonField, + private val instructions: JsonField, + private val intellectualGenre: JsonField, + private val keywords: JsonField>, + private val licensorCity: JsonField>, + private val licensorCountry: JsonField>, + private val licensorEmail: JsonField>, + private val licensorExtendedAddress: JsonField>, + private val licensorId: JsonField>, + private val licensorName: JsonField>, + private val licensorPostalCode: JsonField>, + private val licensorRegion: JsonField>, + private val licensorStreetAddress: JsonField>, + private val licensorTelephone1: JsonField>, + private val licensorTelephone2: JsonField>, + private val licensorUrl: JsonField>, + private val linkedEncodedRightsExpr: JsonField, + private val linkedEncodedRightsExprLangId: JsonField, + private val linkedEncodedRightsExprType: JsonField, + private val location: JsonField, + private val locationCreatedCity: JsonField, + private val locationCreatedCountryCode: JsonField, + private val locationCreatedCountryName: JsonField, + private val locationCreatedGpsAltitude: JsonField, + private val locationCreatedGpsLatitude: JsonField, + private val locationCreatedGpsLongitude: JsonField, + private val locationCreatedLocationId: JsonField, + private val locationCreatedLocationName: JsonField, + private val locationCreatedProvinceState: JsonField, + private val locationCreatedSublocation: JsonField, + private val locationCreatedWorldRegion: JsonField, + private val locationShownCity: JsonField>, + private val locationShownCountryCode: JsonField>, + private val locationShownCountryName: JsonField>, + private val locationShownGpsAltitude: JsonField>, + private val locationShownGpsLatitude: JsonField>, + private val locationShownGpsLongitude: JsonField>, + private val locationShownLocationId: JsonField>, + private val locationShownLocationName: JsonField>, + private val locationShownProvinceState: JsonField>, + private val locationShownSublocation: JsonField>, + private val locationShownWorldRegion: JsonField>, + private val maxAvailHeight: JsonField, + private val maxAvailWidth: JsonField, + private val modelAge: JsonField>, + private val modelReleaseId: JsonField>, + private val objectAttributeReference: JsonField, + private val objectName: JsonField, + private val offsetTimeOriginal: JsonField, + private val organisationInImageCode: JsonField>, + private val organisationInImageName: JsonField>, + private val orientation: JsonField, + private val originalTransmissionReference: JsonField, + private val personInImage: JsonField>, + private val personInImageCvTermCvId: JsonField>, + private val personInImageCvTermId: JsonField>, + private val personInImageCvTermName: JsonField>, + private val personInImageCvTermRefinedAbout: JsonField>, + private val personInImageDescription: JsonField>, + private val personInImageId: JsonField>, + private val personInImageName: JsonField>, + private val productInImageDescription: JsonField>, + private val productInImageGtin: JsonField>, + private val productInImageName: JsonField>, + private val propertyReleaseId: JsonField>, + private val provinceState: JsonField, + private val rating: JsonField, + private val registryEntryRole: JsonField>, + private val registryItemId: JsonField>, + private val registryOrganisationId: JsonField>, + private val resolutionUnit: JsonField, + private val rights: JsonField, + private val scene: JsonField>, + private val source: JsonField, + private val specialInstructions: JsonField, + private val state: JsonField, + private val subject: JsonField>, + private val subjectCode: JsonField>, + private val subjectReference: JsonField>, + private val sublocation: JsonField, + private val timeCreated: JsonField, + private val title: JsonField, + private val transmissionReference: JsonField, + private val usageTerms: JsonField, + private val webStatement: JsonField, + private val writer: JsonField, + private val writerEditor: JsonField, + private val xResolution: JsonField, + private val yResolution: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("AboutCvTermCvId") + @ExcludeMissing + aboutCvTermCvId: JsonField = JsonMissing.of(), + @JsonProperty("AboutCvTermId") + @ExcludeMissing + aboutCvTermId: JsonField = JsonMissing.of(), + @JsonProperty("AboutCvTermName") + @ExcludeMissing + aboutCvTermName: JsonField = JsonMissing.of(), + @JsonProperty("AboutCvTermRefinedAbout") + @ExcludeMissing + aboutCvTermRefinedAbout: JsonField = JsonMissing.of(), + @JsonProperty("AdditionalModelInformation") + @ExcludeMissing + additionalModelInformation: JsonField = JsonMissing.of(), + @JsonProperty("ApplicationRecordVersion") + @ExcludeMissing + applicationRecordVersion: JsonField = JsonMissing.of(), + @JsonProperty("Artist") @ExcludeMissing artist: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCircaDateCreated") + @ExcludeMissing + artworkCircaDateCreated: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkContentDescription") + @ExcludeMissing + artworkContentDescription: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkContributionDescription") + @ExcludeMissing + artworkContributionDescription: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCopyrightNotice") + @ExcludeMissing + artworkCopyrightNotice: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCopyrightOwnerID") + @ExcludeMissing + artworkCopyrightOwnerId: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCopyrightOwnerName") + @ExcludeMissing + artworkCopyrightOwnerName: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCreator") + @ExcludeMissing + artworkCreator: JsonField> = JsonMissing.of(), + @JsonProperty("ArtworkCreatorID") + @ExcludeMissing + artworkCreatorId: JsonField> = JsonMissing.of(), + @JsonProperty("ArtworkDateCreated") + @ExcludeMissing + artworkDateCreated: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkLicensorID") + @ExcludeMissing + artworkLicensorId: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkLicensorName") + @ExcludeMissing + artworkLicensorName: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkPhysicalDescription") + @ExcludeMissing + artworkPhysicalDescription: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkSource") + @ExcludeMissing + artworkSource: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkSourceInventoryNo") + @ExcludeMissing + artworkSourceInventoryNo: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkSourceInvURL") + @ExcludeMissing + artworkSourceInvUrl: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkStylePeriod") + @ExcludeMissing + artworkStylePeriod: JsonField> = JsonMissing.of(), + @JsonProperty("ArtworkTitle") + @ExcludeMissing + artworkTitle: JsonField = JsonMissing.of(), + @JsonProperty("AuthorsPosition") + @ExcludeMissing + authorsPosition: JsonField = JsonMissing.of(), + @JsonProperty("Byline") @ExcludeMissing byline: JsonField = JsonMissing.of(), + @JsonProperty("BylineTitle") + @ExcludeMissing + bylineTitle: JsonField = JsonMissing.of(), + @JsonProperty("Caption") @ExcludeMissing caption: JsonField = JsonMissing.of(), + @JsonProperty("CaptionAbstract") + @ExcludeMissing + captionAbstract: JsonField = JsonMissing.of(), + @JsonProperty("CaptionWriter") + @ExcludeMissing + captionWriter: JsonField = JsonMissing.of(), + @JsonProperty("City") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("ColorSpace") + @ExcludeMissing + colorSpace: JsonField = JsonMissing.of(), + @JsonProperty("ComponentsConfiguration") + @ExcludeMissing + componentsConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("Copyright") + @ExcludeMissing + copyright: JsonField = JsonMissing.of(), + @JsonProperty("CopyrightNotice") + @ExcludeMissing + copyrightNotice: JsonField = JsonMissing.of(), + @JsonProperty("CopyrightOwnerID") + @ExcludeMissing + copyrightOwnerId: JsonField> = JsonMissing.of(), + @JsonProperty("CopyrightOwnerName") + @ExcludeMissing + copyrightOwnerName: JsonField> = JsonMissing.of(), + @JsonProperty("Country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("CountryCode") + @ExcludeMissing + countryCode: JsonField = JsonMissing.of(), + @JsonProperty("CountryPrimaryLocationCode") + @ExcludeMissing + countryPrimaryLocationCode: JsonField = JsonMissing.of(), + @JsonProperty("CountryPrimaryLocationName") + @ExcludeMissing + countryPrimaryLocationName: JsonField = JsonMissing.of(), + @JsonProperty("Creator") @ExcludeMissing creator: JsonField = JsonMissing.of(), + @JsonProperty("CreatorAddress") + @ExcludeMissing + creatorAddress: JsonField = JsonMissing.of(), + @JsonProperty("CreatorCity") + @ExcludeMissing + creatorCity: JsonField = JsonMissing.of(), + @JsonProperty("CreatorCountry") + @ExcludeMissing + creatorCountry: JsonField = JsonMissing.of(), + @JsonProperty("CreatorPostalCode") + @ExcludeMissing + creatorPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("CreatorRegion") + @ExcludeMissing + creatorRegion: JsonField = JsonMissing.of(), + @JsonProperty("CreatorWorkEmail") + @ExcludeMissing + creatorWorkEmail: JsonField = JsonMissing.of(), + @JsonProperty("CreatorWorkTelephone") + @ExcludeMissing + creatorWorkTelephone: JsonField = JsonMissing.of(), + @JsonProperty("CreatorWorkURL") + @ExcludeMissing + creatorWorkUrl: JsonField = JsonMissing.of(), + @JsonProperty("Credit") @ExcludeMissing credit: JsonField = JsonMissing.of(), + @JsonProperty("DateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("DateTimeCreated") + @ExcludeMissing + dateTimeCreated: JsonField = JsonMissing.of(), + @JsonProperty("DateTimeOriginal") + @ExcludeMissing + dateTimeOriginal: JsonField = JsonMissing.of(), + @JsonProperty("Description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("DigitalImageGUID") + @ExcludeMissing + digitalImageGuid: JsonField = JsonMissing.of(), + @JsonProperty("DigitalSourceType") + @ExcludeMissing + digitalSourceType: JsonField = JsonMissing.of(), + @JsonProperty("EmbeddedEncodedRightsExpr") + @ExcludeMissing + embeddedEncodedRightsExpr: JsonField = JsonMissing.of(), + @JsonProperty("EmbeddedEncodedRightsExprLangID") + @ExcludeMissing + embeddedEncodedRightsExprLangId: JsonField = JsonMissing.of(), + @JsonProperty("EmbeddedEncodedRightsExprType") + @ExcludeMissing + embeddedEncodedRightsExprType: JsonField = JsonMissing.of(), + @JsonProperty("Event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("ExifVersion") + @ExcludeMissing + exifVersion: JsonField = JsonMissing.of(), + @JsonProperty("FlashpixVersion") + @ExcludeMissing + flashpixVersion: JsonField = JsonMissing.of(), + @JsonProperty("GenreCvId") + @ExcludeMissing + genreCvId: JsonField = JsonMissing.of(), + @JsonProperty("GenreCvTermId") + @ExcludeMissing + genreCvTermId: JsonField = JsonMissing.of(), + @JsonProperty("GenreCvTermName") + @ExcludeMissing + genreCvTermName: JsonField = JsonMissing.of(), + @JsonProperty("GenreCvTermRefinedAbout") + @ExcludeMissing + genreCvTermRefinedAbout: JsonField = JsonMissing.of(), + @JsonProperty("Headline") + @ExcludeMissing + headline: JsonField = JsonMissing.of(), + @JsonProperty("ImageCreatorID") + @ExcludeMissing + imageCreatorId: JsonField = JsonMissing.of(), + @JsonProperty("ImageCreatorImageID") + @ExcludeMissing + imageCreatorImageId: JsonField = JsonMissing.of(), + @JsonProperty("ImageCreatorName") + @ExcludeMissing + imageCreatorName: JsonField = JsonMissing.of(), + @JsonProperty("ImageDescription") + @ExcludeMissing + imageDescription: JsonField = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryH") + @ExcludeMissing + imageRegionBoundaryH: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryRx") + @ExcludeMissing + imageRegionBoundaryRx: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryShape") + @ExcludeMissing + imageRegionBoundaryShape: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryUnit") + @ExcludeMissing + imageRegionBoundaryUnit: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryVerticesX") + @ExcludeMissing + imageRegionBoundaryVerticesX: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryVerticesY") + @ExcludeMissing + imageRegionBoundaryVerticesY: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryW") + @ExcludeMissing + imageRegionBoundaryW: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryX") + @ExcludeMissing + imageRegionBoundaryX: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryY") + @ExcludeMissing + imageRegionBoundaryY: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionCtypeIdentifier") + @ExcludeMissing + imageRegionCtypeIdentifier: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionCtypeName") + @ExcludeMissing + imageRegionCtypeName: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionID") + @ExcludeMissing + imageRegionId: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionName") + @ExcludeMissing + imageRegionName: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionOrganisationInImageName") + @ExcludeMissing + imageRegionOrganisationInImageName: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionPersonInImage") + @ExcludeMissing + imageRegionPersonInImage: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionRoleIdentifier") + @ExcludeMissing + imageRegionRoleIdentifier: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionRoleName") + @ExcludeMissing + imageRegionRoleName: JsonField> = JsonMissing.of(), + @JsonProperty("ImageSupplierID") + @ExcludeMissing + imageSupplierId: JsonField = JsonMissing.of(), + @JsonProperty("ImageSupplierImageID") + @ExcludeMissing + imageSupplierImageId: JsonField = JsonMissing.of(), + @JsonProperty("ImageSupplierName") + @ExcludeMissing + imageSupplierName: JsonField = JsonMissing.of(), + @JsonProperty("Instructions") + @ExcludeMissing + instructions: JsonField = JsonMissing.of(), + @JsonProperty("IntellectualGenre") + @ExcludeMissing + intellectualGenre: JsonField = JsonMissing.of(), + @JsonProperty("Keywords") + @ExcludeMissing + keywords: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorCity") + @ExcludeMissing + licensorCity: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorCountry") + @ExcludeMissing + licensorCountry: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorEmail") + @ExcludeMissing + licensorEmail: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorExtendedAddress") + @ExcludeMissing + licensorExtendedAddress: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorID") + @ExcludeMissing + licensorId: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorName") + @ExcludeMissing + licensorName: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorPostalCode") + @ExcludeMissing + licensorPostalCode: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorRegion") + @ExcludeMissing + licensorRegion: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorStreetAddress") + @ExcludeMissing + licensorStreetAddress: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorTelephone1") + @ExcludeMissing + licensorTelephone1: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorTelephone2") + @ExcludeMissing + licensorTelephone2: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorURL") + @ExcludeMissing + licensorUrl: JsonField> = JsonMissing.of(), + @JsonProperty("LinkedEncodedRightsExpr") + @ExcludeMissing + linkedEncodedRightsExpr: JsonField = JsonMissing.of(), + @JsonProperty("LinkedEncodedRightsExprLangID") + @ExcludeMissing + linkedEncodedRightsExprLangId: JsonField = JsonMissing.of(), + @JsonProperty("LinkedEncodedRightsExprType") + @ExcludeMissing + linkedEncodedRightsExprType: JsonField = JsonMissing.of(), + @JsonProperty("Location") + @ExcludeMissing + location: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedCity") + @ExcludeMissing + locationCreatedCity: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedCountryCode") + @ExcludeMissing + locationCreatedCountryCode: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedCountryName") + @ExcludeMissing + locationCreatedCountryName: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedGPSAltitude") + @ExcludeMissing + locationCreatedGpsAltitude: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedGPSLatitude") + @ExcludeMissing + locationCreatedGpsLatitude: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedGPSLongitude") + @ExcludeMissing + locationCreatedGpsLongitude: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedLocationId") + @ExcludeMissing + locationCreatedLocationId: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedLocationName") + @ExcludeMissing + locationCreatedLocationName: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedProvinceState") + @ExcludeMissing + locationCreatedProvinceState: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedSublocation") + @ExcludeMissing + locationCreatedSublocation: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedWorldRegion") + @ExcludeMissing + locationCreatedWorldRegion: JsonField = JsonMissing.of(), + @JsonProperty("LocationShownCity") + @ExcludeMissing + locationShownCity: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownCountryCode") + @ExcludeMissing + locationShownCountryCode: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownCountryName") + @ExcludeMissing + locationShownCountryName: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownGPSAltitude") + @ExcludeMissing + locationShownGpsAltitude: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownGPSLatitude") + @ExcludeMissing + locationShownGpsLatitude: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownGPSLongitude") + @ExcludeMissing + locationShownGpsLongitude: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownLocationId") + @ExcludeMissing + locationShownLocationId: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownLocationName") + @ExcludeMissing + locationShownLocationName: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownProvinceState") + @ExcludeMissing + locationShownProvinceState: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownSublocation") + @ExcludeMissing + locationShownSublocation: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownWorldRegion") + @ExcludeMissing + locationShownWorldRegion: JsonField> = JsonMissing.of(), + @JsonProperty("MaxAvailHeight") + @ExcludeMissing + maxAvailHeight: JsonField = JsonMissing.of(), + @JsonProperty("MaxAvailWidth") + @ExcludeMissing + maxAvailWidth: JsonField = JsonMissing.of(), + @JsonProperty("ModelAge") + @ExcludeMissing + modelAge: JsonField> = JsonMissing.of(), + @JsonProperty("ModelReleaseID") + @ExcludeMissing + modelReleaseId: JsonField> = JsonMissing.of(), + @JsonProperty("ObjectAttributeReference") + @ExcludeMissing + objectAttributeReference: JsonField = JsonMissing.of(), + @JsonProperty("ObjectName") + @ExcludeMissing + objectName: JsonField = JsonMissing.of(), + @JsonProperty("OffsetTimeOriginal") + @ExcludeMissing + offsetTimeOriginal: JsonField = JsonMissing.of(), + @JsonProperty("OrganisationInImageCode") + @ExcludeMissing + organisationInImageCode: JsonField> = JsonMissing.of(), + @JsonProperty("OrganisationInImageName") + @ExcludeMissing + organisationInImageName: JsonField> = JsonMissing.of(), + @JsonProperty("Orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("OriginalTransmissionReference") + @ExcludeMissing + originalTransmissionReference: JsonField = JsonMissing.of(), + @JsonProperty("PersonInImage") + @ExcludeMissing + personInImage: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageCvTermCvId") + @ExcludeMissing + personInImageCvTermCvId: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageCvTermId") + @ExcludeMissing + personInImageCvTermId: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageCvTermName") + @ExcludeMissing + personInImageCvTermName: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageCvTermRefinedAbout") + @ExcludeMissing + personInImageCvTermRefinedAbout: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageDescription") + @ExcludeMissing + personInImageDescription: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageId") + @ExcludeMissing + personInImageId: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageName") + @ExcludeMissing + personInImageName: JsonField> = JsonMissing.of(), + @JsonProperty("ProductInImageDescription") + @ExcludeMissing + productInImageDescription: JsonField> = JsonMissing.of(), + @JsonProperty("ProductInImageGTIN") + @ExcludeMissing + productInImageGtin: JsonField> = JsonMissing.of(), + @JsonProperty("ProductInImageName") + @ExcludeMissing + productInImageName: JsonField> = JsonMissing.of(), + @JsonProperty("PropertyReleaseID") + @ExcludeMissing + propertyReleaseId: JsonField> = JsonMissing.of(), + @JsonProperty("ProvinceState") + @ExcludeMissing + provinceState: JsonField = JsonMissing.of(), + @JsonProperty("Rating") @ExcludeMissing rating: JsonField = JsonMissing.of(), + @JsonProperty("RegistryEntryRole") + @ExcludeMissing + registryEntryRole: JsonField> = JsonMissing.of(), + @JsonProperty("RegistryItemID") + @ExcludeMissing + registryItemId: JsonField> = JsonMissing.of(), + @JsonProperty("RegistryOrganisationID") + @ExcludeMissing + registryOrganisationId: JsonField> = JsonMissing.of(), + @JsonProperty("ResolutionUnit") + @ExcludeMissing + resolutionUnit: JsonField = JsonMissing.of(), + @JsonProperty("Rights") @ExcludeMissing rights: JsonField = JsonMissing.of(), + @JsonProperty("Scene") + @ExcludeMissing + scene: JsonField> = JsonMissing.of(), + @JsonProperty("Source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("SpecialInstructions") + @ExcludeMissing + specialInstructions: JsonField = JsonMissing.of(), + @JsonProperty("State") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("Subject") + @ExcludeMissing + subject: JsonField> = JsonMissing.of(), + @JsonProperty("SubjectCode") + @ExcludeMissing + subjectCode: JsonField> = JsonMissing.of(), + @JsonProperty("SubjectReference") + @ExcludeMissing + subjectReference: JsonField> = JsonMissing.of(), + @JsonProperty("Sublocation") + @ExcludeMissing + sublocation: JsonField = JsonMissing.of(), + @JsonProperty("TimeCreated") + @ExcludeMissing + timeCreated: JsonField = JsonMissing.of(), + @JsonProperty("Title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("TransmissionReference") + @ExcludeMissing + transmissionReference: JsonField = JsonMissing.of(), + @JsonProperty("UsageTerms") + @ExcludeMissing + usageTerms: JsonField = JsonMissing.of(), + @JsonProperty("WebStatement") + @ExcludeMissing + webStatement: JsonField = JsonMissing.of(), + @JsonProperty("Writer") @ExcludeMissing writer: JsonField = JsonMissing.of(), + @JsonProperty("WriterEditor") + @ExcludeMissing + writerEditor: JsonField = JsonMissing.of(), + @JsonProperty("XResolution") + @ExcludeMissing + xResolution: JsonField = JsonMissing.of(), + @JsonProperty("YResolution") + @ExcludeMissing + yResolution: JsonField = JsonMissing.of(), + ) : this( + aboutCvTermCvId, + aboutCvTermId, + aboutCvTermName, + aboutCvTermRefinedAbout, + additionalModelInformation, + applicationRecordVersion, + artist, + artworkCircaDateCreated, + artworkContentDescription, + artworkContributionDescription, + artworkCopyrightNotice, + artworkCopyrightOwnerId, + artworkCopyrightOwnerName, + artworkCreator, + artworkCreatorId, + artworkDateCreated, + artworkLicensorId, + artworkLicensorName, + artworkPhysicalDescription, + artworkSource, + artworkSourceInventoryNo, + artworkSourceInvUrl, + artworkStylePeriod, + artworkTitle, + authorsPosition, + byline, + bylineTitle, + caption, + captionAbstract, + captionWriter, + city, + colorSpace, + componentsConfiguration, + copyright, + copyrightNotice, + copyrightOwnerId, + copyrightOwnerName, + country, + countryCode, + countryPrimaryLocationCode, + countryPrimaryLocationName, + creator, + creatorAddress, + creatorCity, + creatorCountry, + creatorPostalCode, + creatorRegion, + creatorWorkEmail, + creatorWorkTelephone, + creatorWorkUrl, + credit, + dateCreated, + dateTimeCreated, + dateTimeOriginal, + description, + digitalImageGuid, + digitalSourceType, + embeddedEncodedRightsExpr, + embeddedEncodedRightsExprLangId, + embeddedEncodedRightsExprType, + event, + exifVersion, + flashpixVersion, + genreCvId, + genreCvTermId, + genreCvTermName, + genreCvTermRefinedAbout, + headline, + imageCreatorId, + imageCreatorImageId, + imageCreatorName, + imageDescription, + imageRegionBoundaryH, + imageRegionBoundaryRx, + imageRegionBoundaryShape, + imageRegionBoundaryUnit, + imageRegionBoundaryVerticesX, + imageRegionBoundaryVerticesY, + imageRegionBoundaryW, + imageRegionBoundaryX, + imageRegionBoundaryY, + imageRegionCtypeIdentifier, + imageRegionCtypeName, + imageRegionId, + imageRegionName, + imageRegionOrganisationInImageName, + imageRegionPersonInImage, + imageRegionRoleIdentifier, + imageRegionRoleName, + imageSupplierId, + imageSupplierImageId, + imageSupplierName, + instructions, + intellectualGenre, + keywords, + licensorCity, + licensorCountry, + licensorEmail, + licensorExtendedAddress, + licensorId, + licensorName, + licensorPostalCode, + licensorRegion, + licensorStreetAddress, + licensorTelephone1, + licensorTelephone2, + licensorUrl, + linkedEncodedRightsExpr, + linkedEncodedRightsExprLangId, + linkedEncodedRightsExprType, + location, + locationCreatedCity, + locationCreatedCountryCode, + locationCreatedCountryName, + locationCreatedGpsAltitude, + locationCreatedGpsLatitude, + locationCreatedGpsLongitude, + locationCreatedLocationId, + locationCreatedLocationName, + locationCreatedProvinceState, + locationCreatedSublocation, + locationCreatedWorldRegion, + locationShownCity, + locationShownCountryCode, + locationShownCountryName, + locationShownGpsAltitude, + locationShownGpsLatitude, + locationShownGpsLongitude, + locationShownLocationId, + locationShownLocationName, + locationShownProvinceState, + locationShownSublocation, + locationShownWorldRegion, + maxAvailHeight, + maxAvailWidth, + modelAge, + modelReleaseId, + objectAttributeReference, + objectName, + offsetTimeOriginal, + organisationInImageCode, + organisationInImageName, + orientation, + originalTransmissionReference, + personInImage, + personInImageCvTermCvId, + personInImageCvTermId, + personInImageCvTermName, + personInImageCvTermRefinedAbout, + personInImageDescription, + personInImageId, + personInImageName, + productInImageDescription, + productInImageGtin, + productInImageName, + propertyReleaseId, + provinceState, + rating, + registryEntryRole, + registryItemId, + registryOrganisationId, + resolutionUnit, + rights, + scene, + source, + specialInstructions, + state, + subject, + subjectCode, + subjectReference, + sublocation, + timeCreated, + title, + transmissionReference, + usageTerms, + webStatement, + writer, + writerEditor, + xResolution, + yResolution, + mutableMapOf(), + ) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aboutCvTermCvId(): Optional = aboutCvTermCvId.getOptional("AboutCvTermCvId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aboutCvTermId(): Optional = aboutCvTermId.getOptional("AboutCvTermId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aboutCvTermName(): Optional = aboutCvTermName.getOptional("AboutCvTermName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aboutCvTermRefinedAbout(): Optional = + aboutCvTermRefinedAbout.getOptional("AboutCvTermRefinedAbout") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun additionalModelInformation(): Optional = + additionalModelInformation.getOptional("AdditionalModelInformation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicationRecordVersion(): Optional = + applicationRecordVersion.getOptional("ApplicationRecordVersion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artist(): Optional = artist.getOptional("Artist") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCircaDateCreated(): Optional = + artworkCircaDateCreated.getOptional("ArtworkCircaDateCreated") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkContentDescription(): Optional = + artworkContentDescription.getOptional("ArtworkContentDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkContributionDescription(): Optional = + artworkContributionDescription.getOptional("ArtworkContributionDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCopyrightNotice(): Optional = + artworkCopyrightNotice.getOptional("ArtworkCopyrightNotice") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCopyrightOwnerId(): Optional = + artworkCopyrightOwnerId.getOptional("ArtworkCopyrightOwnerID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCopyrightOwnerName(): Optional = + artworkCopyrightOwnerName.getOptional("ArtworkCopyrightOwnerName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCreator(): Optional> = artworkCreator.getOptional("ArtworkCreator") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCreatorId(): Optional> = + artworkCreatorId.getOptional("ArtworkCreatorID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkDateCreated(): Optional = + artworkDateCreated.getOptional("ArtworkDateCreated") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkLicensorId(): Optional = + artworkLicensorId.getOptional("ArtworkLicensorID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkLicensorName(): Optional = + artworkLicensorName.getOptional("ArtworkLicensorName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkPhysicalDescription(): Optional = + artworkPhysicalDescription.getOptional("ArtworkPhysicalDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkSource(): Optional = artworkSource.getOptional("ArtworkSource") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkSourceInventoryNo(): Optional = + artworkSourceInventoryNo.getOptional("ArtworkSourceInventoryNo") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkSourceInvUrl(): Optional = + artworkSourceInvUrl.getOptional("ArtworkSourceInvURL") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkStylePeriod(): Optional> = + artworkStylePeriod.getOptional("ArtworkStylePeriod") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkTitle(): Optional = artworkTitle.getOptional("ArtworkTitle") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun authorsPosition(): Optional = authorsPosition.getOptional("AuthorsPosition") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun byline(): Optional = byline.getOptional("Byline") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun bylineTitle(): Optional = bylineTitle.getOptional("BylineTitle") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun caption(): Optional = caption.getOptional("Caption") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun captionAbstract(): Optional = captionAbstract.getOptional("CaptionAbstract") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun captionWriter(): Optional = captionWriter.getOptional("CaptionWriter") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun city(): Optional = city.getOptional("City") + + /** + * @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 componentsConfiguration(): Optional = + componentsConfiguration.getOptional("ComponentsConfiguration") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun copyright(): Optional = copyright.getOptional("Copyright") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun copyrightNotice(): Optional = copyrightNotice.getOptional("CopyrightNotice") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun copyrightOwnerId(): Optional> = + copyrightOwnerId.getOptional("CopyrightOwnerID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun copyrightOwnerName(): Optional> = + copyrightOwnerName.getOptional("CopyrightOwnerName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun country(): Optional = country.getOptional("Country") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun countryCode(): Optional = countryCode.getOptional("CountryCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun countryPrimaryLocationCode(): Optional = + countryPrimaryLocationCode.getOptional("CountryPrimaryLocationCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun countryPrimaryLocationName(): Optional = + countryPrimaryLocationName.getOptional("CountryPrimaryLocationName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creator(): Optional = creator.getOptional("Creator") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorAddress(): Optional = creatorAddress.getOptional("CreatorAddress") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorCity(): Optional = creatorCity.getOptional("CreatorCity") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorCountry(): Optional = creatorCountry.getOptional("CreatorCountry") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorPostalCode(): Optional = + creatorPostalCode.getOptional("CreatorPostalCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorRegion(): Optional = creatorRegion.getOptional("CreatorRegion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorWorkEmail(): Optional = creatorWorkEmail.getOptional("CreatorWorkEmail") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorWorkTelephone(): Optional = + creatorWorkTelephone.getOptional("CreatorWorkTelephone") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorWorkUrl(): Optional = creatorWorkUrl.getOptional("CreatorWorkURL") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credit(): Optional = credit.getOptional("Credit") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateCreated(): Optional = dateCreated.getOptional("DateCreated") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateTimeCreated(): Optional = + dateTimeCreated.getOptional("DateTimeCreated") + + /** + * @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 description(): Optional = description.getOptional("Description") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun digitalImageGuid(): Optional = digitalImageGuid.getOptional("DigitalImageGUID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun digitalSourceType(): Optional = + digitalSourceType.getOptional("DigitalSourceType") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun embeddedEncodedRightsExpr(): Optional = + embeddedEncodedRightsExpr.getOptional("EmbeddedEncodedRightsExpr") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun embeddedEncodedRightsExprLangId(): Optional = + embeddedEncodedRightsExprLangId.getOptional("EmbeddedEncodedRightsExprLangID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun embeddedEncodedRightsExprType(): Optional = + embeddedEncodedRightsExprType.getOptional("EmbeddedEncodedRightsExprType") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun event(): Optional = event.getOptional("Event") + + /** + * @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 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 genreCvId(): Optional = genreCvId.getOptional("GenreCvId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun genreCvTermId(): Optional = genreCvTermId.getOptional("GenreCvTermId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun genreCvTermName(): Optional = genreCvTermName.getOptional("GenreCvTermName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun genreCvTermRefinedAbout(): Optional = + genreCvTermRefinedAbout.getOptional("GenreCvTermRefinedAbout") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun headline(): Optional = headline.getOptional("Headline") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageCreatorId(): Optional = imageCreatorId.getOptional("ImageCreatorID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageCreatorImageId(): Optional = + imageCreatorImageId.getOptional("ImageCreatorImageID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageCreatorName(): Optional = imageCreatorName.getOptional("ImageCreatorName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageDescription(): Optional = imageDescription.getOptional("ImageDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryH(): Optional> = + imageRegionBoundaryH.getOptional("ImageRegionBoundaryH") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryRx(): Optional> = + imageRegionBoundaryRx.getOptional("ImageRegionBoundaryRx") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryShape(): Optional> = + imageRegionBoundaryShape.getOptional("ImageRegionBoundaryShape") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryUnit(): Optional> = + imageRegionBoundaryUnit.getOptional("ImageRegionBoundaryUnit") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryVerticesX(): Optional> = + imageRegionBoundaryVerticesX.getOptional("ImageRegionBoundaryVerticesX") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryVerticesY(): Optional> = + imageRegionBoundaryVerticesY.getOptional("ImageRegionBoundaryVerticesY") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryW(): Optional> = + imageRegionBoundaryW.getOptional("ImageRegionBoundaryW") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryX(): Optional> = + imageRegionBoundaryX.getOptional("ImageRegionBoundaryX") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryY(): Optional> = + imageRegionBoundaryY.getOptional("ImageRegionBoundaryY") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionCtypeIdentifier(): Optional> = + imageRegionCtypeIdentifier.getOptional("ImageRegionCtypeIdentifier") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionCtypeName(): Optional> = + imageRegionCtypeName.getOptional("ImageRegionCtypeName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionId(): Optional> = imageRegionId.getOptional("ImageRegionID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionName(): Optional> = + imageRegionName.getOptional("ImageRegionName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionOrganisationInImageName(): Optional> = + imageRegionOrganisationInImageName.getOptional("ImageRegionOrganisationInImageName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionPersonInImage(): Optional> = + imageRegionPersonInImage.getOptional("ImageRegionPersonInImage") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionRoleIdentifier(): Optional> = + imageRegionRoleIdentifier.getOptional("ImageRegionRoleIdentifier") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionRoleName(): Optional> = + imageRegionRoleName.getOptional("ImageRegionRoleName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageSupplierId(): Optional = imageSupplierId.getOptional("ImageSupplierID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageSupplierImageId(): Optional = + imageSupplierImageId.getOptional("ImageSupplierImageID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageSupplierName(): Optional = + imageSupplierName.getOptional("ImageSupplierName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun instructions(): Optional = instructions.getOptional("Instructions") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun intellectualGenre(): Optional = + intellectualGenre.getOptional("IntellectualGenre") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun keywords(): Optional> = keywords.getOptional("Keywords") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorCity(): Optional> = licensorCity.getOptional("LicensorCity") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorCountry(): Optional> = + licensorCountry.getOptional("LicensorCountry") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorEmail(): Optional> = licensorEmail.getOptional("LicensorEmail") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorExtendedAddress(): Optional> = + licensorExtendedAddress.getOptional("LicensorExtendedAddress") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorId(): Optional> = licensorId.getOptional("LicensorID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorName(): Optional> = licensorName.getOptional("LicensorName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorPostalCode(): Optional> = + licensorPostalCode.getOptional("LicensorPostalCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorRegion(): Optional> = licensorRegion.getOptional("LicensorRegion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorStreetAddress(): Optional> = + licensorStreetAddress.getOptional("LicensorStreetAddress") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorTelephone1(): Optional> = + licensorTelephone1.getOptional("LicensorTelephone1") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorTelephone2(): Optional> = + licensorTelephone2.getOptional("LicensorTelephone2") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorUrl(): Optional> = licensorUrl.getOptional("LicensorURL") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedEncodedRightsExpr(): Optional = + linkedEncodedRightsExpr.getOptional("LinkedEncodedRightsExpr") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedEncodedRightsExprLangId(): Optional = + linkedEncodedRightsExprLangId.getOptional("LinkedEncodedRightsExprLangID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedEncodedRightsExprType(): Optional = + linkedEncodedRightsExprType.getOptional("LinkedEncodedRightsExprType") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun location(): Optional = location.getOptional("Location") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedCity(): Optional = + locationCreatedCity.getOptional("LocationCreatedCity") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedCountryCode(): Optional = + locationCreatedCountryCode.getOptional("LocationCreatedCountryCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedCountryName(): Optional = + locationCreatedCountryName.getOptional("LocationCreatedCountryName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedGpsAltitude(): Optional = + locationCreatedGpsAltitude.getOptional("LocationCreatedGPSAltitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedGpsLatitude(): Optional = + locationCreatedGpsLatitude.getOptional("LocationCreatedGPSLatitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedGpsLongitude(): Optional = + locationCreatedGpsLongitude.getOptional("LocationCreatedGPSLongitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedLocationId(): Optional = + locationCreatedLocationId.getOptional("LocationCreatedLocationId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedLocationName(): Optional = + locationCreatedLocationName.getOptional("LocationCreatedLocationName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedProvinceState(): Optional = + locationCreatedProvinceState.getOptional("LocationCreatedProvinceState") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedSublocation(): Optional = + locationCreatedSublocation.getOptional("LocationCreatedSublocation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedWorldRegion(): Optional = + locationCreatedWorldRegion.getOptional("LocationCreatedWorldRegion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownCity(): Optional> = + locationShownCity.getOptional("LocationShownCity") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownCountryCode(): Optional> = + locationShownCountryCode.getOptional("LocationShownCountryCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownCountryName(): Optional> = + locationShownCountryName.getOptional("LocationShownCountryName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownGpsAltitude(): Optional> = + locationShownGpsAltitude.getOptional("LocationShownGPSAltitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownGpsLatitude(): Optional> = + locationShownGpsLatitude.getOptional("LocationShownGPSLatitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownGpsLongitude(): Optional> = + locationShownGpsLongitude.getOptional("LocationShownGPSLongitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownLocationId(): Optional> = + locationShownLocationId.getOptional("LocationShownLocationId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownLocationName(): Optional> = + locationShownLocationName.getOptional("LocationShownLocationName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownProvinceState(): Optional> = + locationShownProvinceState.getOptional("LocationShownProvinceState") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownSublocation(): Optional> = + locationShownSublocation.getOptional("LocationShownSublocation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownWorldRegion(): Optional> = + locationShownWorldRegion.getOptional("LocationShownWorldRegion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxAvailHeight(): Optional = maxAvailHeight.getOptional("MaxAvailHeight") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxAvailWidth(): Optional = maxAvailWidth.getOptional("MaxAvailWidth") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelAge(): Optional> = modelAge.getOptional("ModelAge") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelReleaseId(): Optional> = modelReleaseId.getOptional("ModelReleaseID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun objectAttributeReference(): Optional = + objectAttributeReference.getOptional("ObjectAttributeReference") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun objectName(): Optional = objectName.getOptional("ObjectName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun offsetTimeOriginal(): Optional = + offsetTimeOriginal.getOptional("OffsetTimeOriginal") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organisationInImageCode(): Optional> = + organisationInImageCode.getOptional("OrganisationInImageCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organisationInImageName(): Optional> = + organisationInImageName.getOptional("OrganisationInImageName") + + /** + * @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 originalTransmissionReference(): Optional = + originalTransmissionReference.getOptional("OriginalTransmissionReference") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImage(): Optional> = personInImage.getOptional("PersonInImage") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageCvTermCvId(): Optional> = + personInImageCvTermCvId.getOptional("PersonInImageCvTermCvId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageCvTermId(): Optional> = + personInImageCvTermId.getOptional("PersonInImageCvTermId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageCvTermName(): Optional> = + personInImageCvTermName.getOptional("PersonInImageCvTermName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageCvTermRefinedAbout(): Optional> = + personInImageCvTermRefinedAbout.getOptional("PersonInImageCvTermRefinedAbout") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageDescription(): Optional> = + personInImageDescription.getOptional("PersonInImageDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageId(): Optional> = + personInImageId.getOptional("PersonInImageId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageName(): Optional> = + personInImageName.getOptional("PersonInImageName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productInImageDescription(): Optional> = + productInImageDescription.getOptional("ProductInImageDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productInImageGtin(): Optional> = + productInImageGtin.getOptional("ProductInImageGTIN") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productInImageName(): Optional> = + productInImageName.getOptional("ProductInImageName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun propertyReleaseId(): Optional> = + propertyReleaseId.getOptional("PropertyReleaseID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun provinceState(): Optional = provinceState.getOptional("ProvinceState") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rating(): Optional = rating.getOptional("Rating") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun registryEntryRole(): Optional> = + registryEntryRole.getOptional("RegistryEntryRole") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun registryItemId(): Optional> = registryItemId.getOptional("RegistryItemID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun registryOrganisationId(): Optional> = + registryOrganisationId.getOptional("RegistryOrganisationID") + + /** + * @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 rights(): Optional = rights.getOptional("Rights") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun scene(): Optional> = scene.getOptional("Scene") + + /** + * @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") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun specialInstructions(): Optional = + specialInstructions.getOptional("SpecialInstructions") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("State") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subject(): Optional> = subject.getOptional("Subject") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subjectCode(): Optional> = subjectCode.getOptional("SubjectCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subjectReference(): Optional> = + subjectReference.getOptional("SubjectReference") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sublocation(): Optional = sublocation.getOptional("Sublocation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timeCreated(): Optional = timeCreated.getOptional("TimeCreated") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun title(): Optional = title.getOptional("Title") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transmissionReference(): Optional = + transmissionReference.getOptional("TransmissionReference") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun usageTerms(): Optional = usageTerms.getOptional("UsageTerms") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webStatement(): Optional = webStatement.getOptional("WebStatement") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writer(): Optional = writer.getOptional("Writer") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writerEditor(): Optional = writerEditor.getOptional("WriterEditor") + + /** + * @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 [aboutCvTermCvId]. + * + * Unlike [aboutCvTermCvId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("AboutCvTermCvId") + @ExcludeMissing + fun _aboutCvTermCvId(): JsonField = aboutCvTermCvId + + /** + * Returns the raw JSON value of [aboutCvTermId]. + * + * Unlike [aboutCvTermId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("AboutCvTermId") + @ExcludeMissing + fun _aboutCvTermId(): JsonField = aboutCvTermId + + /** + * Returns the raw JSON value of [aboutCvTermName]. + * + * Unlike [aboutCvTermName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("AboutCvTermName") + @ExcludeMissing + fun _aboutCvTermName(): JsonField = aboutCvTermName + + /** + * Returns the raw JSON value of [aboutCvTermRefinedAbout]. + * + * Unlike [aboutCvTermRefinedAbout], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("AboutCvTermRefinedAbout") + @ExcludeMissing + fun _aboutCvTermRefinedAbout(): JsonField = aboutCvTermRefinedAbout + + /** + * Returns the raw JSON value of [additionalModelInformation]. + * + * Unlike [additionalModelInformation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("AdditionalModelInformation") + @ExcludeMissing + fun _additionalModelInformation(): JsonField = additionalModelInformation + + /** + * Returns the raw JSON value of [applicationRecordVersion]. + * + * Unlike [applicationRecordVersion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ApplicationRecordVersion") + @ExcludeMissing + fun _applicationRecordVersion(): JsonField = applicationRecordVersion + + /** + * Returns the raw JSON value of [artist]. + * + * Unlike [artist], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Artist") @ExcludeMissing fun _artist(): JsonField = artist + + /** + * Returns the raw JSON value of [artworkCircaDateCreated]. + * + * Unlike [artworkCircaDateCreated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkCircaDateCreated") + @ExcludeMissing + fun _artworkCircaDateCreated(): JsonField = artworkCircaDateCreated + + /** + * Returns the raw JSON value of [artworkContentDescription]. + * + * Unlike [artworkContentDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkContentDescription") + @ExcludeMissing + fun _artworkContentDescription(): JsonField = artworkContentDescription + + /** + * Returns the raw JSON value of [artworkContributionDescription]. + * + * Unlike [artworkContributionDescription], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("ArtworkContributionDescription") + @ExcludeMissing + fun _artworkContributionDescription(): JsonField = artworkContributionDescription + + /** + * Returns the raw JSON value of [artworkCopyrightNotice]. + * + * Unlike [artworkCopyrightNotice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkCopyrightNotice") + @ExcludeMissing + fun _artworkCopyrightNotice(): JsonField = artworkCopyrightNotice + + /** + * Returns the raw JSON value of [artworkCopyrightOwnerId]. + * + * Unlike [artworkCopyrightOwnerId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkCopyrightOwnerID") + @ExcludeMissing + fun _artworkCopyrightOwnerId(): JsonField = artworkCopyrightOwnerId + + /** + * Returns the raw JSON value of [artworkCopyrightOwnerName]. + * + * Unlike [artworkCopyrightOwnerName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkCopyrightOwnerName") + @ExcludeMissing + fun _artworkCopyrightOwnerName(): JsonField = artworkCopyrightOwnerName + + /** + * Returns the raw JSON value of [artworkCreator]. + * + * Unlike [artworkCreator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkCreator") + @ExcludeMissing + fun _artworkCreator(): JsonField> = artworkCreator + + /** + * Returns the raw JSON value of [artworkCreatorId]. + * + * Unlike [artworkCreatorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkCreatorID") + @ExcludeMissing + fun _artworkCreatorId(): JsonField> = artworkCreatorId + + /** + * Returns the raw JSON value of [artworkDateCreated]. + * + * Unlike [artworkDateCreated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkDateCreated") + @ExcludeMissing + fun _artworkDateCreated(): JsonField = artworkDateCreated + + /** + * Returns the raw JSON value of [artworkLicensorId]. + * + * Unlike [artworkLicensorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkLicensorID") + @ExcludeMissing + fun _artworkLicensorId(): JsonField = artworkLicensorId + + /** + * Returns the raw JSON value of [artworkLicensorName]. + * + * Unlike [artworkLicensorName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkLicensorName") + @ExcludeMissing + fun _artworkLicensorName(): JsonField = artworkLicensorName + + /** + * Returns the raw JSON value of [artworkPhysicalDescription]. + * + * Unlike [artworkPhysicalDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkPhysicalDescription") + @ExcludeMissing + fun _artworkPhysicalDescription(): JsonField = artworkPhysicalDescription + + /** + * Returns the raw JSON value of [artworkSource]. + * + * Unlike [artworkSource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkSource") + @ExcludeMissing + fun _artworkSource(): JsonField = artworkSource + + /** + * Returns the raw JSON value of [artworkSourceInventoryNo]. + * + * Unlike [artworkSourceInventoryNo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkSourceInventoryNo") + @ExcludeMissing + fun _artworkSourceInventoryNo(): JsonField = artworkSourceInventoryNo + + /** + * Returns the raw JSON value of [artworkSourceInvUrl]. + * + * Unlike [artworkSourceInvUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkSourceInvURL") + @ExcludeMissing + fun _artworkSourceInvUrl(): JsonField = artworkSourceInvUrl + + /** + * Returns the raw JSON value of [artworkStylePeriod]. + * + * Unlike [artworkStylePeriod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkStylePeriod") + @ExcludeMissing + fun _artworkStylePeriod(): JsonField> = artworkStylePeriod + + /** + * Returns the raw JSON value of [artworkTitle]. + * + * Unlike [artworkTitle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkTitle") + @ExcludeMissing + fun _artworkTitle(): JsonField = artworkTitle + + /** + * Returns the raw JSON value of [authorsPosition]. + * + * Unlike [authorsPosition], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("AuthorsPosition") + @ExcludeMissing + fun _authorsPosition(): JsonField = authorsPosition + + /** + * Returns the raw JSON value of [byline]. + * + * Unlike [byline], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Byline") @ExcludeMissing fun _byline(): JsonField = byline + + /** + * Returns the raw JSON value of [bylineTitle]. + * + * Unlike [bylineTitle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("BylineTitle") + @ExcludeMissing + fun _bylineTitle(): JsonField = bylineTitle + + /** + * Returns the raw JSON value of [caption]. + * + * Unlike [caption], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Caption") @ExcludeMissing fun _caption(): JsonField = caption + + /** + * Returns the raw JSON value of [captionAbstract]. + * + * Unlike [captionAbstract], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CaptionAbstract") + @ExcludeMissing + fun _captionAbstract(): JsonField = captionAbstract + + /** + * Returns the raw JSON value of [captionWriter]. + * + * Unlike [captionWriter], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CaptionWriter") + @ExcludeMissing + fun _captionWriter(): JsonField = captionWriter + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("City") @ExcludeMissing fun _city(): JsonField = city + + /** + * 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 [componentsConfiguration]. + * + * Unlike [componentsConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ComponentsConfiguration") + @ExcludeMissing + fun _componentsConfiguration(): JsonField = componentsConfiguration + + /** + * Returns the raw JSON value of [copyright]. + * + * Unlike [copyright], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Copyright") @ExcludeMissing fun _copyright(): JsonField = copyright + + /** + * Returns the raw JSON value of [copyrightNotice]. + * + * Unlike [copyrightNotice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CopyrightNotice") + @ExcludeMissing + fun _copyrightNotice(): JsonField = copyrightNotice + + /** + * Returns the raw JSON value of [copyrightOwnerId]. + * + * Unlike [copyrightOwnerId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CopyrightOwnerID") + @ExcludeMissing + fun _copyrightOwnerId(): JsonField> = copyrightOwnerId + + /** + * Returns the raw JSON value of [copyrightOwnerName]. + * + * Unlike [copyrightOwnerName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CopyrightOwnerName") + @ExcludeMissing + fun _copyrightOwnerName(): JsonField> = copyrightOwnerName + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [countryCode]. + * + * Unlike [countryCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("CountryCode") + @ExcludeMissing + fun _countryCode(): JsonField = countryCode + + /** + * Returns the raw JSON value of [countryPrimaryLocationCode]. + * + * Unlike [countryPrimaryLocationCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CountryPrimaryLocationCode") + @ExcludeMissing + fun _countryPrimaryLocationCode(): JsonField = countryPrimaryLocationCode + + /** + * Returns the raw JSON value of [countryPrimaryLocationName]. + * + * Unlike [countryPrimaryLocationName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CountryPrimaryLocationName") + @ExcludeMissing + fun _countryPrimaryLocationName(): JsonField = countryPrimaryLocationName + + /** + * Returns the raw JSON value of [creator]. + * + * Unlike [creator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Creator") @ExcludeMissing fun _creator(): JsonField = creator + + /** + * Returns the raw JSON value of [creatorAddress]. + * + * Unlike [creatorAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorAddress") + @ExcludeMissing + fun _creatorAddress(): JsonField = creatorAddress + + /** + * Returns the raw JSON value of [creatorCity]. + * + * Unlike [creatorCity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("CreatorCity") + @ExcludeMissing + fun _creatorCity(): JsonField = creatorCity + + /** + * Returns the raw JSON value of [creatorCountry]. + * + * Unlike [creatorCountry], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorCountry") + @ExcludeMissing + fun _creatorCountry(): JsonField = creatorCountry + + /** + * Returns the raw JSON value of [creatorPostalCode]. + * + * Unlike [creatorPostalCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorPostalCode") + @ExcludeMissing + fun _creatorPostalCode(): JsonField = creatorPostalCode + + /** + * Returns the raw JSON value of [creatorRegion]. + * + * Unlike [creatorRegion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorRegion") + @ExcludeMissing + fun _creatorRegion(): JsonField = creatorRegion + + /** + * Returns the raw JSON value of [creatorWorkEmail]. + * + * Unlike [creatorWorkEmail], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorWorkEmail") + @ExcludeMissing + fun _creatorWorkEmail(): JsonField = creatorWorkEmail + + /** + * Returns the raw JSON value of [creatorWorkTelephone]. + * + * Unlike [creatorWorkTelephone], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CreatorWorkTelephone") + @ExcludeMissing + fun _creatorWorkTelephone(): JsonField = creatorWorkTelephone + + /** + * Returns the raw JSON value of [creatorWorkUrl]. + * + * Unlike [creatorWorkUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorWorkURL") + @ExcludeMissing + fun _creatorWorkUrl(): JsonField = creatorWorkUrl + + /** + * Returns the raw JSON value of [credit]. + * + * Unlike [credit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Credit") @ExcludeMissing fun _credit(): JsonField = credit + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("DateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateTimeCreated]. + * + * Unlike [dateTimeCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("DateTimeCreated") + @ExcludeMissing + fun _dateTimeCreated(): JsonField = dateTimeCreated + + /** + * 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 [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 [digitalImageGuid]. + * + * Unlike [digitalImageGuid], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("DigitalImageGUID") + @ExcludeMissing + fun _digitalImageGuid(): JsonField = digitalImageGuid + + /** + * Returns the raw JSON value of [digitalSourceType]. + * + * Unlike [digitalSourceType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("DigitalSourceType") + @ExcludeMissing + fun _digitalSourceType(): JsonField = digitalSourceType + + /** + * Returns the raw JSON value of [embeddedEncodedRightsExpr]. + * + * Unlike [embeddedEncodedRightsExpr], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("EmbeddedEncodedRightsExpr") + @ExcludeMissing + fun _embeddedEncodedRightsExpr(): JsonField = embeddedEncodedRightsExpr + + /** + * Returns the raw JSON value of [embeddedEncodedRightsExprLangId]. + * + * Unlike [embeddedEncodedRightsExprLangId], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("EmbeddedEncodedRightsExprLangID") + @ExcludeMissing + fun _embeddedEncodedRightsExprLangId(): JsonField = embeddedEncodedRightsExprLangId + + /** + * Returns the raw JSON value of [embeddedEncodedRightsExprType]. + * + * Unlike [embeddedEncodedRightsExprType], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("EmbeddedEncodedRightsExprType") + @ExcludeMissing + fun _embeddedEncodedRightsExprType(): JsonField = embeddedEncodedRightsExprType + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Event") @ExcludeMissing fun _event(): JsonField = event + + /** + * 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 [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 [genreCvId]. + * + * Unlike [genreCvId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("GenreCvId") @ExcludeMissing fun _genreCvId(): JsonField = genreCvId + + /** + * Returns the raw JSON value of [genreCvTermId]. + * + * Unlike [genreCvTermId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("GenreCvTermId") + @ExcludeMissing + fun _genreCvTermId(): JsonField = genreCvTermId + + /** + * Returns the raw JSON value of [genreCvTermName]. + * + * Unlike [genreCvTermName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("GenreCvTermName") + @ExcludeMissing + fun _genreCvTermName(): JsonField = genreCvTermName + + /** + * Returns the raw JSON value of [genreCvTermRefinedAbout]. + * + * Unlike [genreCvTermRefinedAbout], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("GenreCvTermRefinedAbout") + @ExcludeMissing + fun _genreCvTermRefinedAbout(): JsonField = genreCvTermRefinedAbout + + /** + * Returns the raw JSON value of [headline]. + * + * Unlike [headline], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Headline") @ExcludeMissing fun _headline(): JsonField = headline + + /** + * Returns the raw JSON value of [imageCreatorId]. + * + * Unlike [imageCreatorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageCreatorID") + @ExcludeMissing + fun _imageCreatorId(): JsonField = imageCreatorId + + /** + * Returns the raw JSON value of [imageCreatorImageId]. + * + * Unlike [imageCreatorImageId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageCreatorImageID") + @ExcludeMissing + fun _imageCreatorImageId(): JsonField = imageCreatorImageId + + /** + * Returns the raw JSON value of [imageCreatorName]. + * + * Unlike [imageCreatorName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageCreatorName") + @ExcludeMissing + fun _imageCreatorName(): JsonField = imageCreatorName + + /** + * Returns the raw JSON value of [imageDescription]. + * + * Unlike [imageDescription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageDescription") + @ExcludeMissing + fun _imageDescription(): JsonField = imageDescription + + /** + * Returns the raw JSON value of [imageRegionBoundaryH]. + * + * Unlike [imageRegionBoundaryH], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryH") + @ExcludeMissing + fun _imageRegionBoundaryH(): JsonField> = imageRegionBoundaryH + + /** + * Returns the raw JSON value of [imageRegionBoundaryRx]. + * + * Unlike [imageRegionBoundaryRx], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryRx") + @ExcludeMissing + fun _imageRegionBoundaryRx(): JsonField> = imageRegionBoundaryRx + + /** + * Returns the raw JSON value of [imageRegionBoundaryShape]. + * + * Unlike [imageRegionBoundaryShape], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryShape") + @ExcludeMissing + fun _imageRegionBoundaryShape(): JsonField> = imageRegionBoundaryShape + + /** + * Returns the raw JSON value of [imageRegionBoundaryUnit]. + * + * Unlike [imageRegionBoundaryUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryUnit") + @ExcludeMissing + fun _imageRegionBoundaryUnit(): JsonField> = imageRegionBoundaryUnit + + /** + * Returns the raw JSON value of [imageRegionBoundaryVerticesX]. + * + * Unlike [imageRegionBoundaryVerticesX], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryVerticesX") + @ExcludeMissing + fun _imageRegionBoundaryVerticesX(): JsonField> = imageRegionBoundaryVerticesX + + /** + * Returns the raw JSON value of [imageRegionBoundaryVerticesY]. + * + * Unlike [imageRegionBoundaryVerticesY], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryVerticesY") + @ExcludeMissing + fun _imageRegionBoundaryVerticesY(): JsonField> = imageRegionBoundaryVerticesY + + /** + * Returns the raw JSON value of [imageRegionBoundaryW]. + * + * Unlike [imageRegionBoundaryW], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryW") + @ExcludeMissing + fun _imageRegionBoundaryW(): JsonField> = imageRegionBoundaryW + + /** + * Returns the raw JSON value of [imageRegionBoundaryX]. + * + * Unlike [imageRegionBoundaryX], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryX") + @ExcludeMissing + fun _imageRegionBoundaryX(): JsonField> = imageRegionBoundaryX + + /** + * Returns the raw JSON value of [imageRegionBoundaryY]. + * + * Unlike [imageRegionBoundaryY], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryY") + @ExcludeMissing + fun _imageRegionBoundaryY(): JsonField> = imageRegionBoundaryY + + /** + * Returns the raw JSON value of [imageRegionCtypeIdentifier]. + * + * Unlike [imageRegionCtypeIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionCtypeIdentifier") + @ExcludeMissing + fun _imageRegionCtypeIdentifier(): JsonField> = imageRegionCtypeIdentifier + + /** + * Returns the raw JSON value of [imageRegionCtypeName]. + * + * Unlike [imageRegionCtypeName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionCtypeName") + @ExcludeMissing + fun _imageRegionCtypeName(): JsonField> = imageRegionCtypeName + + /** + * Returns the raw JSON value of [imageRegionId]. + * + * Unlike [imageRegionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageRegionID") + @ExcludeMissing + fun _imageRegionId(): JsonField> = imageRegionId + + /** + * Returns the raw JSON value of [imageRegionName]. + * + * Unlike [imageRegionName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageRegionName") + @ExcludeMissing + fun _imageRegionName(): JsonField> = imageRegionName + + /** + * Returns the raw JSON value of [imageRegionOrganisationInImageName]. + * + * Unlike [imageRegionOrganisationInImageName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("ImageRegionOrganisationInImageName") + @ExcludeMissing + fun _imageRegionOrganisationInImageName(): JsonField> = + imageRegionOrganisationInImageName + + /** + * Returns the raw JSON value of [imageRegionPersonInImage]. + * + * Unlike [imageRegionPersonInImage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionPersonInImage") + @ExcludeMissing + fun _imageRegionPersonInImage(): JsonField> = imageRegionPersonInImage + + /** + * Returns the raw JSON value of [imageRegionRoleIdentifier]. + * + * Unlike [imageRegionRoleIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionRoleIdentifier") + @ExcludeMissing + fun _imageRegionRoleIdentifier(): JsonField> = imageRegionRoleIdentifier + + /** + * Returns the raw JSON value of [imageRegionRoleName]. + * + * Unlike [imageRegionRoleName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionRoleName") + @ExcludeMissing + fun _imageRegionRoleName(): JsonField> = imageRegionRoleName + + /** + * Returns the raw JSON value of [imageSupplierId]. + * + * Unlike [imageSupplierId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageSupplierID") + @ExcludeMissing + fun _imageSupplierId(): JsonField = imageSupplierId + + /** + * Returns the raw JSON value of [imageSupplierImageId]. + * + * Unlike [imageSupplierImageId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageSupplierImageID") + @ExcludeMissing + fun _imageSupplierImageId(): JsonField = imageSupplierImageId + + /** + * Returns the raw JSON value of [imageSupplierName]. + * + * Unlike [imageSupplierName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageSupplierName") + @ExcludeMissing + fun _imageSupplierName(): JsonField = imageSupplierName + + /** + * Returns the raw JSON value of [instructions]. + * + * Unlike [instructions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("Instructions") + @ExcludeMissing + fun _instructions(): JsonField = instructions + + /** + * Returns the raw JSON value of [intellectualGenre]. + * + * Unlike [intellectualGenre], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("IntellectualGenre") + @ExcludeMissing + fun _intellectualGenre(): JsonField = intellectualGenre + + /** + * Returns the raw JSON value of [keywords]. + * + * Unlike [keywords], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Keywords") + @ExcludeMissing + fun _keywords(): JsonField> = keywords + + /** + * Returns the raw JSON value of [licensorCity]. + * + * Unlike [licensorCity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorCity") + @ExcludeMissing + fun _licensorCity(): JsonField> = licensorCity + + /** + * Returns the raw JSON value of [licensorCountry]. + * + * Unlike [licensorCountry], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorCountry") + @ExcludeMissing + fun _licensorCountry(): JsonField> = licensorCountry + + /** + * Returns the raw JSON value of [licensorEmail]. + * + * Unlike [licensorEmail], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorEmail") + @ExcludeMissing + fun _licensorEmail(): JsonField> = licensorEmail + + /** + * Returns the raw JSON value of [licensorExtendedAddress]. + * + * Unlike [licensorExtendedAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorExtendedAddress") + @ExcludeMissing + fun _licensorExtendedAddress(): JsonField> = licensorExtendedAddress + + /** + * Returns the raw JSON value of [licensorId]. + * + * Unlike [licensorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("LicensorID") + @ExcludeMissing + fun _licensorId(): JsonField> = licensorId + + /** + * Returns the raw JSON value of [licensorName]. + * + * Unlike [licensorName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorName") + @ExcludeMissing + fun _licensorName(): JsonField> = licensorName + + /** + * Returns the raw JSON value of [licensorPostalCode]. + * + * Unlike [licensorPostalCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorPostalCode") + @ExcludeMissing + fun _licensorPostalCode(): JsonField> = licensorPostalCode + + /** + * Returns the raw JSON value of [licensorRegion]. + * + * Unlike [licensorRegion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorRegion") + @ExcludeMissing + fun _licensorRegion(): JsonField> = licensorRegion + + /** + * Returns the raw JSON value of [licensorStreetAddress]. + * + * Unlike [licensorStreetAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorStreetAddress") + @ExcludeMissing + fun _licensorStreetAddress(): JsonField> = licensorStreetAddress + + /** + * Returns the raw JSON value of [licensorTelephone1]. + * + * Unlike [licensorTelephone1], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorTelephone1") + @ExcludeMissing + fun _licensorTelephone1(): JsonField> = licensorTelephone1 + + /** + * Returns the raw JSON value of [licensorTelephone2]. + * + * Unlike [licensorTelephone2], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorTelephone2") + @ExcludeMissing + fun _licensorTelephone2(): JsonField> = licensorTelephone2 + + /** + * Returns the raw JSON value of [licensorUrl]. + * + * Unlike [licensorUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("LicensorURL") + @ExcludeMissing + fun _licensorUrl(): JsonField> = licensorUrl + + /** + * Returns the raw JSON value of [linkedEncodedRightsExpr]. + * + * Unlike [linkedEncodedRightsExpr], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LinkedEncodedRightsExpr") + @ExcludeMissing + fun _linkedEncodedRightsExpr(): JsonField = linkedEncodedRightsExpr + + /** + * Returns the raw JSON value of [linkedEncodedRightsExprLangId]. + * + * Unlike [linkedEncodedRightsExprLangId], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("LinkedEncodedRightsExprLangID") + @ExcludeMissing + fun _linkedEncodedRightsExprLangId(): JsonField = linkedEncodedRightsExprLangId + + /** + * Returns the raw JSON value of [linkedEncodedRightsExprType]. + * + * Unlike [linkedEncodedRightsExprType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LinkedEncodedRightsExprType") + @ExcludeMissing + fun _linkedEncodedRightsExprType(): JsonField = linkedEncodedRightsExprType + + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Location") @ExcludeMissing fun _location(): JsonField = location + + /** + * Returns the raw JSON value of [locationCreatedCity]. + * + * Unlike [locationCreatedCity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedCity") + @ExcludeMissing + fun _locationCreatedCity(): JsonField = locationCreatedCity + + /** + * Returns the raw JSON value of [locationCreatedCountryCode]. + * + * Unlike [locationCreatedCountryCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedCountryCode") + @ExcludeMissing + fun _locationCreatedCountryCode(): JsonField = locationCreatedCountryCode + + /** + * Returns the raw JSON value of [locationCreatedCountryName]. + * + * Unlike [locationCreatedCountryName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedCountryName") + @ExcludeMissing + fun _locationCreatedCountryName(): JsonField = locationCreatedCountryName + + /** + * Returns the raw JSON value of [locationCreatedGpsAltitude]. + * + * Unlike [locationCreatedGpsAltitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedGPSAltitude") + @ExcludeMissing + fun _locationCreatedGpsAltitude(): JsonField = locationCreatedGpsAltitude + + /** + * Returns the raw JSON value of [locationCreatedGpsLatitude]. + * + * Unlike [locationCreatedGpsLatitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedGPSLatitude") + @ExcludeMissing + fun _locationCreatedGpsLatitude(): JsonField = locationCreatedGpsLatitude + + /** + * Returns the raw JSON value of [locationCreatedGpsLongitude]. + * + * Unlike [locationCreatedGpsLongitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedGPSLongitude") + @ExcludeMissing + fun _locationCreatedGpsLongitude(): JsonField = locationCreatedGpsLongitude + + /** + * Returns the raw JSON value of [locationCreatedLocationId]. + * + * Unlike [locationCreatedLocationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedLocationId") + @ExcludeMissing + fun _locationCreatedLocationId(): JsonField = locationCreatedLocationId + + /** + * Returns the raw JSON value of [locationCreatedLocationName]. + * + * Unlike [locationCreatedLocationName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedLocationName") + @ExcludeMissing + fun _locationCreatedLocationName(): JsonField = locationCreatedLocationName + + /** + * Returns the raw JSON value of [locationCreatedProvinceState]. + * + * Unlike [locationCreatedProvinceState], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedProvinceState") + @ExcludeMissing + fun _locationCreatedProvinceState(): JsonField = locationCreatedProvinceState + + /** + * Returns the raw JSON value of [locationCreatedSublocation]. + * + * Unlike [locationCreatedSublocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedSublocation") + @ExcludeMissing + fun _locationCreatedSublocation(): JsonField = locationCreatedSublocation + + /** + * Returns the raw JSON value of [locationCreatedWorldRegion]. + * + * Unlike [locationCreatedWorldRegion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedWorldRegion") + @ExcludeMissing + fun _locationCreatedWorldRegion(): JsonField = locationCreatedWorldRegion + + /** + * Returns the raw JSON value of [locationShownCity]. + * + * Unlike [locationShownCity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LocationShownCity") + @ExcludeMissing + fun _locationShownCity(): JsonField> = locationShownCity + + /** + * Returns the raw JSON value of [locationShownCountryCode]. + * + * Unlike [locationShownCountryCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownCountryCode") + @ExcludeMissing + fun _locationShownCountryCode(): JsonField> = locationShownCountryCode + + /** + * Returns the raw JSON value of [locationShownCountryName]. + * + * Unlike [locationShownCountryName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownCountryName") + @ExcludeMissing + fun _locationShownCountryName(): JsonField> = locationShownCountryName + + /** + * Returns the raw JSON value of [locationShownGpsAltitude]. + * + * Unlike [locationShownGpsAltitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownGPSAltitude") + @ExcludeMissing + fun _locationShownGpsAltitude(): JsonField> = locationShownGpsAltitude + + /** + * Returns the raw JSON value of [locationShownGpsLatitude]. + * + * Unlike [locationShownGpsLatitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownGPSLatitude") + @ExcludeMissing + fun _locationShownGpsLatitude(): JsonField> = locationShownGpsLatitude + + /** + * Returns the raw JSON value of [locationShownGpsLongitude]. + * + * Unlike [locationShownGpsLongitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownGPSLongitude") + @ExcludeMissing + fun _locationShownGpsLongitude(): JsonField> = locationShownGpsLongitude + + /** + * Returns the raw JSON value of [locationShownLocationId]. + * + * Unlike [locationShownLocationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownLocationId") + @ExcludeMissing + fun _locationShownLocationId(): JsonField> = locationShownLocationId + + /** + * Returns the raw JSON value of [locationShownLocationName]. + * + * Unlike [locationShownLocationName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownLocationName") + @ExcludeMissing + fun _locationShownLocationName(): JsonField> = locationShownLocationName + + /** + * Returns the raw JSON value of [locationShownProvinceState]. + * + * Unlike [locationShownProvinceState], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownProvinceState") + @ExcludeMissing + fun _locationShownProvinceState(): JsonField> = locationShownProvinceState + + /** + * Returns the raw JSON value of [locationShownSublocation]. + * + * Unlike [locationShownSublocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownSublocation") + @ExcludeMissing + fun _locationShownSublocation(): JsonField> = locationShownSublocation + + /** + * Returns the raw JSON value of [locationShownWorldRegion]. + * + * Unlike [locationShownWorldRegion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownWorldRegion") + @ExcludeMissing + fun _locationShownWorldRegion(): JsonField> = locationShownWorldRegion + + /** + * Returns the raw JSON value of [maxAvailHeight]. + * + * Unlike [maxAvailHeight], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("MaxAvailHeight") + @ExcludeMissing + fun _maxAvailHeight(): JsonField = maxAvailHeight + + /** + * Returns the raw JSON value of [maxAvailWidth]. + * + * Unlike [maxAvailWidth], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("MaxAvailWidth") + @ExcludeMissing + fun _maxAvailWidth(): JsonField = maxAvailWidth + + /** + * Returns the raw JSON value of [modelAge]. + * + * Unlike [modelAge], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ModelAge") + @ExcludeMissing + fun _modelAge(): JsonField> = modelAge + + /** + * Returns the raw JSON value of [modelReleaseId]. + * + * Unlike [modelReleaseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ModelReleaseID") + @ExcludeMissing + fun _modelReleaseId(): JsonField> = modelReleaseId + + /** + * Returns the raw JSON value of [objectAttributeReference]. + * + * Unlike [objectAttributeReference], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ObjectAttributeReference") + @ExcludeMissing + fun _objectAttributeReference(): JsonField = objectAttributeReference + + /** + * Returns the raw JSON value of [objectName]. + * + * Unlike [objectName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ObjectName") + @ExcludeMissing + fun _objectName(): JsonField = objectName + + /** + * Returns the raw JSON value of [offsetTimeOriginal]. + * + * Unlike [offsetTimeOriginal], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("OffsetTimeOriginal") + @ExcludeMissing + fun _offsetTimeOriginal(): JsonField = offsetTimeOriginal + + /** + * Returns the raw JSON value of [organisationInImageCode]. + * + * Unlike [organisationInImageCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("OrganisationInImageCode") + @ExcludeMissing + fun _organisationInImageCode(): JsonField> = organisationInImageCode + + /** + * Returns the raw JSON value of [organisationInImageName]. + * + * Unlike [organisationInImageName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("OrganisationInImageName") + @ExcludeMissing + fun _organisationInImageName(): JsonField> = organisationInImageName + + /** + * 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 [originalTransmissionReference]. + * + * Unlike [originalTransmissionReference], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("OriginalTransmissionReference") + @ExcludeMissing + fun _originalTransmissionReference(): JsonField = originalTransmissionReference + + /** + * Returns the raw JSON value of [personInImage]. + * + * Unlike [personInImage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("PersonInImage") + @ExcludeMissing + fun _personInImage(): JsonField> = personInImage + + /** + * Returns the raw JSON value of [personInImageCvTermCvId]. + * + * Unlike [personInImageCvTermCvId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("PersonInImageCvTermCvId") + @ExcludeMissing + fun _personInImageCvTermCvId(): JsonField> = personInImageCvTermCvId + + /** + * Returns the raw JSON value of [personInImageCvTermId]. + * + * Unlike [personInImageCvTermId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("PersonInImageCvTermId") + @ExcludeMissing + fun _personInImageCvTermId(): JsonField> = personInImageCvTermId + + /** + * Returns the raw JSON value of [personInImageCvTermName]. + * + * Unlike [personInImageCvTermName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("PersonInImageCvTermName") + @ExcludeMissing + fun _personInImageCvTermName(): JsonField> = personInImageCvTermName + + /** + * Returns the raw JSON value of [personInImageCvTermRefinedAbout]. + * + * Unlike [personInImageCvTermRefinedAbout], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("PersonInImageCvTermRefinedAbout") + @ExcludeMissing + fun _personInImageCvTermRefinedAbout(): JsonField> = + personInImageCvTermRefinedAbout + + /** + * Returns the raw JSON value of [personInImageDescription]. + * + * Unlike [personInImageDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("PersonInImageDescription") + @ExcludeMissing + fun _personInImageDescription(): JsonField> = personInImageDescription + + /** + * Returns the raw JSON value of [personInImageId]. + * + * Unlike [personInImageId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("PersonInImageId") + @ExcludeMissing + fun _personInImageId(): JsonField> = personInImageId + + /** + * Returns the raw JSON value of [personInImageName]. + * + * Unlike [personInImageName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("PersonInImageName") + @ExcludeMissing + fun _personInImageName(): JsonField> = personInImageName + + /** + * Returns the raw JSON value of [productInImageDescription]. + * + * Unlike [productInImageDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ProductInImageDescription") + @ExcludeMissing + fun _productInImageDescription(): JsonField> = productInImageDescription + + /** + * Returns the raw JSON value of [productInImageGtin]. + * + * Unlike [productInImageGtin], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ProductInImageGTIN") + @ExcludeMissing + fun _productInImageGtin(): JsonField> = productInImageGtin + + /** + * Returns the raw JSON value of [productInImageName]. + * + * Unlike [productInImageName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ProductInImageName") + @ExcludeMissing + fun _productInImageName(): JsonField> = productInImageName + + /** + * Returns the raw JSON value of [propertyReleaseId]. + * + * Unlike [propertyReleaseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("PropertyReleaseID") + @ExcludeMissing + fun _propertyReleaseId(): JsonField> = propertyReleaseId + + /** + * Returns the raw JSON value of [provinceState]. + * + * Unlike [provinceState], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ProvinceState") + @ExcludeMissing + fun _provinceState(): JsonField = provinceState + + /** + * Returns the raw JSON value of [rating]. + * + * Unlike [rating], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Rating") @ExcludeMissing fun _rating(): JsonField = rating + + /** + * Returns the raw JSON value of [registryEntryRole]. + * + * Unlike [registryEntryRole], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("RegistryEntryRole") + @ExcludeMissing + fun _registryEntryRole(): JsonField> = registryEntryRole + + /** + * Returns the raw JSON value of [registryItemId]. + * + * Unlike [registryItemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("RegistryItemID") + @ExcludeMissing + fun _registryItemId(): JsonField> = registryItemId + + /** + * Returns the raw JSON value of [registryOrganisationId]. + * + * Unlike [registryOrganisationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("RegistryOrganisationID") + @ExcludeMissing + fun _registryOrganisationId(): JsonField> = registryOrganisationId + + /** + * 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 [rights]. + * + * Unlike [rights], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Rights") @ExcludeMissing fun _rights(): JsonField = rights + + /** + * Returns the raw JSON value of [scene]. + * + * Unlike [scene], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Scene") @ExcludeMissing fun _scene(): JsonField> = scene + + /** + * 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 + + /** + * Returns the raw JSON value of [specialInstructions]. + * + * Unlike [specialInstructions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("SpecialInstructions") + @ExcludeMissing + fun _specialInstructions(): JsonField = specialInstructions + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("State") @ExcludeMissing fun _state(): JsonField = state + + /** + * Returns the raw JSON value of [subject]. + * + * Unlike [subject], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Subject") @ExcludeMissing fun _subject(): JsonField> = subject + + /** + * Returns the raw JSON value of [subjectCode]. + * + * Unlike [subjectCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("SubjectCode") + @ExcludeMissing + fun _subjectCode(): JsonField> = subjectCode + + /** + * Returns the raw JSON value of [subjectReference]. + * + * Unlike [subjectReference], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("SubjectReference") + @ExcludeMissing + fun _subjectReference(): JsonField> = subjectReference + + /** + * Returns the raw JSON value of [sublocation]. + * + * Unlike [sublocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Sublocation") + @ExcludeMissing + fun _sublocation(): JsonField = sublocation + + /** + * Returns the raw JSON value of [timeCreated]. + * + * Unlike [timeCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("TimeCreated") + @ExcludeMissing + fun _timeCreated(): JsonField = timeCreated + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [transmissionReference]. + * + * Unlike [transmissionReference], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("TransmissionReference") + @ExcludeMissing + fun _transmissionReference(): JsonField = transmissionReference + + /** + * Returns the raw JSON value of [usageTerms]. + * + * Unlike [usageTerms], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("UsageTerms") + @ExcludeMissing + fun _usageTerms(): JsonField = usageTerms + + /** + * Returns the raw JSON value of [webStatement]. + * + * Unlike [webStatement], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("WebStatement") + @ExcludeMissing + fun _webStatement(): JsonField = webStatement + + /** + * Returns the raw JSON value of [writer]. + * + * Unlike [writer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Writer") @ExcludeMissing fun _writer(): JsonField = writer + + /** + * Returns the raw JSON value of [writerEditor]. + * + * Unlike [writerEditor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("WriterEditor") + @ExcludeMissing + fun _writerEditor(): JsonField = writerEditor + + /** + * 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 [EmbeddedMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmbeddedMetadata]. */ + class Builder internal constructor() { + + private var aboutCvTermCvId: JsonField = JsonMissing.of() + private var aboutCvTermId: JsonField = JsonMissing.of() + private var aboutCvTermName: JsonField = JsonMissing.of() + private var aboutCvTermRefinedAbout: JsonField = JsonMissing.of() + private var additionalModelInformation: JsonField = JsonMissing.of() + private var applicationRecordVersion: JsonField = JsonMissing.of() + private var artist: JsonField = JsonMissing.of() + private var artworkCircaDateCreated: JsonField = JsonMissing.of() + private var artworkContentDescription: JsonField = JsonMissing.of() + private var artworkContributionDescription: JsonField = JsonMissing.of() + private var artworkCopyrightNotice: JsonField = JsonMissing.of() + private var artworkCopyrightOwnerId: JsonField = JsonMissing.of() + private var artworkCopyrightOwnerName: JsonField = JsonMissing.of() + private var artworkCreator: JsonField>? = null + private var artworkCreatorId: JsonField>? = null + private var artworkDateCreated: JsonField = JsonMissing.of() + private var artworkLicensorId: JsonField = JsonMissing.of() + private var artworkLicensorName: JsonField = JsonMissing.of() + private var artworkPhysicalDescription: JsonField = JsonMissing.of() + private var artworkSource: JsonField = JsonMissing.of() + private var artworkSourceInventoryNo: JsonField = JsonMissing.of() + private var artworkSourceInvUrl: JsonField = JsonMissing.of() + private var artworkStylePeriod: JsonField>? = null + private var artworkTitle: JsonField = JsonMissing.of() + private var authorsPosition: JsonField = JsonMissing.of() + private var byline: JsonField = JsonMissing.of() + private var bylineTitle: JsonField = JsonMissing.of() + private var caption: JsonField = JsonMissing.of() + private var captionAbstract: JsonField = JsonMissing.of() + private var captionWriter: JsonField = JsonMissing.of() + private var city: JsonField = JsonMissing.of() + private var colorSpace: JsonField = JsonMissing.of() + private var componentsConfiguration: JsonField = JsonMissing.of() + private var copyright: JsonField = JsonMissing.of() + private var copyrightNotice: JsonField = JsonMissing.of() + private var copyrightOwnerId: JsonField>? = null + private var copyrightOwnerName: JsonField>? = null + private var country: JsonField = JsonMissing.of() + private var countryCode: JsonField = JsonMissing.of() + private var countryPrimaryLocationCode: JsonField = JsonMissing.of() + private var countryPrimaryLocationName: JsonField = JsonMissing.of() + private var creator: JsonField = JsonMissing.of() + private var creatorAddress: JsonField = JsonMissing.of() + private var creatorCity: JsonField = JsonMissing.of() + private var creatorCountry: JsonField = JsonMissing.of() + private var creatorPostalCode: JsonField = JsonMissing.of() + private var creatorRegion: JsonField = JsonMissing.of() + private var creatorWorkEmail: JsonField = JsonMissing.of() + private var creatorWorkTelephone: JsonField = JsonMissing.of() + private var creatorWorkUrl: JsonField = JsonMissing.of() + private var credit: JsonField = JsonMissing.of() + private var dateCreated: JsonField = JsonMissing.of() + private var dateTimeCreated: JsonField = JsonMissing.of() + private var dateTimeOriginal: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var digitalImageGuid: JsonField = JsonMissing.of() + private var digitalSourceType: JsonField = JsonMissing.of() + private var embeddedEncodedRightsExpr: JsonField = JsonMissing.of() + private var embeddedEncodedRightsExprLangId: JsonField = JsonMissing.of() + private var embeddedEncodedRightsExprType: JsonField = JsonMissing.of() + private var event: JsonField = JsonMissing.of() + private var exifVersion: JsonField = JsonMissing.of() + private var flashpixVersion: JsonField = JsonMissing.of() + private var genreCvId: JsonField = JsonMissing.of() + private var genreCvTermId: JsonField = JsonMissing.of() + private var genreCvTermName: JsonField = JsonMissing.of() + private var genreCvTermRefinedAbout: JsonField = JsonMissing.of() + private var headline: JsonField = JsonMissing.of() + private var imageCreatorId: JsonField = JsonMissing.of() + private var imageCreatorImageId: JsonField = JsonMissing.of() + private var imageCreatorName: JsonField = JsonMissing.of() + private var imageDescription: JsonField = JsonMissing.of() + private var imageRegionBoundaryH: JsonField>? = null + private var imageRegionBoundaryRx: JsonField>? = null + private var imageRegionBoundaryShape: JsonField>? = null + private var imageRegionBoundaryUnit: JsonField>? = null + private var imageRegionBoundaryVerticesX: JsonField>? = null + private var imageRegionBoundaryVerticesY: JsonField>? = null + private var imageRegionBoundaryW: JsonField>? = null + private var imageRegionBoundaryX: JsonField>? = null + private var imageRegionBoundaryY: JsonField>? = null + private var imageRegionCtypeIdentifier: JsonField>? = null + private var imageRegionCtypeName: JsonField>? = null + private var imageRegionId: JsonField>? = null + private var imageRegionName: JsonField>? = null + private var imageRegionOrganisationInImageName: JsonField>? = null + private var imageRegionPersonInImage: JsonField>? = null + private var imageRegionRoleIdentifier: JsonField>? = null + private var imageRegionRoleName: JsonField>? = null + private var imageSupplierId: JsonField = JsonMissing.of() + private var imageSupplierImageId: JsonField = JsonMissing.of() + private var imageSupplierName: JsonField = JsonMissing.of() + private var instructions: JsonField = JsonMissing.of() + private var intellectualGenre: JsonField = JsonMissing.of() + private var keywords: JsonField>? = null + private var licensorCity: JsonField>? = null + private var licensorCountry: JsonField>? = null + private var licensorEmail: JsonField>? = null + private var licensorExtendedAddress: JsonField>? = null + private var licensorId: JsonField>? = null + private var licensorName: JsonField>? = null + private var licensorPostalCode: JsonField>? = null + private var licensorRegion: JsonField>? = null + private var licensorStreetAddress: JsonField>? = null + private var licensorTelephone1: JsonField>? = null + private var licensorTelephone2: JsonField>? = null + private var licensorUrl: JsonField>? = null + private var linkedEncodedRightsExpr: JsonField = JsonMissing.of() + private var linkedEncodedRightsExprLangId: JsonField = JsonMissing.of() + private var linkedEncodedRightsExprType: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var locationCreatedCity: JsonField = JsonMissing.of() + private var locationCreatedCountryCode: JsonField = JsonMissing.of() + private var locationCreatedCountryName: JsonField = JsonMissing.of() + private var locationCreatedGpsAltitude: JsonField = JsonMissing.of() + private var locationCreatedGpsLatitude: JsonField = JsonMissing.of() + private var locationCreatedGpsLongitude: JsonField = JsonMissing.of() + private var locationCreatedLocationId: JsonField = JsonMissing.of() + private var locationCreatedLocationName: JsonField = JsonMissing.of() + private var locationCreatedProvinceState: JsonField = JsonMissing.of() + private var locationCreatedSublocation: JsonField = JsonMissing.of() + private var locationCreatedWorldRegion: JsonField = JsonMissing.of() + private var locationShownCity: JsonField>? = null + private var locationShownCountryCode: JsonField>? = null + private var locationShownCountryName: JsonField>? = null + private var locationShownGpsAltitude: JsonField>? = null + private var locationShownGpsLatitude: JsonField>? = null + private var locationShownGpsLongitude: JsonField>? = null + private var locationShownLocationId: JsonField>? = null + private var locationShownLocationName: JsonField>? = null + private var locationShownProvinceState: JsonField>? = null + private var locationShownSublocation: JsonField>? = null + private var locationShownWorldRegion: JsonField>? = null + private var maxAvailHeight: JsonField = JsonMissing.of() + private var maxAvailWidth: JsonField = JsonMissing.of() + private var modelAge: JsonField>? = null + private var modelReleaseId: JsonField>? = null + private var objectAttributeReference: JsonField = JsonMissing.of() + private var objectName: JsonField = JsonMissing.of() + private var offsetTimeOriginal: JsonField = JsonMissing.of() + private var organisationInImageCode: JsonField>? = null + private var organisationInImageName: JsonField>? = null + private var orientation: JsonField = JsonMissing.of() + private var originalTransmissionReference: JsonField = JsonMissing.of() + private var personInImage: JsonField>? = null + private var personInImageCvTermCvId: JsonField>? = null + private var personInImageCvTermId: JsonField>? = null + private var personInImageCvTermName: JsonField>? = null + private var personInImageCvTermRefinedAbout: JsonField>? = null + private var personInImageDescription: JsonField>? = null + private var personInImageId: JsonField>? = null + private var personInImageName: JsonField>? = null + private var productInImageDescription: JsonField>? = null + private var productInImageGtin: JsonField>? = null + private var productInImageName: JsonField>? = null + private var propertyReleaseId: JsonField>? = null + private var provinceState: JsonField = JsonMissing.of() + private var rating: JsonField = JsonMissing.of() + private var registryEntryRole: JsonField>? = null + private var registryItemId: JsonField>? = null + private var registryOrganisationId: JsonField>? = null + private var resolutionUnit: JsonField = JsonMissing.of() + private var rights: JsonField = JsonMissing.of() + private var scene: JsonField>? = null + private var source: JsonField = JsonMissing.of() + private var specialInstructions: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var subject: JsonField>? = null + private var subjectCode: JsonField>? = null + private var subjectReference: JsonField>? = null + private var sublocation: JsonField = JsonMissing.of() + private var timeCreated: JsonField = JsonMissing.of() + private var title: JsonField = JsonMissing.of() + private var transmissionReference: JsonField = JsonMissing.of() + private var usageTerms: JsonField = JsonMissing.of() + private var webStatement: JsonField = JsonMissing.of() + private var writer: JsonField = JsonMissing.of() + private var writerEditor: JsonField = JsonMissing.of() + private var xResolution: JsonField = JsonMissing.of() + private var yResolution: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { + aboutCvTermCvId = embeddedMetadata.aboutCvTermCvId + aboutCvTermId = embeddedMetadata.aboutCvTermId + aboutCvTermName = embeddedMetadata.aboutCvTermName + aboutCvTermRefinedAbout = embeddedMetadata.aboutCvTermRefinedAbout + additionalModelInformation = embeddedMetadata.additionalModelInformation + applicationRecordVersion = embeddedMetadata.applicationRecordVersion + artist = embeddedMetadata.artist + artworkCircaDateCreated = embeddedMetadata.artworkCircaDateCreated + artworkContentDescription = embeddedMetadata.artworkContentDescription + artworkContributionDescription = embeddedMetadata.artworkContributionDescription + artworkCopyrightNotice = embeddedMetadata.artworkCopyrightNotice + artworkCopyrightOwnerId = embeddedMetadata.artworkCopyrightOwnerId + artworkCopyrightOwnerName = embeddedMetadata.artworkCopyrightOwnerName + artworkCreator = embeddedMetadata.artworkCreator.map { it.toMutableList() } + artworkCreatorId = embeddedMetadata.artworkCreatorId.map { it.toMutableList() } + artworkDateCreated = embeddedMetadata.artworkDateCreated + artworkLicensorId = embeddedMetadata.artworkLicensorId + artworkLicensorName = embeddedMetadata.artworkLicensorName + artworkPhysicalDescription = embeddedMetadata.artworkPhysicalDescription + artworkSource = embeddedMetadata.artworkSource + artworkSourceInventoryNo = embeddedMetadata.artworkSourceInventoryNo + artworkSourceInvUrl = embeddedMetadata.artworkSourceInvUrl + artworkStylePeriod = embeddedMetadata.artworkStylePeriod.map { it.toMutableList() } + artworkTitle = embeddedMetadata.artworkTitle + authorsPosition = embeddedMetadata.authorsPosition + byline = embeddedMetadata.byline + bylineTitle = embeddedMetadata.bylineTitle + caption = embeddedMetadata.caption + captionAbstract = embeddedMetadata.captionAbstract + captionWriter = embeddedMetadata.captionWriter + city = embeddedMetadata.city + colorSpace = embeddedMetadata.colorSpace + componentsConfiguration = embeddedMetadata.componentsConfiguration + copyright = embeddedMetadata.copyright + copyrightNotice = embeddedMetadata.copyrightNotice + copyrightOwnerId = embeddedMetadata.copyrightOwnerId.map { it.toMutableList() } + copyrightOwnerName = embeddedMetadata.copyrightOwnerName.map { it.toMutableList() } + country = embeddedMetadata.country + countryCode = embeddedMetadata.countryCode + countryPrimaryLocationCode = embeddedMetadata.countryPrimaryLocationCode + countryPrimaryLocationName = embeddedMetadata.countryPrimaryLocationName + creator = embeddedMetadata.creator + creatorAddress = embeddedMetadata.creatorAddress + creatorCity = embeddedMetadata.creatorCity + creatorCountry = embeddedMetadata.creatorCountry + creatorPostalCode = embeddedMetadata.creatorPostalCode + creatorRegion = embeddedMetadata.creatorRegion + creatorWorkEmail = embeddedMetadata.creatorWorkEmail + creatorWorkTelephone = embeddedMetadata.creatorWorkTelephone + creatorWorkUrl = embeddedMetadata.creatorWorkUrl + credit = embeddedMetadata.credit + dateCreated = embeddedMetadata.dateCreated + dateTimeCreated = embeddedMetadata.dateTimeCreated + dateTimeOriginal = embeddedMetadata.dateTimeOriginal + description = embeddedMetadata.description + digitalImageGuid = embeddedMetadata.digitalImageGuid + digitalSourceType = embeddedMetadata.digitalSourceType + embeddedEncodedRightsExpr = embeddedMetadata.embeddedEncodedRightsExpr + embeddedEncodedRightsExprLangId = embeddedMetadata.embeddedEncodedRightsExprLangId + embeddedEncodedRightsExprType = embeddedMetadata.embeddedEncodedRightsExprType + event = embeddedMetadata.event + exifVersion = embeddedMetadata.exifVersion + flashpixVersion = embeddedMetadata.flashpixVersion + genreCvId = embeddedMetadata.genreCvId + genreCvTermId = embeddedMetadata.genreCvTermId + genreCvTermName = embeddedMetadata.genreCvTermName + genreCvTermRefinedAbout = embeddedMetadata.genreCvTermRefinedAbout + headline = embeddedMetadata.headline + imageCreatorId = embeddedMetadata.imageCreatorId + imageCreatorImageId = embeddedMetadata.imageCreatorImageId + imageCreatorName = embeddedMetadata.imageCreatorName + imageDescription = embeddedMetadata.imageDescription + imageRegionBoundaryH = + embeddedMetadata.imageRegionBoundaryH.map { it.toMutableList() } + imageRegionBoundaryRx = + embeddedMetadata.imageRegionBoundaryRx.map { it.toMutableList() } + imageRegionBoundaryShape = + embeddedMetadata.imageRegionBoundaryShape.map { it.toMutableList() } + imageRegionBoundaryUnit = + embeddedMetadata.imageRegionBoundaryUnit.map { it.toMutableList() } + imageRegionBoundaryVerticesX = + embeddedMetadata.imageRegionBoundaryVerticesX.map { it.toMutableList() } + imageRegionBoundaryVerticesY = + embeddedMetadata.imageRegionBoundaryVerticesY.map { it.toMutableList() } + imageRegionBoundaryW = + embeddedMetadata.imageRegionBoundaryW.map { it.toMutableList() } + imageRegionBoundaryX = + embeddedMetadata.imageRegionBoundaryX.map { it.toMutableList() } + imageRegionBoundaryY = + embeddedMetadata.imageRegionBoundaryY.map { it.toMutableList() } + imageRegionCtypeIdentifier = + embeddedMetadata.imageRegionCtypeIdentifier.map { it.toMutableList() } + imageRegionCtypeName = + embeddedMetadata.imageRegionCtypeName.map { it.toMutableList() } + imageRegionId = embeddedMetadata.imageRegionId.map { it.toMutableList() } + imageRegionName = embeddedMetadata.imageRegionName.map { it.toMutableList() } + imageRegionOrganisationInImageName = + embeddedMetadata.imageRegionOrganisationInImageName.map { it.toMutableList() } + imageRegionPersonInImage = + embeddedMetadata.imageRegionPersonInImage.map { it.toMutableList() } + imageRegionRoleIdentifier = + embeddedMetadata.imageRegionRoleIdentifier.map { it.toMutableList() } + imageRegionRoleName = + embeddedMetadata.imageRegionRoleName.map { it.toMutableList() } + imageSupplierId = embeddedMetadata.imageSupplierId + imageSupplierImageId = embeddedMetadata.imageSupplierImageId + imageSupplierName = embeddedMetadata.imageSupplierName + instructions = embeddedMetadata.instructions + intellectualGenre = embeddedMetadata.intellectualGenre + keywords = embeddedMetadata.keywords.map { it.toMutableList() } + licensorCity = embeddedMetadata.licensorCity.map { it.toMutableList() } + licensorCountry = embeddedMetadata.licensorCountry.map { it.toMutableList() } + licensorEmail = embeddedMetadata.licensorEmail.map { it.toMutableList() } + licensorExtendedAddress = + embeddedMetadata.licensorExtendedAddress.map { it.toMutableList() } + licensorId = embeddedMetadata.licensorId.map { it.toMutableList() } + licensorName = embeddedMetadata.licensorName.map { it.toMutableList() } + licensorPostalCode = embeddedMetadata.licensorPostalCode.map { it.toMutableList() } + licensorRegion = embeddedMetadata.licensorRegion.map { it.toMutableList() } + licensorStreetAddress = + embeddedMetadata.licensorStreetAddress.map { it.toMutableList() } + licensorTelephone1 = embeddedMetadata.licensorTelephone1.map { it.toMutableList() } + licensorTelephone2 = embeddedMetadata.licensorTelephone2.map { it.toMutableList() } + licensorUrl = embeddedMetadata.licensorUrl.map { it.toMutableList() } + linkedEncodedRightsExpr = embeddedMetadata.linkedEncodedRightsExpr + linkedEncodedRightsExprLangId = embeddedMetadata.linkedEncodedRightsExprLangId + linkedEncodedRightsExprType = embeddedMetadata.linkedEncodedRightsExprType + location = embeddedMetadata.location + locationCreatedCity = embeddedMetadata.locationCreatedCity + locationCreatedCountryCode = embeddedMetadata.locationCreatedCountryCode + locationCreatedCountryName = embeddedMetadata.locationCreatedCountryName + locationCreatedGpsAltitude = embeddedMetadata.locationCreatedGpsAltitude + locationCreatedGpsLatitude = embeddedMetadata.locationCreatedGpsLatitude + locationCreatedGpsLongitude = embeddedMetadata.locationCreatedGpsLongitude + locationCreatedLocationId = embeddedMetadata.locationCreatedLocationId + locationCreatedLocationName = embeddedMetadata.locationCreatedLocationName + locationCreatedProvinceState = embeddedMetadata.locationCreatedProvinceState + locationCreatedSublocation = embeddedMetadata.locationCreatedSublocation + locationCreatedWorldRegion = embeddedMetadata.locationCreatedWorldRegion + locationShownCity = embeddedMetadata.locationShownCity.map { it.toMutableList() } + locationShownCountryCode = + embeddedMetadata.locationShownCountryCode.map { it.toMutableList() } + locationShownCountryName = + embeddedMetadata.locationShownCountryName.map { it.toMutableList() } + locationShownGpsAltitude = + embeddedMetadata.locationShownGpsAltitude.map { it.toMutableList() } + locationShownGpsLatitude = + embeddedMetadata.locationShownGpsLatitude.map { it.toMutableList() } + locationShownGpsLongitude = + embeddedMetadata.locationShownGpsLongitude.map { it.toMutableList() } + locationShownLocationId = + embeddedMetadata.locationShownLocationId.map { it.toMutableList() } + locationShownLocationName = + embeddedMetadata.locationShownLocationName.map { it.toMutableList() } + locationShownProvinceState = + embeddedMetadata.locationShownProvinceState.map { it.toMutableList() } + locationShownSublocation = + embeddedMetadata.locationShownSublocation.map { it.toMutableList() } + locationShownWorldRegion = + embeddedMetadata.locationShownWorldRegion.map { it.toMutableList() } + maxAvailHeight = embeddedMetadata.maxAvailHeight + maxAvailWidth = embeddedMetadata.maxAvailWidth + modelAge = embeddedMetadata.modelAge.map { it.toMutableList() } + modelReleaseId = embeddedMetadata.modelReleaseId.map { it.toMutableList() } + objectAttributeReference = embeddedMetadata.objectAttributeReference + objectName = embeddedMetadata.objectName + offsetTimeOriginal = embeddedMetadata.offsetTimeOriginal + organisationInImageCode = + embeddedMetadata.organisationInImageCode.map { it.toMutableList() } + organisationInImageName = + embeddedMetadata.organisationInImageName.map { it.toMutableList() } + orientation = embeddedMetadata.orientation + originalTransmissionReference = embeddedMetadata.originalTransmissionReference + personInImage = embeddedMetadata.personInImage.map { it.toMutableList() } + personInImageCvTermCvId = + embeddedMetadata.personInImageCvTermCvId.map { it.toMutableList() } + personInImageCvTermId = + embeddedMetadata.personInImageCvTermId.map { it.toMutableList() } + personInImageCvTermName = + embeddedMetadata.personInImageCvTermName.map { it.toMutableList() } + personInImageCvTermRefinedAbout = + embeddedMetadata.personInImageCvTermRefinedAbout.map { it.toMutableList() } + personInImageDescription = + embeddedMetadata.personInImageDescription.map { it.toMutableList() } + personInImageId = embeddedMetadata.personInImageId.map { it.toMutableList() } + personInImageName = embeddedMetadata.personInImageName.map { it.toMutableList() } + productInImageDescription = + embeddedMetadata.productInImageDescription.map { it.toMutableList() } + productInImageGtin = embeddedMetadata.productInImageGtin.map { it.toMutableList() } + productInImageName = embeddedMetadata.productInImageName.map { it.toMutableList() } + propertyReleaseId = embeddedMetadata.propertyReleaseId.map { it.toMutableList() } + provinceState = embeddedMetadata.provinceState + rating = embeddedMetadata.rating + registryEntryRole = embeddedMetadata.registryEntryRole.map { it.toMutableList() } + registryItemId = embeddedMetadata.registryItemId.map { it.toMutableList() } + registryOrganisationId = + embeddedMetadata.registryOrganisationId.map { it.toMutableList() } + resolutionUnit = embeddedMetadata.resolutionUnit + rights = embeddedMetadata.rights + scene = embeddedMetadata.scene.map { it.toMutableList() } + source = embeddedMetadata.source + specialInstructions = embeddedMetadata.specialInstructions + state = embeddedMetadata.state + subject = embeddedMetadata.subject.map { it.toMutableList() } + subjectCode = embeddedMetadata.subjectCode.map { it.toMutableList() } + subjectReference = embeddedMetadata.subjectReference.map { it.toMutableList() } + sublocation = embeddedMetadata.sublocation + timeCreated = embeddedMetadata.timeCreated + title = embeddedMetadata.title + transmissionReference = embeddedMetadata.transmissionReference + usageTerms = embeddedMetadata.usageTerms + webStatement = embeddedMetadata.webStatement + writer = embeddedMetadata.writer + writerEditor = embeddedMetadata.writerEditor + xResolution = embeddedMetadata.xResolution + yResolution = embeddedMetadata.yResolution + additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() + } + + fun aboutCvTermCvId(aboutCvTermCvId: String) = + aboutCvTermCvId(JsonField.of(aboutCvTermCvId)) + + /** + * Sets [Builder.aboutCvTermCvId] to an arbitrary JSON value. + * + * You should usually call [Builder.aboutCvTermCvId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aboutCvTermCvId(aboutCvTermCvId: JsonField) = apply { + this.aboutCvTermCvId = aboutCvTermCvId + } + + fun aboutCvTermId(aboutCvTermId: String) = aboutCvTermId(JsonField.of(aboutCvTermId)) + + /** + * Sets [Builder.aboutCvTermId] to an arbitrary JSON value. + * + * You should usually call [Builder.aboutCvTermId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aboutCvTermId(aboutCvTermId: JsonField) = apply { + this.aboutCvTermId = aboutCvTermId + } + + fun aboutCvTermName(aboutCvTermName: String) = + aboutCvTermName(JsonField.of(aboutCvTermName)) + + /** + * Sets [Builder.aboutCvTermName] to an arbitrary JSON value. + * + * You should usually call [Builder.aboutCvTermName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aboutCvTermName(aboutCvTermName: JsonField) = apply { + this.aboutCvTermName = aboutCvTermName + } + + fun aboutCvTermRefinedAbout(aboutCvTermRefinedAbout: String) = + aboutCvTermRefinedAbout(JsonField.of(aboutCvTermRefinedAbout)) + + /** + * Sets [Builder.aboutCvTermRefinedAbout] to an arbitrary JSON value. + * + * You should usually call [Builder.aboutCvTermRefinedAbout] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun aboutCvTermRefinedAbout(aboutCvTermRefinedAbout: JsonField) = apply { + this.aboutCvTermRefinedAbout = aboutCvTermRefinedAbout + } + + fun additionalModelInformation(additionalModelInformation: String) = + additionalModelInformation(JsonField.of(additionalModelInformation)) + + /** + * Sets [Builder.additionalModelInformation] to an arbitrary JSON value. + * + * You should usually call [Builder.additionalModelInformation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun additionalModelInformation(additionalModelInformation: JsonField) = apply { + this.additionalModelInformation = additionalModelInformation + } + + fun applicationRecordVersion(applicationRecordVersion: Long) = + applicationRecordVersion(JsonField.of(applicationRecordVersion)) + + /** + * Sets [Builder.applicationRecordVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.applicationRecordVersion] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun applicationRecordVersion(applicationRecordVersion: JsonField) = apply { + this.applicationRecordVersion = applicationRecordVersion + } + + fun artist(artist: String) = artist(JsonField.of(artist)) + + /** + * Sets [Builder.artist] to an arbitrary JSON value. + * + * You should usually call [Builder.artist] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artist(artist: JsonField) = apply { this.artist = artist } + + fun artworkCircaDateCreated(artworkCircaDateCreated: String) = + artworkCircaDateCreated(JsonField.of(artworkCircaDateCreated)) + + /** + * Sets [Builder.artworkCircaDateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCircaDateCreated] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCircaDateCreated(artworkCircaDateCreated: JsonField) = apply { + this.artworkCircaDateCreated = artworkCircaDateCreated + } + + fun artworkContentDescription(artworkContentDescription: String) = + artworkContentDescription(JsonField.of(artworkContentDescription)) + + /** + * Sets [Builder.artworkContentDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkContentDescription] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkContentDescription(artworkContentDescription: JsonField) = apply { + this.artworkContentDescription = artworkContentDescription + } + + fun artworkContributionDescription(artworkContributionDescription: String) = + artworkContributionDescription(JsonField.of(artworkContributionDescription)) + + /** + * Sets [Builder.artworkContributionDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkContributionDescription] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkContributionDescription(artworkContributionDescription: JsonField) = + apply { + this.artworkContributionDescription = artworkContributionDescription + } + + fun artworkCopyrightNotice(artworkCopyrightNotice: String) = + artworkCopyrightNotice(JsonField.of(artworkCopyrightNotice)) + + /** + * Sets [Builder.artworkCopyrightNotice] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCopyrightNotice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCopyrightNotice(artworkCopyrightNotice: JsonField) = apply { + this.artworkCopyrightNotice = artworkCopyrightNotice + } + + fun artworkCopyrightOwnerId(artworkCopyrightOwnerId: String) = + artworkCopyrightOwnerId(JsonField.of(artworkCopyrightOwnerId)) + + /** + * Sets [Builder.artworkCopyrightOwnerId] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCopyrightOwnerId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCopyrightOwnerId(artworkCopyrightOwnerId: JsonField) = apply { + this.artworkCopyrightOwnerId = artworkCopyrightOwnerId + } + + fun artworkCopyrightOwnerName(artworkCopyrightOwnerName: String) = + artworkCopyrightOwnerName(JsonField.of(artworkCopyrightOwnerName)) + + /** + * Sets [Builder.artworkCopyrightOwnerName] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCopyrightOwnerName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkCopyrightOwnerName(artworkCopyrightOwnerName: JsonField) = apply { + this.artworkCopyrightOwnerName = artworkCopyrightOwnerName + } + + fun artworkCreator(artworkCreator: List) = + artworkCreator(JsonField.of(artworkCreator)) + + /** + * Sets [Builder.artworkCreator] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCreator] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCreator(artworkCreator: JsonField>) = apply { + this.artworkCreator = artworkCreator.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.artworkCreator]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArtworkCreator(artworkCreator: String) = apply { + this.artworkCreator = + (this.artworkCreator ?: JsonField.of(mutableListOf())).also { + checkKnown("artworkCreator", it).add(artworkCreator) + } + } + + fun artworkCreatorId(artworkCreatorId: List) = + artworkCreatorId(JsonField.of(artworkCreatorId)) + + /** + * Sets [Builder.artworkCreatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCreatorId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCreatorId(artworkCreatorId: JsonField>) = apply { + this.artworkCreatorId = artworkCreatorId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.artworkCreatorId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArtworkCreatorId(artworkCreatorId: String) = apply { + this.artworkCreatorId = + (this.artworkCreatorId ?: JsonField.of(mutableListOf())).also { + checkKnown("artworkCreatorId", it).add(artworkCreatorId) + } + } + + fun artworkDateCreated(artworkDateCreated: OffsetDateTime) = + artworkDateCreated(JsonField.of(artworkDateCreated)) + + /** + * Sets [Builder.artworkDateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkDateCreated] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkDateCreated(artworkDateCreated: JsonField) = apply { + this.artworkDateCreated = artworkDateCreated + } + + fun artworkLicensorId(artworkLicensorId: String) = + artworkLicensorId(JsonField.of(artworkLicensorId)) + + /** + * Sets [Builder.artworkLicensorId] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkLicensorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artworkLicensorId(artworkLicensorId: JsonField) = apply { + this.artworkLicensorId = artworkLicensorId + } + + fun artworkLicensorName(artworkLicensorName: String) = + artworkLicensorName(JsonField.of(artworkLicensorName)) + + /** + * Sets [Builder.artworkLicensorName] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkLicensorName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkLicensorName(artworkLicensorName: JsonField) = apply { + this.artworkLicensorName = artworkLicensorName + } + + fun artworkPhysicalDescription(artworkPhysicalDescription: String) = + artworkPhysicalDescription(JsonField.of(artworkPhysicalDescription)) + + /** + * Sets [Builder.artworkPhysicalDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkPhysicalDescription] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkPhysicalDescription(artworkPhysicalDescription: JsonField) = apply { + this.artworkPhysicalDescription = artworkPhysicalDescription + } + + fun artworkSource(artworkSource: String) = artworkSource(JsonField.of(artworkSource)) + + /** + * Sets [Builder.artworkSource] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkSource] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artworkSource(artworkSource: JsonField) = apply { + this.artworkSource = artworkSource + } + + fun artworkSourceInventoryNo(artworkSourceInventoryNo: String) = + artworkSourceInventoryNo(JsonField.of(artworkSourceInventoryNo)) + + /** + * Sets [Builder.artworkSourceInventoryNo] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkSourceInventoryNo] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkSourceInventoryNo(artworkSourceInventoryNo: JsonField) = apply { + this.artworkSourceInventoryNo = artworkSourceInventoryNo + } + + fun artworkSourceInvUrl(artworkSourceInvUrl: String) = + artworkSourceInvUrl(JsonField.of(artworkSourceInvUrl)) + + /** + * Sets [Builder.artworkSourceInvUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkSourceInvUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkSourceInvUrl(artworkSourceInvUrl: JsonField) = apply { + this.artworkSourceInvUrl = artworkSourceInvUrl + } + + fun artworkStylePeriod(artworkStylePeriod: List) = + artworkStylePeriod(JsonField.of(artworkStylePeriod)) + + /** + * Sets [Builder.artworkStylePeriod] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkStylePeriod] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkStylePeriod(artworkStylePeriod: JsonField>) = apply { + this.artworkStylePeriod = artworkStylePeriod.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.artworkStylePeriod]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArtworkStylePeriod(artworkStylePeriod: String) = apply { + this.artworkStylePeriod = + (this.artworkStylePeriod ?: JsonField.of(mutableListOf())).also { + checkKnown("artworkStylePeriod", it).add(artworkStylePeriod) + } + } + + fun artworkTitle(artworkTitle: String) = artworkTitle(JsonField.of(artworkTitle)) + + /** + * Sets [Builder.artworkTitle] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkTitle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artworkTitle(artworkTitle: JsonField) = apply { + this.artworkTitle = artworkTitle + } + + fun authorsPosition(authorsPosition: String) = + authorsPosition(JsonField.of(authorsPosition)) + + /** + * Sets [Builder.authorsPosition] to an arbitrary JSON value. + * + * You should usually call [Builder.authorsPosition] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authorsPosition(authorsPosition: JsonField) = apply { + this.authorsPosition = authorsPosition + } + + fun byline(byline: String) = byline(JsonField.of(byline)) + + /** + * Sets [Builder.byline] to an arbitrary JSON value. + * + * You should usually call [Builder.byline] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun byline(byline: JsonField) = apply { this.byline = byline } + + fun bylineTitle(bylineTitle: String) = bylineTitle(JsonField.of(bylineTitle)) + + /** + * Sets [Builder.bylineTitle] to an arbitrary JSON value. + * + * You should usually call [Builder.bylineTitle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bylineTitle(bylineTitle: JsonField) = apply { + this.bylineTitle = bylineTitle + } + + fun caption(caption: String) = caption(JsonField.of(caption)) + + /** + * Sets [Builder.caption] to an arbitrary JSON value. + * + * You should usually call [Builder.caption] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caption(caption: JsonField) = apply { this.caption = caption } + + fun captionAbstract(captionAbstract: String) = + captionAbstract(JsonField.of(captionAbstract)) + + /** + * Sets [Builder.captionAbstract] to an arbitrary JSON value. + * + * You should usually call [Builder.captionAbstract] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun captionAbstract(captionAbstract: JsonField) = apply { + this.captionAbstract = captionAbstract + } + + fun captionWriter(captionWriter: String) = captionWriter(JsonField.of(captionWriter)) + + /** + * Sets [Builder.captionWriter] to an arbitrary JSON value. + * + * You should usually call [Builder.captionWriter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun captionWriter(captionWriter: JsonField) = apply { + this.captionWriter = captionWriter + } + + fun city(city: String) = city(JsonField.of(city)) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun city(city: JsonField) = apply { this.city = city } + + fun colorSpace(colorSpace: String) = colorSpace(JsonField.of(colorSpace)) + + /** + * Sets [Builder.colorSpace] to an arbitrary JSON value. + * + * You should usually call [Builder.colorSpace] with a well-typed [String] 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 componentsConfiguration(componentsConfiguration: String) = + componentsConfiguration(JsonField.of(componentsConfiguration)) + + /** + * Sets [Builder.componentsConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.componentsConfiguration] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun componentsConfiguration(componentsConfiguration: JsonField) = apply { + this.componentsConfiguration = componentsConfiguration + } + + fun copyright(copyright: String) = copyright(JsonField.of(copyright)) + + /** + * Sets [Builder.copyright] to an arbitrary JSON value. + * + * You should usually call [Builder.copyright] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun copyright(copyright: JsonField) = apply { this.copyright = copyright } + + fun copyrightNotice(copyrightNotice: String) = + copyrightNotice(JsonField.of(copyrightNotice)) + + /** + * Sets [Builder.copyrightNotice] to an arbitrary JSON value. + * + * You should usually call [Builder.copyrightNotice] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun copyrightNotice(copyrightNotice: JsonField) = apply { + this.copyrightNotice = copyrightNotice + } + + fun copyrightOwnerId(copyrightOwnerId: List) = + copyrightOwnerId(JsonField.of(copyrightOwnerId)) + + /** + * Sets [Builder.copyrightOwnerId] to an arbitrary JSON value. + * + * You should usually call [Builder.copyrightOwnerId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun copyrightOwnerId(copyrightOwnerId: JsonField>) = apply { + this.copyrightOwnerId = copyrightOwnerId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.copyrightOwnerId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCopyrightOwnerId(copyrightOwnerId: String) = apply { + this.copyrightOwnerId = + (this.copyrightOwnerId ?: JsonField.of(mutableListOf())).also { + checkKnown("copyrightOwnerId", it).add(copyrightOwnerId) + } + } + + fun copyrightOwnerName(copyrightOwnerName: List) = + copyrightOwnerName(JsonField.of(copyrightOwnerName)) + + /** + * Sets [Builder.copyrightOwnerName] to an arbitrary JSON value. + * + * You should usually call [Builder.copyrightOwnerName] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun copyrightOwnerName(copyrightOwnerName: JsonField>) = apply { + this.copyrightOwnerName = copyrightOwnerName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.copyrightOwnerName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCopyrightOwnerName(copyrightOwnerName: String) = apply { + this.copyrightOwnerName = + (this.copyrightOwnerName ?: JsonField.of(mutableListOf())).also { + checkKnown("copyrightOwnerName", it).add(copyrightOwnerName) + } + } + + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + fun countryCode(countryCode: String) = countryCode(JsonField.of(countryCode)) + + /** + * Sets [Builder.countryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.countryCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun countryCode(countryCode: JsonField) = apply { + this.countryCode = countryCode + } + + fun countryPrimaryLocationCode(countryPrimaryLocationCode: String) = + countryPrimaryLocationCode(JsonField.of(countryPrimaryLocationCode)) + + /** + * Sets [Builder.countryPrimaryLocationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.countryPrimaryLocationCode] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun countryPrimaryLocationCode(countryPrimaryLocationCode: JsonField) = apply { + this.countryPrimaryLocationCode = countryPrimaryLocationCode + } + + fun countryPrimaryLocationName(countryPrimaryLocationName: String) = + countryPrimaryLocationName(JsonField.of(countryPrimaryLocationName)) + + /** + * Sets [Builder.countryPrimaryLocationName] to an arbitrary JSON value. + * + * You should usually call [Builder.countryPrimaryLocationName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun countryPrimaryLocationName(countryPrimaryLocationName: JsonField) = apply { + this.countryPrimaryLocationName = countryPrimaryLocationName + } + + fun creator(creator: String) = creator(JsonField.of(creator)) + + /** + * Sets [Builder.creator] to an arbitrary JSON value. + * + * You should usually call [Builder.creator] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creator(creator: JsonField) = apply { this.creator = creator } + + fun creatorAddress(creatorAddress: String) = + creatorAddress(JsonField.of(creatorAddress)) + + /** + * Sets [Builder.creatorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorAddress(creatorAddress: JsonField) = apply { + this.creatorAddress = creatorAddress + } + + fun creatorCity(creatorCity: String) = creatorCity(JsonField.of(creatorCity)) + + /** + * Sets [Builder.creatorCity] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorCity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorCity(creatorCity: JsonField) = apply { + this.creatorCity = creatorCity + } + + fun creatorCountry(creatorCountry: String) = + creatorCountry(JsonField.of(creatorCountry)) + + /** + * Sets [Builder.creatorCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorCountry] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorCountry(creatorCountry: JsonField) = apply { + this.creatorCountry = creatorCountry + } + + fun creatorPostalCode(creatorPostalCode: String) = + creatorPostalCode(JsonField.of(creatorPostalCode)) + + /** + * Sets [Builder.creatorPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorPostalCode(creatorPostalCode: JsonField) = apply { + this.creatorPostalCode = creatorPostalCode + } + + fun creatorRegion(creatorRegion: String) = creatorRegion(JsonField.of(creatorRegion)) + + /** + * Sets [Builder.creatorRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorRegion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorRegion(creatorRegion: JsonField) = apply { + this.creatorRegion = creatorRegion + } + + fun creatorWorkEmail(creatorWorkEmail: String) = + creatorWorkEmail(JsonField.of(creatorWorkEmail)) + + /** + * Sets [Builder.creatorWorkEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorWorkEmail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorWorkEmail(creatorWorkEmail: JsonField) = apply { + this.creatorWorkEmail = creatorWorkEmail + } + + fun creatorWorkTelephone(creatorWorkTelephone: String) = + creatorWorkTelephone(JsonField.of(creatorWorkTelephone)) + + /** + * Sets [Builder.creatorWorkTelephone] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorWorkTelephone] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creatorWorkTelephone(creatorWorkTelephone: JsonField) = apply { + this.creatorWorkTelephone = creatorWorkTelephone + } + + fun creatorWorkUrl(creatorWorkUrl: String) = + creatorWorkUrl(JsonField.of(creatorWorkUrl)) + + /** + * Sets [Builder.creatorWorkUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorWorkUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorWorkUrl(creatorWorkUrl: JsonField) = apply { + this.creatorWorkUrl = creatorWorkUrl + } + + fun credit(credit: String) = credit(JsonField.of(credit)) + + /** + * Sets [Builder.credit] to an arbitrary JSON value. + * + * You should usually call [Builder.credit] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credit(credit: JsonField) = apply { this.credit = credit } + + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + fun dateTimeCreated(dateTimeCreated: OffsetDateTime) = + dateTimeCreated(JsonField.of(dateTimeCreated)) + + /** + * Sets [Builder.dateTimeCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateTimeCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateTimeCreated(dateTimeCreated: JsonField) = apply { + this.dateTimeCreated = dateTimeCreated + } + + fun dateTimeOriginal(dateTimeOriginal: OffsetDateTime) = + dateTimeOriginal(JsonField.of(dateTimeOriginal)) + + /** + * Sets [Builder.dateTimeOriginal] to an arbitrary JSON value. + * + * You should usually call [Builder.dateTimeOriginal] with a well-typed [OffsetDateTime] + * 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 description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun digitalImageGuid(digitalImageGuid: String) = + digitalImageGuid(JsonField.of(digitalImageGuid)) + + /** + * Sets [Builder.digitalImageGuid] to an arbitrary JSON value. + * + * You should usually call [Builder.digitalImageGuid] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun digitalImageGuid(digitalImageGuid: JsonField) = apply { + this.digitalImageGuid = digitalImageGuid + } + + fun digitalSourceType(digitalSourceType: String) = + digitalSourceType(JsonField.of(digitalSourceType)) + + /** + * Sets [Builder.digitalSourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.digitalSourceType] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun digitalSourceType(digitalSourceType: JsonField) = apply { + this.digitalSourceType = digitalSourceType + } + + fun embeddedEncodedRightsExpr(embeddedEncodedRightsExpr: String) = + embeddedEncodedRightsExpr(JsonField.of(embeddedEncodedRightsExpr)) + + /** + * Sets [Builder.embeddedEncodedRightsExpr] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedEncodedRightsExpr] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun embeddedEncodedRightsExpr(embeddedEncodedRightsExpr: JsonField) = apply { + this.embeddedEncodedRightsExpr = embeddedEncodedRightsExpr + } + + fun embeddedEncodedRightsExprLangId(embeddedEncodedRightsExprLangId: String) = + embeddedEncodedRightsExprLangId(JsonField.of(embeddedEncodedRightsExprLangId)) + + /** + * Sets [Builder.embeddedEncodedRightsExprLangId] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedEncodedRightsExprLangId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun embeddedEncodedRightsExprLangId( + embeddedEncodedRightsExprLangId: JsonField + ) = apply { this.embeddedEncodedRightsExprLangId = embeddedEncodedRightsExprLangId } + + fun embeddedEncodedRightsExprType(embeddedEncodedRightsExprType: String) = + embeddedEncodedRightsExprType(JsonField.of(embeddedEncodedRightsExprType)) + + /** + * Sets [Builder.embeddedEncodedRightsExprType] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedEncodedRightsExprType] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun embeddedEncodedRightsExprType(embeddedEncodedRightsExprType: JsonField) = + apply { + this.embeddedEncodedRightsExprType = embeddedEncodedRightsExprType + } + + fun event(event: String) = event(JsonField.of(event)) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + 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 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 genreCvId(genreCvId: String) = genreCvId(JsonField.of(genreCvId)) + + /** + * Sets [Builder.genreCvId] to an arbitrary JSON value. + * + * You should usually call [Builder.genreCvId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun genreCvId(genreCvId: JsonField) = apply { this.genreCvId = genreCvId } + + fun genreCvTermId(genreCvTermId: String) = genreCvTermId(JsonField.of(genreCvTermId)) + + /** + * Sets [Builder.genreCvTermId] to an arbitrary JSON value. + * + * You should usually call [Builder.genreCvTermId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun genreCvTermId(genreCvTermId: JsonField) = apply { + this.genreCvTermId = genreCvTermId + } + + fun genreCvTermName(genreCvTermName: String) = + genreCvTermName(JsonField.of(genreCvTermName)) + + /** + * Sets [Builder.genreCvTermName] to an arbitrary JSON value. + * + * You should usually call [Builder.genreCvTermName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun genreCvTermName(genreCvTermName: JsonField) = apply { + this.genreCvTermName = genreCvTermName + } + + fun genreCvTermRefinedAbout(genreCvTermRefinedAbout: String) = + genreCvTermRefinedAbout(JsonField.of(genreCvTermRefinedAbout)) + + /** + * Sets [Builder.genreCvTermRefinedAbout] to an arbitrary JSON value. + * + * You should usually call [Builder.genreCvTermRefinedAbout] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun genreCvTermRefinedAbout(genreCvTermRefinedAbout: JsonField) = apply { + this.genreCvTermRefinedAbout = genreCvTermRefinedAbout + } + + fun headline(headline: String) = headline(JsonField.of(headline)) + + /** + * Sets [Builder.headline] to an arbitrary JSON value. + * + * You should usually call [Builder.headline] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun headline(headline: JsonField) = apply { this.headline = headline } + + fun imageCreatorId(imageCreatorId: String) = + imageCreatorId(JsonField.of(imageCreatorId)) + + /** + * Sets [Builder.imageCreatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageCreatorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageCreatorId(imageCreatorId: JsonField) = apply { + this.imageCreatorId = imageCreatorId + } + + fun imageCreatorImageId(imageCreatorImageId: String) = + imageCreatorImageId(JsonField.of(imageCreatorImageId)) + + /** + * Sets [Builder.imageCreatorImageId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageCreatorImageId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageCreatorImageId(imageCreatorImageId: JsonField) = apply { + this.imageCreatorImageId = imageCreatorImageId + } + + fun imageCreatorName(imageCreatorName: String) = + imageCreatorName(JsonField.of(imageCreatorName)) + + /** + * Sets [Builder.imageCreatorName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageCreatorName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageCreatorName(imageCreatorName: JsonField) = apply { + this.imageCreatorName = imageCreatorName + } + + fun imageDescription(imageDescription: String) = + imageDescription(JsonField.of(imageDescription)) + + /** + * Sets [Builder.imageDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.imageDescription] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageDescription(imageDescription: JsonField) = apply { + this.imageDescription = imageDescription + } + + fun imageRegionBoundaryH(imageRegionBoundaryH: List) = + imageRegionBoundaryH(JsonField.of(imageRegionBoundaryH)) + + /** + * Sets [Builder.imageRegionBoundaryH] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryH] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryH(imageRegionBoundaryH: JsonField>) = apply { + this.imageRegionBoundaryH = imageRegionBoundaryH.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryH]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryH(imageRegionBoundaryH: Double) = apply { + this.imageRegionBoundaryH = + (this.imageRegionBoundaryH ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryH", it).add(imageRegionBoundaryH) + } + } + + fun imageRegionBoundaryRx(imageRegionBoundaryRx: List) = + imageRegionBoundaryRx(JsonField.of(imageRegionBoundaryRx)) + + /** + * Sets [Builder.imageRegionBoundaryRx] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryRx] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryRx(imageRegionBoundaryRx: JsonField>) = apply { + this.imageRegionBoundaryRx = imageRegionBoundaryRx.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryRx]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryRx(imageRegionBoundaryRx: Double) = apply { + this.imageRegionBoundaryRx = + (this.imageRegionBoundaryRx ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryRx", it).add(imageRegionBoundaryRx) + } + } + + fun imageRegionBoundaryShape(imageRegionBoundaryShape: List) = + imageRegionBoundaryShape(JsonField.of(imageRegionBoundaryShape)) + + /** + * Sets [Builder.imageRegionBoundaryShape] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryShape] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryShape(imageRegionBoundaryShape: JsonField>) = + apply { + this.imageRegionBoundaryShape = + imageRegionBoundaryShape.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionBoundaryShape]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryShape(imageRegionBoundaryShape: String) = apply { + this.imageRegionBoundaryShape = + (this.imageRegionBoundaryShape ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryShape", it).add(imageRegionBoundaryShape) + } + } + + fun imageRegionBoundaryUnit(imageRegionBoundaryUnit: List) = + imageRegionBoundaryUnit(JsonField.of(imageRegionBoundaryUnit)) + + /** + * Sets [Builder.imageRegionBoundaryUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryUnit] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryUnit(imageRegionBoundaryUnit: JsonField>) = apply { + this.imageRegionBoundaryUnit = imageRegionBoundaryUnit.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionBoundaryUnit]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryUnit(imageRegionBoundaryUnit: String) = apply { + this.imageRegionBoundaryUnit = + (this.imageRegionBoundaryUnit ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryUnit", it).add(imageRegionBoundaryUnit) + } + } + + fun imageRegionBoundaryVerticesX(imageRegionBoundaryVerticesX: List) = + imageRegionBoundaryVerticesX(JsonField.of(imageRegionBoundaryVerticesX)) + + /** + * Sets [Builder.imageRegionBoundaryVerticesX] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryVerticesX] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryVerticesX( + imageRegionBoundaryVerticesX: JsonField> + ) = apply { + this.imageRegionBoundaryVerticesX = + imageRegionBoundaryVerticesX.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryVerticesX]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryVerticesX(imageRegionBoundaryVerticesX: Double) = apply { + this.imageRegionBoundaryVerticesX = + (this.imageRegionBoundaryVerticesX ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryVerticesX", it) + .add(imageRegionBoundaryVerticesX) + } + } + + fun imageRegionBoundaryVerticesY(imageRegionBoundaryVerticesY: List) = + imageRegionBoundaryVerticesY(JsonField.of(imageRegionBoundaryVerticesY)) + + /** + * Sets [Builder.imageRegionBoundaryVerticesY] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryVerticesY] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryVerticesY( + imageRegionBoundaryVerticesY: JsonField> + ) = apply { + this.imageRegionBoundaryVerticesY = + imageRegionBoundaryVerticesY.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryVerticesY]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryVerticesY(imageRegionBoundaryVerticesY: Double) = apply { + this.imageRegionBoundaryVerticesY = + (this.imageRegionBoundaryVerticesY ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryVerticesY", it) + .add(imageRegionBoundaryVerticesY) + } + } + + fun imageRegionBoundaryW(imageRegionBoundaryW: List) = + imageRegionBoundaryW(JsonField.of(imageRegionBoundaryW)) + + /** + * Sets [Builder.imageRegionBoundaryW] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryW] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryW(imageRegionBoundaryW: JsonField>) = apply { + this.imageRegionBoundaryW = imageRegionBoundaryW.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryW]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryW(imageRegionBoundaryW: Double) = apply { + this.imageRegionBoundaryW = + (this.imageRegionBoundaryW ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryW", it).add(imageRegionBoundaryW) + } + } + + fun imageRegionBoundaryX(imageRegionBoundaryX: List) = + imageRegionBoundaryX(JsonField.of(imageRegionBoundaryX)) + + /** + * Sets [Builder.imageRegionBoundaryX] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryX] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryX(imageRegionBoundaryX: JsonField>) = apply { + this.imageRegionBoundaryX = imageRegionBoundaryX.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryX]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryX(imageRegionBoundaryX: Double) = apply { + this.imageRegionBoundaryX = + (this.imageRegionBoundaryX ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryX", it).add(imageRegionBoundaryX) + } + } + + fun imageRegionBoundaryY(imageRegionBoundaryY: List) = + imageRegionBoundaryY(JsonField.of(imageRegionBoundaryY)) + + /** + * Sets [Builder.imageRegionBoundaryY] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryY] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryY(imageRegionBoundaryY: JsonField>) = apply { + this.imageRegionBoundaryY = imageRegionBoundaryY.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryY]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryY(imageRegionBoundaryY: Double) = apply { + this.imageRegionBoundaryY = + (this.imageRegionBoundaryY ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryY", it).add(imageRegionBoundaryY) + } + } + + fun imageRegionCtypeIdentifier(imageRegionCtypeIdentifier: List) = + imageRegionCtypeIdentifier(JsonField.of(imageRegionCtypeIdentifier)) + + /** + * Sets [Builder.imageRegionCtypeIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionCtypeIdentifier] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionCtypeIdentifier(imageRegionCtypeIdentifier: JsonField>) = + apply { + this.imageRegionCtypeIdentifier = + imageRegionCtypeIdentifier.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionCtypeIdentifier]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionCtypeIdentifier(imageRegionCtypeIdentifier: String) = apply { + this.imageRegionCtypeIdentifier = + (this.imageRegionCtypeIdentifier ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionCtypeIdentifier", it).add(imageRegionCtypeIdentifier) + } + } + + fun imageRegionCtypeName(imageRegionCtypeName: List) = + imageRegionCtypeName(JsonField.of(imageRegionCtypeName)) + + /** + * Sets [Builder.imageRegionCtypeName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionCtypeName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionCtypeName(imageRegionCtypeName: JsonField>) = apply { + this.imageRegionCtypeName = imageRegionCtypeName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionCtypeName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionCtypeName(imageRegionCtypeName: String) = apply { + this.imageRegionCtypeName = + (this.imageRegionCtypeName ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionCtypeName", it).add(imageRegionCtypeName) + } + } + + fun imageRegionId(imageRegionId: List) = + imageRegionId(JsonField.of(imageRegionId)) + + /** + * Sets [Builder.imageRegionId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageRegionId(imageRegionId: JsonField>) = apply { + this.imageRegionId = imageRegionId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionId(imageRegionId: String) = apply { + this.imageRegionId = + (this.imageRegionId ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionId", it).add(imageRegionId) + } + } + + fun imageRegionName(imageRegionName: List) = + imageRegionName(JsonField.of(imageRegionName)) + + /** + * Sets [Builder.imageRegionName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionName] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageRegionName(imageRegionName: JsonField>) = apply { + this.imageRegionName = imageRegionName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionName(imageRegionName: String) = apply { + this.imageRegionName = + (this.imageRegionName ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionName", it).add(imageRegionName) + } + } + + fun imageRegionOrganisationInImageName( + imageRegionOrganisationInImageName: List + ) = imageRegionOrganisationInImageName(JsonField.of(imageRegionOrganisationInImageName)) + + /** + * Sets [Builder.imageRegionOrganisationInImageName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionOrganisationInImageName] with a + * well-typed `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun imageRegionOrganisationInImageName( + imageRegionOrganisationInImageName: JsonField> + ) = apply { + this.imageRegionOrganisationInImageName = + imageRegionOrganisationInImageName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionOrganisationInImageName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionOrganisationInImageName(imageRegionOrganisationInImageName: String) = + apply { + this.imageRegionOrganisationInImageName = + (this.imageRegionOrganisationInImageName ?: JsonField.of(mutableListOf())) + .also { + checkKnown("imageRegionOrganisationInImageName", it) + .add(imageRegionOrganisationInImageName) + } + } + + fun imageRegionPersonInImage(imageRegionPersonInImage: List) = + imageRegionPersonInImage(JsonField.of(imageRegionPersonInImage)) + + /** + * Sets [Builder.imageRegionPersonInImage] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionPersonInImage] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionPersonInImage(imageRegionPersonInImage: JsonField>) = + apply { + this.imageRegionPersonInImage = + imageRegionPersonInImage.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionPersonInImage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionPersonInImage(imageRegionPersonInImage: String) = apply { + this.imageRegionPersonInImage = + (this.imageRegionPersonInImage ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionPersonInImage", it).add(imageRegionPersonInImage) + } + } + + fun imageRegionRoleIdentifier(imageRegionRoleIdentifier: List) = + imageRegionRoleIdentifier(JsonField.of(imageRegionRoleIdentifier)) + + /** + * Sets [Builder.imageRegionRoleIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionRoleIdentifier] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionRoleIdentifier(imageRegionRoleIdentifier: JsonField>) = + apply { + this.imageRegionRoleIdentifier = + imageRegionRoleIdentifier.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionRoleIdentifier]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionRoleIdentifier(imageRegionRoleIdentifier: String) = apply { + this.imageRegionRoleIdentifier = + (this.imageRegionRoleIdentifier ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionRoleIdentifier", it).add(imageRegionRoleIdentifier) + } + } + + fun imageRegionRoleName(imageRegionRoleName: List) = + imageRegionRoleName(JsonField.of(imageRegionRoleName)) + + /** + * Sets [Builder.imageRegionRoleName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionRoleName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionRoleName(imageRegionRoleName: JsonField>) = apply { + this.imageRegionRoleName = imageRegionRoleName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionRoleName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionRoleName(imageRegionRoleName: String) = apply { + this.imageRegionRoleName = + (this.imageRegionRoleName ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionRoleName", it).add(imageRegionRoleName) + } + } + + fun imageSupplierId(imageSupplierId: String) = + imageSupplierId(JsonField.of(imageSupplierId)) + + /** + * Sets [Builder.imageSupplierId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageSupplierId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageSupplierId(imageSupplierId: JsonField) = apply { + this.imageSupplierId = imageSupplierId + } + + fun imageSupplierImageId(imageSupplierImageId: String) = + imageSupplierImageId(JsonField.of(imageSupplierImageId)) + + /** + * Sets [Builder.imageSupplierImageId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageSupplierImageId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageSupplierImageId(imageSupplierImageId: JsonField) = apply { + this.imageSupplierImageId = imageSupplierImageId + } + + fun imageSupplierName(imageSupplierName: String) = + imageSupplierName(JsonField.of(imageSupplierName)) + + /** + * Sets [Builder.imageSupplierName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageSupplierName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageSupplierName(imageSupplierName: JsonField) = apply { + this.imageSupplierName = imageSupplierName + } + + fun instructions(instructions: String) = instructions(JsonField.of(instructions)) + + /** + * Sets [Builder.instructions] to an arbitrary JSON value. + * + * You should usually call [Builder.instructions] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun instructions(instructions: JsonField) = apply { + this.instructions = instructions + } + + fun intellectualGenre(intellectualGenre: String) = + intellectualGenre(JsonField.of(intellectualGenre)) + + /** + * Sets [Builder.intellectualGenre] to an arbitrary JSON value. + * + * You should usually call [Builder.intellectualGenre] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun intellectualGenre(intellectualGenre: JsonField) = apply { + this.intellectualGenre = intellectualGenre + } + + fun keywords(keywords: List) = keywords(JsonField.of(keywords)) + + /** + * Sets [Builder.keywords] to an arbitrary JSON value. + * + * You should usually call [Builder.keywords] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun keywords(keywords: JsonField>) = apply { + this.keywords = keywords.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [keywords]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addKeyword(keyword: String) = apply { + keywords = + (keywords ?: JsonField.of(mutableListOf())).also { + checkKnown("keywords", it).add(keyword) + } + } + + fun licensorCity(licensorCity: List) = licensorCity(JsonField.of(licensorCity)) + + /** + * Sets [Builder.licensorCity] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorCity] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licensorCity(licensorCity: JsonField>) = apply { + this.licensorCity = licensorCity.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorCity]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorCity(licensorCity: String) = apply { + this.licensorCity = + (this.licensorCity ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorCity", it).add(licensorCity) + } + } + + fun licensorCountry(licensorCountry: List) = + licensorCountry(JsonField.of(licensorCountry)) + + /** + * Sets [Builder.licensorCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorCountry] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorCountry(licensorCountry: JsonField>) = apply { + this.licensorCountry = licensorCountry.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorCountry]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorCountry(licensorCountry: String) = apply { + this.licensorCountry = + (this.licensorCountry ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorCountry", it).add(licensorCountry) + } + } + + fun licensorEmail(licensorEmail: List) = + licensorEmail(JsonField.of(licensorEmail)) + + /** + * Sets [Builder.licensorEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorEmail] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorEmail(licensorEmail: JsonField>) = apply { + this.licensorEmail = licensorEmail.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorEmail]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorEmail(licensorEmail: String) = apply { + this.licensorEmail = + (this.licensorEmail ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorEmail", it).add(licensorEmail) + } + } + + fun licensorExtendedAddress(licensorExtendedAddress: List) = + licensorExtendedAddress(JsonField.of(licensorExtendedAddress)) + + /** + * Sets [Builder.licensorExtendedAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorExtendedAddress] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licensorExtendedAddress(licensorExtendedAddress: JsonField>) = apply { + this.licensorExtendedAddress = licensorExtendedAddress.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorExtendedAddress]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorExtendedAddress(licensorExtendedAddress: String) = apply { + this.licensorExtendedAddress = + (this.licensorExtendedAddress ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorExtendedAddress", it).add(licensorExtendedAddress) + } + } + + fun licensorId(licensorId: List) = licensorId(JsonField.of(licensorId)) + + /** + * Sets [Builder.licensorId] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorId] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licensorId(licensorId: JsonField>) = apply { + this.licensorId = licensorId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorId(licensorId: String) = apply { + this.licensorId = + (this.licensorId ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorId", it).add(licensorId) + } + } + + fun licensorName(licensorName: List) = licensorName(JsonField.of(licensorName)) + + /** + * Sets [Builder.licensorName] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorName] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licensorName(licensorName: JsonField>) = apply { + this.licensorName = licensorName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorName(licensorName: String) = apply { + this.licensorName = + (this.licensorName ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorName", it).add(licensorName) + } + } + + fun licensorPostalCode(licensorPostalCode: List) = + licensorPostalCode(JsonField.of(licensorPostalCode)) + + /** + * Sets [Builder.licensorPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorPostalCode] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorPostalCode(licensorPostalCode: JsonField>) = apply { + this.licensorPostalCode = licensorPostalCode.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorPostalCode]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorPostalCode(licensorPostalCode: String) = apply { + this.licensorPostalCode = + (this.licensorPostalCode ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorPostalCode", it).add(licensorPostalCode) + } + } + + fun licensorRegion(licensorRegion: List) = + licensorRegion(JsonField.of(licensorRegion)) + + /** + * Sets [Builder.licensorRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorRegion] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorRegion(licensorRegion: JsonField>) = apply { + this.licensorRegion = licensorRegion.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorRegion]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorRegion(licensorRegion: String) = apply { + this.licensorRegion = + (this.licensorRegion ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorRegion", it).add(licensorRegion) + } + } + + fun licensorStreetAddress(licensorStreetAddress: List) = + licensorStreetAddress(JsonField.of(licensorStreetAddress)) + + /** + * Sets [Builder.licensorStreetAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorStreetAddress] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licensorStreetAddress(licensorStreetAddress: JsonField>) = apply { + this.licensorStreetAddress = licensorStreetAddress.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorStreetAddress]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorStreetAddress(licensorStreetAddress: String) = apply { + this.licensorStreetAddress = + (this.licensorStreetAddress ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorStreetAddress", it).add(licensorStreetAddress) + } + } + + fun licensorTelephone1(licensorTelephone1: List) = + licensorTelephone1(JsonField.of(licensorTelephone1)) + + /** + * Sets [Builder.licensorTelephone1] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorTelephone1] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorTelephone1(licensorTelephone1: JsonField>) = apply { + this.licensorTelephone1 = licensorTelephone1.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorTelephone1]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorTelephone1(licensorTelephone1: String) = apply { + this.licensorTelephone1 = + (this.licensorTelephone1 ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorTelephone1", it).add(licensorTelephone1) + } + } + + fun licensorTelephone2(licensorTelephone2: List) = + licensorTelephone2(JsonField.of(licensorTelephone2)) + + /** + * Sets [Builder.licensorTelephone2] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorTelephone2] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorTelephone2(licensorTelephone2: JsonField>) = apply { + this.licensorTelephone2 = licensorTelephone2.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorTelephone2]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorTelephone2(licensorTelephone2: String) = apply { + this.licensorTelephone2 = + (this.licensorTelephone2 ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorTelephone2", it).add(licensorTelephone2) + } + } + + fun licensorUrl(licensorUrl: List) = licensorUrl(JsonField.of(licensorUrl)) + + /** + * Sets [Builder.licensorUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorUrl] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licensorUrl(licensorUrl: JsonField>) = apply { + this.licensorUrl = licensorUrl.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorUrl]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorUrl(licensorUrl: String) = apply { + this.licensorUrl = + (this.licensorUrl ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorUrl", it).add(licensorUrl) + } + } + + fun linkedEncodedRightsExpr(linkedEncodedRightsExpr: String) = + linkedEncodedRightsExpr(JsonField.of(linkedEncodedRightsExpr)) + + /** + * Sets [Builder.linkedEncodedRightsExpr] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedEncodedRightsExpr] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun linkedEncodedRightsExpr(linkedEncodedRightsExpr: JsonField) = apply { + this.linkedEncodedRightsExpr = linkedEncodedRightsExpr + } + + fun linkedEncodedRightsExprLangId(linkedEncodedRightsExprLangId: String) = + linkedEncodedRightsExprLangId(JsonField.of(linkedEncodedRightsExprLangId)) + + /** + * Sets [Builder.linkedEncodedRightsExprLangId] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedEncodedRightsExprLangId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun linkedEncodedRightsExprLangId(linkedEncodedRightsExprLangId: JsonField) = + apply { + this.linkedEncodedRightsExprLangId = linkedEncodedRightsExprLangId + } + + fun linkedEncodedRightsExprType(linkedEncodedRightsExprType: String) = + linkedEncodedRightsExprType(JsonField.of(linkedEncodedRightsExprType)) + + /** + * Sets [Builder.linkedEncodedRightsExprType] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedEncodedRightsExprType] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun linkedEncodedRightsExprType(linkedEncodedRightsExprType: JsonField) = + apply { + this.linkedEncodedRightsExprType = linkedEncodedRightsExprType + } + + fun location(location: String) = location(JsonField.of(location)) + + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun location(location: JsonField) = apply { this.location = location } + + fun locationCreatedCity(locationCreatedCity: String) = + locationCreatedCity(JsonField.of(locationCreatedCity)) + + /** + * Sets [Builder.locationCreatedCity] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedCity] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun locationCreatedCity(locationCreatedCity: JsonField) = apply { + this.locationCreatedCity = locationCreatedCity + } + + fun locationCreatedCountryCode(locationCreatedCountryCode: String) = + locationCreatedCountryCode(JsonField.of(locationCreatedCountryCode)) + + /** + * Sets [Builder.locationCreatedCountryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedCountryCode] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedCountryCode(locationCreatedCountryCode: JsonField) = apply { + this.locationCreatedCountryCode = locationCreatedCountryCode + } + + fun locationCreatedCountryName(locationCreatedCountryName: String) = + locationCreatedCountryName(JsonField.of(locationCreatedCountryName)) + + /** + * Sets [Builder.locationCreatedCountryName] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedCountryName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedCountryName(locationCreatedCountryName: JsonField) = apply { + this.locationCreatedCountryName = locationCreatedCountryName + } + + fun locationCreatedGpsAltitude(locationCreatedGpsAltitude: String) = + locationCreatedGpsAltitude(JsonField.of(locationCreatedGpsAltitude)) + + /** + * Sets [Builder.locationCreatedGpsAltitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedGpsAltitude] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedGpsAltitude(locationCreatedGpsAltitude: JsonField) = apply { + this.locationCreatedGpsAltitude = locationCreatedGpsAltitude + } + + fun locationCreatedGpsLatitude(locationCreatedGpsLatitude: String) = + locationCreatedGpsLatitude(JsonField.of(locationCreatedGpsLatitude)) + + /** + * Sets [Builder.locationCreatedGpsLatitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedGpsLatitude] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedGpsLatitude(locationCreatedGpsLatitude: JsonField) = apply { + this.locationCreatedGpsLatitude = locationCreatedGpsLatitude + } + + fun locationCreatedGpsLongitude(locationCreatedGpsLongitude: String) = + locationCreatedGpsLongitude(JsonField.of(locationCreatedGpsLongitude)) + + /** + * Sets [Builder.locationCreatedGpsLongitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedGpsLongitude] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedGpsLongitude(locationCreatedGpsLongitude: JsonField) = + apply { + this.locationCreatedGpsLongitude = locationCreatedGpsLongitude + } + + fun locationCreatedLocationId(locationCreatedLocationId: String) = + locationCreatedLocationId(JsonField.of(locationCreatedLocationId)) + + /** + * Sets [Builder.locationCreatedLocationId] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedLocationId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedLocationId(locationCreatedLocationId: JsonField) = apply { + this.locationCreatedLocationId = locationCreatedLocationId + } + + fun locationCreatedLocationName(locationCreatedLocationName: String) = + locationCreatedLocationName(JsonField.of(locationCreatedLocationName)) + + /** + * Sets [Builder.locationCreatedLocationName] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedLocationName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedLocationName(locationCreatedLocationName: JsonField) = + apply { + this.locationCreatedLocationName = locationCreatedLocationName + } + + fun locationCreatedProvinceState(locationCreatedProvinceState: String) = + locationCreatedProvinceState(JsonField.of(locationCreatedProvinceState)) + + /** + * Sets [Builder.locationCreatedProvinceState] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedProvinceState] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedProvinceState(locationCreatedProvinceState: JsonField) = + apply { + this.locationCreatedProvinceState = locationCreatedProvinceState + } + + fun locationCreatedSublocation(locationCreatedSublocation: String) = + locationCreatedSublocation(JsonField.of(locationCreatedSublocation)) + + /** + * Sets [Builder.locationCreatedSublocation] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedSublocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedSublocation(locationCreatedSublocation: JsonField) = apply { + this.locationCreatedSublocation = locationCreatedSublocation + } + + fun locationCreatedWorldRegion(locationCreatedWorldRegion: String) = + locationCreatedWorldRegion(JsonField.of(locationCreatedWorldRegion)) + + /** + * Sets [Builder.locationCreatedWorldRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedWorldRegion] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedWorldRegion(locationCreatedWorldRegion: JsonField) = apply { + this.locationCreatedWorldRegion = locationCreatedWorldRegion + } + + fun locationShownCity(locationShownCity: List) = + locationShownCity(JsonField.of(locationShownCity)) + + /** + * Sets [Builder.locationShownCity] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownCity] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun locationShownCity(locationShownCity: JsonField>) = apply { + this.locationShownCity = locationShownCity.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownCity]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownCity(locationShownCity: String) = apply { + this.locationShownCity = + (this.locationShownCity ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownCity", it).add(locationShownCity) + } + } + + fun locationShownCountryCode(locationShownCountryCode: List) = + locationShownCountryCode(JsonField.of(locationShownCountryCode)) + + /** + * Sets [Builder.locationShownCountryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownCountryCode] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownCountryCode(locationShownCountryCode: JsonField>) = + apply { + this.locationShownCountryCode = + locationShownCountryCode.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownCountryCode]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownCountryCode(locationShownCountryCode: String) = apply { + this.locationShownCountryCode = + (this.locationShownCountryCode ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownCountryCode", it).add(locationShownCountryCode) + } + } + + fun locationShownCountryName(locationShownCountryName: List) = + locationShownCountryName(JsonField.of(locationShownCountryName)) + + /** + * Sets [Builder.locationShownCountryName] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownCountryName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownCountryName(locationShownCountryName: JsonField>) = + apply { + this.locationShownCountryName = + locationShownCountryName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownCountryName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownCountryName(locationShownCountryName: String) = apply { + this.locationShownCountryName = + (this.locationShownCountryName ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownCountryName", it).add(locationShownCountryName) + } + } + + fun locationShownGpsAltitude(locationShownGpsAltitude: List) = + locationShownGpsAltitude(JsonField.of(locationShownGpsAltitude)) + + /** + * Sets [Builder.locationShownGpsAltitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownGpsAltitude] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownGpsAltitude(locationShownGpsAltitude: JsonField>) = + apply { + this.locationShownGpsAltitude = + locationShownGpsAltitude.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownGpsAltitude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownGpsAltitude(locationShownGpsAltitude: String) = apply { + this.locationShownGpsAltitude = + (this.locationShownGpsAltitude ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownGpsAltitude", it).add(locationShownGpsAltitude) + } + } + + fun locationShownGpsLatitude(locationShownGpsLatitude: List) = + locationShownGpsLatitude(JsonField.of(locationShownGpsLatitude)) + + /** + * Sets [Builder.locationShownGpsLatitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownGpsLatitude] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownGpsLatitude(locationShownGpsLatitude: JsonField>) = + apply { + this.locationShownGpsLatitude = + locationShownGpsLatitude.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownGpsLatitude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownGpsLatitude(locationShownGpsLatitude: String) = apply { + this.locationShownGpsLatitude = + (this.locationShownGpsLatitude ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownGpsLatitude", it).add(locationShownGpsLatitude) + } + } + + fun locationShownGpsLongitude(locationShownGpsLongitude: List) = + locationShownGpsLongitude(JsonField.of(locationShownGpsLongitude)) + + /** + * Sets [Builder.locationShownGpsLongitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownGpsLongitude] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownGpsLongitude(locationShownGpsLongitude: JsonField>) = + apply { + this.locationShownGpsLongitude = + locationShownGpsLongitude.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownGpsLongitude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownGpsLongitude(locationShownGpsLongitude: String) = apply { + this.locationShownGpsLongitude = + (this.locationShownGpsLongitude ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownGpsLongitude", it).add(locationShownGpsLongitude) + } + } + + fun locationShownLocationId(locationShownLocationId: List) = + locationShownLocationId(JsonField.of(locationShownLocationId)) + + /** + * Sets [Builder.locationShownLocationId] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownLocationId] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownLocationId(locationShownLocationId: JsonField>) = apply { + this.locationShownLocationId = locationShownLocationId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownLocationId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownLocationId(locationShownLocationId: String) = apply { + this.locationShownLocationId = + (this.locationShownLocationId ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownLocationId", it).add(locationShownLocationId) + } + } + + fun locationShownLocationName(locationShownLocationName: List) = + locationShownLocationName(JsonField.of(locationShownLocationName)) + + /** + * Sets [Builder.locationShownLocationName] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownLocationName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownLocationName(locationShownLocationName: JsonField>) = + apply { + this.locationShownLocationName = + locationShownLocationName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownLocationName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownLocationName(locationShownLocationName: String) = apply { + this.locationShownLocationName = + (this.locationShownLocationName ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownLocationName", it).add(locationShownLocationName) + } + } + + fun locationShownProvinceState(locationShownProvinceState: List) = + locationShownProvinceState(JsonField.of(locationShownProvinceState)) + + /** + * Sets [Builder.locationShownProvinceState] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownProvinceState] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownProvinceState(locationShownProvinceState: JsonField>) = + apply { + this.locationShownProvinceState = + locationShownProvinceState.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownProvinceState]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownProvinceState(locationShownProvinceState: String) = apply { + this.locationShownProvinceState = + (this.locationShownProvinceState ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownProvinceState", it).add(locationShownProvinceState) + } + } + + fun locationShownSublocation(locationShownSublocation: List) = + locationShownSublocation(JsonField.of(locationShownSublocation)) + + /** + * Sets [Builder.locationShownSublocation] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownSublocation] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownSublocation(locationShownSublocation: JsonField>) = + apply { + this.locationShownSublocation = + locationShownSublocation.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownSublocation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownSublocation(locationShownSublocation: String) = apply { + this.locationShownSublocation = + (this.locationShownSublocation ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownSublocation", it).add(locationShownSublocation) + } + } + + fun locationShownWorldRegion(locationShownWorldRegion: List) = + locationShownWorldRegion(JsonField.of(locationShownWorldRegion)) + + /** + * Sets [Builder.locationShownWorldRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownWorldRegion] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownWorldRegion(locationShownWorldRegion: JsonField>) = + apply { + this.locationShownWorldRegion = + locationShownWorldRegion.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownWorldRegion]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownWorldRegion(locationShownWorldRegion: String) = apply { + this.locationShownWorldRegion = + (this.locationShownWorldRegion ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownWorldRegion", it).add(locationShownWorldRegion) + } + } + + fun maxAvailHeight(maxAvailHeight: Double) = + maxAvailHeight(JsonField.of(maxAvailHeight)) + + /** + * Sets [Builder.maxAvailHeight] to an arbitrary JSON value. + * + * You should usually call [Builder.maxAvailHeight] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxAvailHeight(maxAvailHeight: JsonField) = apply { + this.maxAvailHeight = maxAvailHeight + } + + fun maxAvailWidth(maxAvailWidth: Double) = maxAvailWidth(JsonField.of(maxAvailWidth)) + + /** + * Sets [Builder.maxAvailWidth] to an arbitrary JSON value. + * + * You should usually call [Builder.maxAvailWidth] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxAvailWidth(maxAvailWidth: JsonField) = apply { + this.maxAvailWidth = maxAvailWidth + } + + fun modelAge(modelAge: List) = modelAge(JsonField.of(modelAge)) + + /** + * Sets [Builder.modelAge] to an arbitrary JSON value. + * + * You should usually call [Builder.modelAge] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelAge(modelAge: JsonField>) = apply { + this.modelAge = modelAge.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.modelAge]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addModelAge(modelAge: Double) = apply { + this.modelAge = + (this.modelAge ?: JsonField.of(mutableListOf())).also { + checkKnown("modelAge", it).add(modelAge) + } + } + + fun modelReleaseId(modelReleaseId: List) = + modelReleaseId(JsonField.of(modelReleaseId)) + + /** + * Sets [Builder.modelReleaseId] to an arbitrary JSON value. + * + * You should usually call [Builder.modelReleaseId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelReleaseId(modelReleaseId: JsonField>) = apply { + this.modelReleaseId = modelReleaseId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.modelReleaseId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addModelReleaseId(modelReleaseId: String) = apply { + this.modelReleaseId = + (this.modelReleaseId ?: JsonField.of(mutableListOf())).also { + checkKnown("modelReleaseId", it).add(modelReleaseId) + } + } + + fun objectAttributeReference(objectAttributeReference: String) = + objectAttributeReference(JsonField.of(objectAttributeReference)) + + /** + * Sets [Builder.objectAttributeReference] to an arbitrary JSON value. + * + * You should usually call [Builder.objectAttributeReference] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun objectAttributeReference(objectAttributeReference: JsonField) = apply { + this.objectAttributeReference = objectAttributeReference + } + + fun objectName(objectName: String) = objectName(JsonField.of(objectName)) + + /** + * Sets [Builder.objectName] to an arbitrary JSON value. + * + * You should usually call [Builder.objectName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun objectName(objectName: JsonField) = apply { this.objectName = objectName } + + fun offsetTimeOriginal(offsetTimeOriginal: String) = + offsetTimeOriginal(JsonField.of(offsetTimeOriginal)) + + /** + * Sets [Builder.offsetTimeOriginal] to an arbitrary JSON value. + * + * You should usually call [Builder.offsetTimeOriginal] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun offsetTimeOriginal(offsetTimeOriginal: JsonField) = apply { + this.offsetTimeOriginal = offsetTimeOriginal + } + + fun organisationInImageCode(organisationInImageCode: List) = + organisationInImageCode(JsonField.of(organisationInImageCode)) + + /** + * Sets [Builder.organisationInImageCode] to an arbitrary JSON value. + * + * You should usually call [Builder.organisationInImageCode] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun organisationInImageCode(organisationInImageCode: JsonField>) = apply { + this.organisationInImageCode = organisationInImageCode.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.organisationInImageCode]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOrganisationInImageCode(organisationInImageCode: String) = apply { + this.organisationInImageCode = + (this.organisationInImageCode ?: JsonField.of(mutableListOf())).also { + checkKnown("organisationInImageCode", it).add(organisationInImageCode) + } + } + + fun organisationInImageName(organisationInImageName: List) = + organisationInImageName(JsonField.of(organisationInImageName)) + + /** + * Sets [Builder.organisationInImageName] to an arbitrary JSON value. + * + * You should usually call [Builder.organisationInImageName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun organisationInImageName(organisationInImageName: JsonField>) = apply { + this.organisationInImageName = organisationInImageName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.organisationInImageName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOrganisationInImageName(organisationInImageName: String) = apply { + this.organisationInImageName = + (this.organisationInImageName ?: JsonField.of(mutableListOf())).also { + checkKnown("organisationInImageName", it).add(organisationInImageName) + } + } + + fun orientation(orientation: String) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [String] 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 originalTransmissionReference(originalTransmissionReference: String) = + originalTransmissionReference(JsonField.of(originalTransmissionReference)) + + /** + * Sets [Builder.originalTransmissionReference] to an arbitrary JSON value. + * + * You should usually call [Builder.originalTransmissionReference] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun originalTransmissionReference(originalTransmissionReference: JsonField) = + apply { + this.originalTransmissionReference = originalTransmissionReference + } + + fun personInImage(personInImage: List) = + personInImage(JsonField.of(personInImage)) + + /** + * Sets [Builder.personInImage] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImage] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun personInImage(personInImage: JsonField>) = apply { + this.personInImage = personInImage.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImage(personInImage: String) = apply { + this.personInImage = + (this.personInImage ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImage", it).add(personInImage) + } + } + + fun personInImageCvTermCvId(personInImageCvTermCvId: List) = + personInImageCvTermCvId(JsonField.of(personInImageCvTermCvId)) + + /** + * Sets [Builder.personInImageCvTermCvId] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageCvTermCvId] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageCvTermCvId(personInImageCvTermCvId: JsonField>) = apply { + this.personInImageCvTermCvId = personInImageCvTermCvId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageCvTermCvId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageCvTermCvId(personInImageCvTermCvId: String) = apply { + this.personInImageCvTermCvId = + (this.personInImageCvTermCvId ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageCvTermCvId", it).add(personInImageCvTermCvId) + } + } + + fun personInImageCvTermId(personInImageCvTermId: List) = + personInImageCvTermId(JsonField.of(personInImageCvTermId)) + + /** + * Sets [Builder.personInImageCvTermId] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageCvTermId] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageCvTermId(personInImageCvTermId: JsonField>) = apply { + this.personInImageCvTermId = personInImageCvTermId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageCvTermId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageCvTermId(personInImageCvTermId: String) = apply { + this.personInImageCvTermId = + (this.personInImageCvTermId ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageCvTermId", it).add(personInImageCvTermId) + } + } + + fun personInImageCvTermName(personInImageCvTermName: List) = + personInImageCvTermName(JsonField.of(personInImageCvTermName)) + + /** + * Sets [Builder.personInImageCvTermName] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageCvTermName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageCvTermName(personInImageCvTermName: JsonField>) = apply { + this.personInImageCvTermName = personInImageCvTermName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageCvTermName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageCvTermName(personInImageCvTermName: String) = apply { + this.personInImageCvTermName = + (this.personInImageCvTermName ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageCvTermName", it).add(personInImageCvTermName) + } + } + + fun personInImageCvTermRefinedAbout(personInImageCvTermRefinedAbout: List) = + personInImageCvTermRefinedAbout(JsonField.of(personInImageCvTermRefinedAbout)) + + /** + * Sets [Builder.personInImageCvTermRefinedAbout] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageCvTermRefinedAbout] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageCvTermRefinedAbout( + personInImageCvTermRefinedAbout: JsonField> + ) = apply { + this.personInImageCvTermRefinedAbout = + personInImageCvTermRefinedAbout.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageCvTermRefinedAbout]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageCvTermRefinedAbout(personInImageCvTermRefinedAbout: String) = + apply { + this.personInImageCvTermRefinedAbout = + (this.personInImageCvTermRefinedAbout ?: JsonField.of(mutableListOf())) + .also { + checkKnown("personInImageCvTermRefinedAbout", it) + .add(personInImageCvTermRefinedAbout) + } + } + + fun personInImageDescription(personInImageDescription: List) = + personInImageDescription(JsonField.of(personInImageDescription)) + + /** + * Sets [Builder.personInImageDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageDescription] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageDescription(personInImageDescription: JsonField>) = + apply { + this.personInImageDescription = + personInImageDescription.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageDescription]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageDescription(personInImageDescription: String) = apply { + this.personInImageDescription = + (this.personInImageDescription ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageDescription", it).add(personInImageDescription) + } + } + + fun personInImageId(personInImageId: List) = + personInImageId(JsonField.of(personInImageId)) + + /** + * Sets [Builder.personInImageId] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun personInImageId(personInImageId: JsonField>) = apply { + this.personInImageId = personInImageId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageId(personInImageId: String) = apply { + this.personInImageId = + (this.personInImageId ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageId", it).add(personInImageId) + } + } + + fun personInImageName(personInImageName: List) = + personInImageName(JsonField.of(personInImageName)) + + /** + * Sets [Builder.personInImageName] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageName] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun personInImageName(personInImageName: JsonField>) = apply { + this.personInImageName = personInImageName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageName(personInImageName: String) = apply { + this.personInImageName = + (this.personInImageName ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageName", it).add(personInImageName) + } + } + + fun productInImageDescription(productInImageDescription: List) = + productInImageDescription(JsonField.of(productInImageDescription)) + + /** + * Sets [Builder.productInImageDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.productInImageDescription] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun productInImageDescription(productInImageDescription: JsonField>) = + apply { + this.productInImageDescription = + productInImageDescription.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.productInImageDescription]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProductInImageDescription(productInImageDescription: String) = apply { + this.productInImageDescription = + (this.productInImageDescription ?: JsonField.of(mutableListOf())).also { + checkKnown("productInImageDescription", it).add(productInImageDescription) + } + } + + fun productInImageGtin(productInImageGtin: List) = + productInImageGtin(JsonField.of(productInImageGtin)) + + /** + * Sets [Builder.productInImageGtin] to an arbitrary JSON value. + * + * You should usually call [Builder.productInImageGtin] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun productInImageGtin(productInImageGtin: JsonField>) = apply { + this.productInImageGtin = productInImageGtin.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.productInImageGtin]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProductInImageGtin(productInImageGtin: Double) = apply { + this.productInImageGtin = + (this.productInImageGtin ?: JsonField.of(mutableListOf())).also { + checkKnown("productInImageGtin", it).add(productInImageGtin) + } + } + + fun productInImageName(productInImageName: List) = + productInImageName(JsonField.of(productInImageName)) + + /** + * Sets [Builder.productInImageName] to an arbitrary JSON value. + * + * You should usually call [Builder.productInImageName] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun productInImageName(productInImageName: JsonField>) = apply { + this.productInImageName = productInImageName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.productInImageName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProductInImageName(productInImageName: String) = apply { + this.productInImageName = + (this.productInImageName ?: JsonField.of(mutableListOf())).also { + checkKnown("productInImageName", it).add(productInImageName) + } + } + + fun propertyReleaseId(propertyReleaseId: List) = + propertyReleaseId(JsonField.of(propertyReleaseId)) + + /** + * Sets [Builder.propertyReleaseId] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyReleaseId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun propertyReleaseId(propertyReleaseId: JsonField>) = apply { + this.propertyReleaseId = propertyReleaseId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.propertyReleaseId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPropertyReleaseId(propertyReleaseId: String) = apply { + this.propertyReleaseId = + (this.propertyReleaseId ?: JsonField.of(mutableListOf())).also { + checkKnown("propertyReleaseId", it).add(propertyReleaseId) + } + } + + fun provinceState(provinceState: String) = provinceState(JsonField.of(provinceState)) + + /** + * Sets [Builder.provinceState] to an arbitrary JSON value. + * + * You should usually call [Builder.provinceState] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provinceState(provinceState: JsonField) = apply { + this.provinceState = provinceState + } + + fun rating(rating: Long) = rating(JsonField.of(rating)) + + /** + * Sets [Builder.rating] to an arbitrary JSON value. + * + * You should usually call [Builder.rating] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rating(rating: JsonField) = apply { this.rating = rating } + + fun registryEntryRole(registryEntryRole: List) = + registryEntryRole(JsonField.of(registryEntryRole)) + + /** + * Sets [Builder.registryEntryRole] to an arbitrary JSON value. + * + * You should usually call [Builder.registryEntryRole] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun registryEntryRole(registryEntryRole: JsonField>) = apply { + this.registryEntryRole = registryEntryRole.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.registryEntryRole]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegistryEntryRole(registryEntryRole: String) = apply { + this.registryEntryRole = + (this.registryEntryRole ?: JsonField.of(mutableListOf())).also { + checkKnown("registryEntryRole", it).add(registryEntryRole) + } + } + + fun registryItemId(registryItemId: List) = + registryItemId(JsonField.of(registryItemId)) + + /** + * Sets [Builder.registryItemId] to an arbitrary JSON value. + * + * You should usually call [Builder.registryItemId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun registryItemId(registryItemId: JsonField>) = apply { + this.registryItemId = registryItemId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.registryItemId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegistryItemId(registryItemId: String) = apply { + this.registryItemId = + (this.registryItemId ?: JsonField.of(mutableListOf())).also { + checkKnown("registryItemId", it).add(registryItemId) + } + } + + fun registryOrganisationId(registryOrganisationId: List) = + registryOrganisationId(JsonField.of(registryOrganisationId)) + + /** + * Sets [Builder.registryOrganisationId] to an arbitrary JSON value. + * + * You should usually call [Builder.registryOrganisationId] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun registryOrganisationId(registryOrganisationId: JsonField>) = apply { + this.registryOrganisationId = registryOrganisationId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.registryOrganisationId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegistryOrganisationId(registryOrganisationId: String) = apply { + this.registryOrganisationId = + (this.registryOrganisationId ?: JsonField.of(mutableListOf())).also { + checkKnown("registryOrganisationId", it).add(registryOrganisationId) + } + } + + fun resolutionUnit(resolutionUnit: String) = + resolutionUnit(JsonField.of(resolutionUnit)) + + /** + * Sets [Builder.resolutionUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.resolutionUnit] with a well-typed [String] 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 rights(rights: String) = rights(JsonField.of(rights)) + + /** + * Sets [Builder.rights] to an arbitrary JSON value. + * + * You should usually call [Builder.rights] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rights(rights: JsonField) = apply { this.rights = rights } + + fun scene(scene: List) = scene(JsonField.of(scene)) + + /** + * Sets [Builder.scene] to an arbitrary JSON value. + * + * You should usually call [Builder.scene] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scene(scene: JsonField>) = apply { + this.scene = scene.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.scene]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScene(scene: String) = apply { + this.scene = + (this.scene ?: JsonField.of(mutableListOf())).also { + checkKnown("scene", it).add(scene) + } + } + + 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 specialInstructions(specialInstructions: String) = + specialInstructions(JsonField.of(specialInstructions)) + + /** + * Sets [Builder.specialInstructions] to an arbitrary JSON value. + * + * You should usually call [Builder.specialInstructions] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun specialInstructions(specialInstructions: JsonField) = apply { + this.specialInstructions = specialInstructions + } + + fun state(state: String) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + fun subject(subject: List) = subject(JsonField.of(subject)) + + /** + * Sets [Builder.subject] to an arbitrary JSON value. + * + * You should usually call [Builder.subject] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subject(subject: JsonField>) = apply { + this.subject = subject.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.subject]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubject(subject: String) = apply { + this.subject = + (this.subject ?: JsonField.of(mutableListOf())).also { + checkKnown("subject", it).add(subject) + } + } + + fun subjectCode(subjectCode: List) = subjectCode(JsonField.of(subjectCode)) + + /** + * Sets [Builder.subjectCode] to an arbitrary JSON value. + * + * You should usually call [Builder.subjectCode] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subjectCode(subjectCode: JsonField>) = apply { + this.subjectCode = subjectCode.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.subjectCode]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubjectCode(subjectCode: String) = apply { + this.subjectCode = + (this.subjectCode ?: JsonField.of(mutableListOf())).also { + checkKnown("subjectCode", it).add(subjectCode) + } + } + + fun subjectReference(subjectReference: List) = + subjectReference(JsonField.of(subjectReference)) + + /** + * Sets [Builder.subjectReference] to an arbitrary JSON value. + * + * You should usually call [Builder.subjectReference] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun subjectReference(subjectReference: JsonField>) = apply { + this.subjectReference = subjectReference.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.subjectReference]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubjectReference(subjectReference: String) = apply { + this.subjectReference = + (this.subjectReference ?: JsonField.of(mutableListOf())).also { + checkKnown("subjectReference", it).add(subjectReference) + } + } + + fun sublocation(sublocation: String) = sublocation(JsonField.of(sublocation)) + + /** + * Sets [Builder.sublocation] to an arbitrary JSON value. + * + * You should usually call [Builder.sublocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sublocation(sublocation: JsonField) = apply { + this.sublocation = sublocation + } + + fun timeCreated(timeCreated: String) = timeCreated(JsonField.of(timeCreated)) + + /** + * Sets [Builder.timeCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.timeCreated] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeCreated(timeCreated: JsonField) = apply { + this.timeCreated = timeCreated + } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun transmissionReference(transmissionReference: String) = + transmissionReference(JsonField.of(transmissionReference)) + + /** + * Sets [Builder.transmissionReference] to an arbitrary JSON value. + * + * You should usually call [Builder.transmissionReference] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun transmissionReference(transmissionReference: JsonField) = apply { + this.transmissionReference = transmissionReference + } + + fun usageTerms(usageTerms: String) = usageTerms(JsonField.of(usageTerms)) + + /** + * Sets [Builder.usageTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.usageTerms] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun usageTerms(usageTerms: JsonField) = apply { this.usageTerms = usageTerms } + + fun webStatement(webStatement: String) = webStatement(JsonField.of(webStatement)) + + /** + * Sets [Builder.webStatement] to an arbitrary JSON value. + * + * You should usually call [Builder.webStatement] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webStatement(webStatement: JsonField) = apply { + this.webStatement = webStatement + } + + fun writer(writer: String) = writer(JsonField.of(writer)) + + /** + * Sets [Builder.writer] to an arbitrary JSON value. + * + * You should usually call [Builder.writer] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun writer(writer: JsonField) = apply { this.writer = writer } + + fun writerEditor(writerEditor: String) = writerEditor(JsonField.of(writerEditor)) + + /** + * Sets [Builder.writerEditor] to an arbitrary JSON value. + * + * You should usually call [Builder.writerEditor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun writerEditor(writerEditor: JsonField) = apply { + this.writerEditor = writerEditor + } + + fun xResolution(xResolution: Double) = xResolution(JsonField.of(xResolution)) + + /** + * Sets [Builder.xResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.xResolution] with a well-typed [Double] 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: Double) = yResolution(JsonField.of(yResolution)) + + /** + * Sets [Builder.yResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.yResolution] with a well-typed [Double] 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 [EmbeddedMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmbeddedMetadata = + EmbeddedMetadata( + aboutCvTermCvId, + aboutCvTermId, + aboutCvTermName, + aboutCvTermRefinedAbout, + additionalModelInformation, + applicationRecordVersion, + artist, + artworkCircaDateCreated, + artworkContentDescription, + artworkContributionDescription, + artworkCopyrightNotice, + artworkCopyrightOwnerId, + artworkCopyrightOwnerName, + (artworkCreator ?: JsonMissing.of()).map { it.toImmutable() }, + (artworkCreatorId ?: JsonMissing.of()).map { it.toImmutable() }, + artworkDateCreated, + artworkLicensorId, + artworkLicensorName, + artworkPhysicalDescription, + artworkSource, + artworkSourceInventoryNo, + artworkSourceInvUrl, + (artworkStylePeriod ?: JsonMissing.of()).map { it.toImmutable() }, + artworkTitle, + authorsPosition, + byline, + bylineTitle, + caption, + captionAbstract, + captionWriter, + city, + colorSpace, + componentsConfiguration, + copyright, + copyrightNotice, + (copyrightOwnerId ?: JsonMissing.of()).map { it.toImmutable() }, + (copyrightOwnerName ?: JsonMissing.of()).map { it.toImmutable() }, + country, + countryCode, + countryPrimaryLocationCode, + countryPrimaryLocationName, + creator, + creatorAddress, + creatorCity, + creatorCountry, + creatorPostalCode, + creatorRegion, + creatorWorkEmail, + creatorWorkTelephone, + creatorWorkUrl, + credit, + dateCreated, + dateTimeCreated, + dateTimeOriginal, + description, + digitalImageGuid, + digitalSourceType, + embeddedEncodedRightsExpr, + embeddedEncodedRightsExprLangId, + embeddedEncodedRightsExprType, + event, + exifVersion, + flashpixVersion, + genreCvId, + genreCvTermId, + genreCvTermName, + genreCvTermRefinedAbout, + headline, + imageCreatorId, + imageCreatorImageId, + imageCreatorName, + imageDescription, + (imageRegionBoundaryH ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryRx ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryShape ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryUnit ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryVerticesX ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryVerticesY ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryW ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryX ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryY ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionCtypeIdentifier ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionCtypeName ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionId ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionName ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionOrganisationInImageName ?: JsonMissing.of()).map { + it.toImmutable() + }, + (imageRegionPersonInImage ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionRoleIdentifier ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionRoleName ?: JsonMissing.of()).map { it.toImmutable() }, + imageSupplierId, + imageSupplierImageId, + imageSupplierName, + instructions, + intellectualGenre, + (keywords ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorCity ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorCountry ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorEmail ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorExtendedAddress ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorId ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorName ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorPostalCode ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorRegion ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorStreetAddress ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorTelephone1 ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorTelephone2 ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorUrl ?: JsonMissing.of()).map { it.toImmutable() }, + linkedEncodedRightsExpr, + linkedEncodedRightsExprLangId, + linkedEncodedRightsExprType, + location, + locationCreatedCity, + locationCreatedCountryCode, + locationCreatedCountryName, + locationCreatedGpsAltitude, + locationCreatedGpsLatitude, + locationCreatedGpsLongitude, + locationCreatedLocationId, + locationCreatedLocationName, + locationCreatedProvinceState, + locationCreatedSublocation, + locationCreatedWorldRegion, + (locationShownCity ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownCountryCode ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownCountryName ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownGpsAltitude ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownGpsLatitude ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownGpsLongitude ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownLocationId ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownLocationName ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownProvinceState ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownSublocation ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownWorldRegion ?: JsonMissing.of()).map { it.toImmutable() }, + maxAvailHeight, + maxAvailWidth, + (modelAge ?: JsonMissing.of()).map { it.toImmutable() }, + (modelReleaseId ?: JsonMissing.of()).map { it.toImmutable() }, + objectAttributeReference, + objectName, + offsetTimeOriginal, + (organisationInImageCode ?: JsonMissing.of()).map { it.toImmutable() }, + (organisationInImageName ?: JsonMissing.of()).map { it.toImmutable() }, + orientation, + originalTransmissionReference, + (personInImage ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageCvTermCvId ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageCvTermId ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageCvTermName ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageCvTermRefinedAbout ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageDescription ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageId ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageName ?: JsonMissing.of()).map { it.toImmutable() }, + (productInImageDescription ?: JsonMissing.of()).map { it.toImmutable() }, + (productInImageGtin ?: JsonMissing.of()).map { it.toImmutable() }, + (productInImageName ?: JsonMissing.of()).map { it.toImmutable() }, + (propertyReleaseId ?: JsonMissing.of()).map { it.toImmutable() }, + provinceState, + rating, + (registryEntryRole ?: JsonMissing.of()).map { it.toImmutable() }, + (registryItemId ?: JsonMissing.of()).map { it.toImmutable() }, + (registryOrganisationId ?: JsonMissing.of()).map { it.toImmutable() }, + resolutionUnit, + rights, + (scene ?: JsonMissing.of()).map { it.toImmutable() }, + source, + specialInstructions, + state, + (subject ?: JsonMissing.of()).map { it.toImmutable() }, + (subjectCode ?: JsonMissing.of()).map { it.toImmutable() }, + (subjectReference ?: JsonMissing.of()).map { it.toImmutable() }, + sublocation, + timeCreated, + title, + transmissionReference, + usageTerms, + webStatement, + writer, + writerEditor, + xResolution, + yResolution, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EmbeddedMetadata = apply { + if (validated) { + return@apply + } + + aboutCvTermCvId() + aboutCvTermId() + aboutCvTermName() + aboutCvTermRefinedAbout() + additionalModelInformation() + applicationRecordVersion() + artist() + artworkCircaDateCreated() + artworkContentDescription() + artworkContributionDescription() + artworkCopyrightNotice() + artworkCopyrightOwnerId() + artworkCopyrightOwnerName() + artworkCreator() + artworkCreatorId() + artworkDateCreated() + artworkLicensorId() + artworkLicensorName() + artworkPhysicalDescription() + artworkSource() + artworkSourceInventoryNo() + artworkSourceInvUrl() + artworkStylePeriod() + artworkTitle() + authorsPosition() + byline() + bylineTitle() + caption() + captionAbstract() + captionWriter() + city() + colorSpace() + componentsConfiguration() + copyright() + copyrightNotice() + copyrightOwnerId() + copyrightOwnerName() + country() + countryCode() + countryPrimaryLocationCode() + countryPrimaryLocationName() + creator() + creatorAddress() + creatorCity() + creatorCountry() + creatorPostalCode() + creatorRegion() + creatorWorkEmail() + creatorWorkTelephone() + creatorWorkUrl() + credit() + dateCreated() + dateTimeCreated() + dateTimeOriginal() + description() + digitalImageGuid() + digitalSourceType() + embeddedEncodedRightsExpr() + embeddedEncodedRightsExprLangId() + embeddedEncodedRightsExprType() + event() + exifVersion() + flashpixVersion() + genreCvId() + genreCvTermId() + genreCvTermName() + genreCvTermRefinedAbout() + headline() + imageCreatorId() + imageCreatorImageId() + imageCreatorName() + imageDescription() + imageRegionBoundaryH() + imageRegionBoundaryRx() + imageRegionBoundaryShape() + imageRegionBoundaryUnit() + imageRegionBoundaryVerticesX() + imageRegionBoundaryVerticesY() + imageRegionBoundaryW() + imageRegionBoundaryX() + imageRegionBoundaryY() + imageRegionCtypeIdentifier() + imageRegionCtypeName() + imageRegionId() + imageRegionName() + imageRegionOrganisationInImageName() + imageRegionPersonInImage() + imageRegionRoleIdentifier() + imageRegionRoleName() + imageSupplierId() + imageSupplierImageId() + imageSupplierName() + instructions() + intellectualGenre() + keywords() + licensorCity() + licensorCountry() + licensorEmail() + licensorExtendedAddress() + licensorId() + licensorName() + licensorPostalCode() + licensorRegion() + licensorStreetAddress() + licensorTelephone1() + licensorTelephone2() + licensorUrl() + linkedEncodedRightsExpr() + linkedEncodedRightsExprLangId() + linkedEncodedRightsExprType() + location() + locationCreatedCity() + locationCreatedCountryCode() + locationCreatedCountryName() + locationCreatedGpsAltitude() + locationCreatedGpsLatitude() + locationCreatedGpsLongitude() + locationCreatedLocationId() + locationCreatedLocationName() + locationCreatedProvinceState() + locationCreatedSublocation() + locationCreatedWorldRegion() + locationShownCity() + locationShownCountryCode() + locationShownCountryName() + locationShownGpsAltitude() + locationShownGpsLatitude() + locationShownGpsLongitude() + locationShownLocationId() + locationShownLocationName() + locationShownProvinceState() + locationShownSublocation() + locationShownWorldRegion() + maxAvailHeight() + maxAvailWidth() + modelAge() + modelReleaseId() + objectAttributeReference() + objectName() + offsetTimeOriginal() + organisationInImageCode() + organisationInImageName() + orientation() + originalTransmissionReference() + personInImage() + personInImageCvTermCvId() + personInImageCvTermId() + personInImageCvTermName() + personInImageCvTermRefinedAbout() + personInImageDescription() + personInImageId() + personInImageName() + productInImageDescription() + productInImageGtin() + productInImageName() + propertyReleaseId() + provinceState() + rating() + registryEntryRole() + registryItemId() + registryOrganisationId() + resolutionUnit() + rights() + scene() + source() + specialInstructions() + state() + subject() + subjectCode() + subjectReference() + sublocation() + timeCreated() + title() + transmissionReference() + usageTerms() + webStatement() + writer() + writerEditor() + 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 (aboutCvTermCvId.asKnown().isPresent) 1 else 0) + + (if (aboutCvTermId.asKnown().isPresent) 1 else 0) + + (if (aboutCvTermName.asKnown().isPresent) 1 else 0) + + (if (aboutCvTermRefinedAbout.asKnown().isPresent) 1 else 0) + + (if (additionalModelInformation.asKnown().isPresent) 1 else 0) + + (if (applicationRecordVersion.asKnown().isPresent) 1 else 0) + + (if (artist.asKnown().isPresent) 1 else 0) + + (if (artworkCircaDateCreated.asKnown().isPresent) 1 else 0) + + (if (artworkContentDescription.asKnown().isPresent) 1 else 0) + + (if (artworkContributionDescription.asKnown().isPresent) 1 else 0) + + (if (artworkCopyrightNotice.asKnown().isPresent) 1 else 0) + + (if (artworkCopyrightOwnerId.asKnown().isPresent) 1 else 0) + + (if (artworkCopyrightOwnerName.asKnown().isPresent) 1 else 0) + + (artworkCreator.asKnown().getOrNull()?.size ?: 0) + + (artworkCreatorId.asKnown().getOrNull()?.size ?: 0) + + (if (artworkDateCreated.asKnown().isPresent) 1 else 0) + + (if (artworkLicensorId.asKnown().isPresent) 1 else 0) + + (if (artworkLicensorName.asKnown().isPresent) 1 else 0) + + (if (artworkPhysicalDescription.asKnown().isPresent) 1 else 0) + + (if (artworkSource.asKnown().isPresent) 1 else 0) + + (if (artworkSourceInventoryNo.asKnown().isPresent) 1 else 0) + + (if (artworkSourceInvUrl.asKnown().isPresent) 1 else 0) + + (artworkStylePeriod.asKnown().getOrNull()?.size ?: 0) + + (if (artworkTitle.asKnown().isPresent) 1 else 0) + + (if (authorsPosition.asKnown().isPresent) 1 else 0) + + (if (byline.asKnown().isPresent) 1 else 0) + + (if (bylineTitle.asKnown().isPresent) 1 else 0) + + (if (caption.asKnown().isPresent) 1 else 0) + + (if (captionAbstract.asKnown().isPresent) 1 else 0) + + (if (captionWriter.asKnown().isPresent) 1 else 0) + + (if (city.asKnown().isPresent) 1 else 0) + + (if (colorSpace.asKnown().isPresent) 1 else 0) + + (if (componentsConfiguration.asKnown().isPresent) 1 else 0) + + (if (copyright.asKnown().isPresent) 1 else 0) + + (if (copyrightNotice.asKnown().isPresent) 1 else 0) + + (copyrightOwnerId.asKnown().getOrNull()?.size ?: 0) + + (copyrightOwnerName.asKnown().getOrNull()?.size ?: 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (countryCode.asKnown().isPresent) 1 else 0) + + (if (countryPrimaryLocationCode.asKnown().isPresent) 1 else 0) + + (if (countryPrimaryLocationName.asKnown().isPresent) 1 else 0) + + (if (creator.asKnown().isPresent) 1 else 0) + + (if (creatorAddress.asKnown().isPresent) 1 else 0) + + (if (creatorCity.asKnown().isPresent) 1 else 0) + + (if (creatorCountry.asKnown().isPresent) 1 else 0) + + (if (creatorPostalCode.asKnown().isPresent) 1 else 0) + + (if (creatorRegion.asKnown().isPresent) 1 else 0) + + (if (creatorWorkEmail.asKnown().isPresent) 1 else 0) + + (if (creatorWorkTelephone.asKnown().isPresent) 1 else 0) + + (if (creatorWorkUrl.asKnown().isPresent) 1 else 0) + + (if (credit.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateTimeCreated.asKnown().isPresent) 1 else 0) + + (if (dateTimeOriginal.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (digitalImageGuid.asKnown().isPresent) 1 else 0) + + (if (digitalSourceType.asKnown().isPresent) 1 else 0) + + (if (embeddedEncodedRightsExpr.asKnown().isPresent) 1 else 0) + + (if (embeddedEncodedRightsExprLangId.asKnown().isPresent) 1 else 0) + + (if (embeddedEncodedRightsExprType.asKnown().isPresent) 1 else 0) + + (if (event.asKnown().isPresent) 1 else 0) + + (if (exifVersion.asKnown().isPresent) 1 else 0) + + (if (flashpixVersion.asKnown().isPresent) 1 else 0) + + (if (genreCvId.asKnown().isPresent) 1 else 0) + + (if (genreCvTermId.asKnown().isPresent) 1 else 0) + + (if (genreCvTermName.asKnown().isPresent) 1 else 0) + + (if (genreCvTermRefinedAbout.asKnown().isPresent) 1 else 0) + + (if (headline.asKnown().isPresent) 1 else 0) + + (if (imageCreatorId.asKnown().isPresent) 1 else 0) + + (if (imageCreatorImageId.asKnown().isPresent) 1 else 0) + + (if (imageCreatorName.asKnown().isPresent) 1 else 0) + + (if (imageDescription.asKnown().isPresent) 1 else 0) + + (imageRegionBoundaryH.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryRx.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryShape.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryUnit.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryVerticesX.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryVerticesY.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryW.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryX.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryY.asKnown().getOrNull()?.size ?: 0) + + (imageRegionCtypeIdentifier.asKnown().getOrNull()?.size ?: 0) + + (imageRegionCtypeName.asKnown().getOrNull()?.size ?: 0) + + (imageRegionId.asKnown().getOrNull()?.size ?: 0) + + (imageRegionName.asKnown().getOrNull()?.size ?: 0) + + (imageRegionOrganisationInImageName.asKnown().getOrNull()?.size ?: 0) + + (imageRegionPersonInImage.asKnown().getOrNull()?.size ?: 0) + + (imageRegionRoleIdentifier.asKnown().getOrNull()?.size ?: 0) + + (imageRegionRoleName.asKnown().getOrNull()?.size ?: 0) + + (if (imageSupplierId.asKnown().isPresent) 1 else 0) + + (if (imageSupplierImageId.asKnown().isPresent) 1 else 0) + + (if (imageSupplierName.asKnown().isPresent) 1 else 0) + + (if (instructions.asKnown().isPresent) 1 else 0) + + (if (intellectualGenre.asKnown().isPresent) 1 else 0) + + (keywords.asKnown().getOrNull()?.size ?: 0) + + (licensorCity.asKnown().getOrNull()?.size ?: 0) + + (licensorCountry.asKnown().getOrNull()?.size ?: 0) + + (licensorEmail.asKnown().getOrNull()?.size ?: 0) + + (licensorExtendedAddress.asKnown().getOrNull()?.size ?: 0) + + (licensorId.asKnown().getOrNull()?.size ?: 0) + + (licensorName.asKnown().getOrNull()?.size ?: 0) + + (licensorPostalCode.asKnown().getOrNull()?.size ?: 0) + + (licensorRegion.asKnown().getOrNull()?.size ?: 0) + + (licensorStreetAddress.asKnown().getOrNull()?.size ?: 0) + + (licensorTelephone1.asKnown().getOrNull()?.size ?: 0) + + (licensorTelephone2.asKnown().getOrNull()?.size ?: 0) + + (licensorUrl.asKnown().getOrNull()?.size ?: 0) + + (if (linkedEncodedRightsExpr.asKnown().isPresent) 1 else 0) + + (if (linkedEncodedRightsExprLangId.asKnown().isPresent) 1 else 0) + + (if (linkedEncodedRightsExprType.asKnown().isPresent) 1 else 0) + + (if (location.asKnown().isPresent) 1 else 0) + + (if (locationCreatedCity.asKnown().isPresent) 1 else 0) + + (if (locationCreatedCountryCode.asKnown().isPresent) 1 else 0) + + (if (locationCreatedCountryName.asKnown().isPresent) 1 else 0) + + (if (locationCreatedGpsAltitude.asKnown().isPresent) 1 else 0) + + (if (locationCreatedGpsLatitude.asKnown().isPresent) 1 else 0) + + (if (locationCreatedGpsLongitude.asKnown().isPresent) 1 else 0) + + (if (locationCreatedLocationId.asKnown().isPresent) 1 else 0) + + (if (locationCreatedLocationName.asKnown().isPresent) 1 else 0) + + (if (locationCreatedProvinceState.asKnown().isPresent) 1 else 0) + + (if (locationCreatedSublocation.asKnown().isPresent) 1 else 0) + + (if (locationCreatedWorldRegion.asKnown().isPresent) 1 else 0) + + (locationShownCity.asKnown().getOrNull()?.size ?: 0) + + (locationShownCountryCode.asKnown().getOrNull()?.size ?: 0) + + (locationShownCountryName.asKnown().getOrNull()?.size ?: 0) + + (locationShownGpsAltitude.asKnown().getOrNull()?.size ?: 0) + + (locationShownGpsLatitude.asKnown().getOrNull()?.size ?: 0) + + (locationShownGpsLongitude.asKnown().getOrNull()?.size ?: 0) + + (locationShownLocationId.asKnown().getOrNull()?.size ?: 0) + + (locationShownLocationName.asKnown().getOrNull()?.size ?: 0) + + (locationShownProvinceState.asKnown().getOrNull()?.size ?: 0) + + (locationShownSublocation.asKnown().getOrNull()?.size ?: 0) + + (locationShownWorldRegion.asKnown().getOrNull()?.size ?: 0) + + (if (maxAvailHeight.asKnown().isPresent) 1 else 0) + + (if (maxAvailWidth.asKnown().isPresent) 1 else 0) + + (modelAge.asKnown().getOrNull()?.size ?: 0) + + (modelReleaseId.asKnown().getOrNull()?.size ?: 0) + + (if (objectAttributeReference.asKnown().isPresent) 1 else 0) + + (if (objectName.asKnown().isPresent) 1 else 0) + + (if (offsetTimeOriginal.asKnown().isPresent) 1 else 0) + + (organisationInImageCode.asKnown().getOrNull()?.size ?: 0) + + (organisationInImageName.asKnown().getOrNull()?.size ?: 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (if (originalTransmissionReference.asKnown().isPresent) 1 else 0) + + (personInImage.asKnown().getOrNull()?.size ?: 0) + + (personInImageCvTermCvId.asKnown().getOrNull()?.size ?: 0) + + (personInImageCvTermId.asKnown().getOrNull()?.size ?: 0) + + (personInImageCvTermName.asKnown().getOrNull()?.size ?: 0) + + (personInImageCvTermRefinedAbout.asKnown().getOrNull()?.size ?: 0) + + (personInImageDescription.asKnown().getOrNull()?.size ?: 0) + + (personInImageId.asKnown().getOrNull()?.size ?: 0) + + (personInImageName.asKnown().getOrNull()?.size ?: 0) + + (productInImageDescription.asKnown().getOrNull()?.size ?: 0) + + (productInImageGtin.asKnown().getOrNull()?.size ?: 0) + + (productInImageName.asKnown().getOrNull()?.size ?: 0) + + (propertyReleaseId.asKnown().getOrNull()?.size ?: 0) + + (if (provinceState.asKnown().isPresent) 1 else 0) + + (if (rating.asKnown().isPresent) 1 else 0) + + (registryEntryRole.asKnown().getOrNull()?.size ?: 0) + + (registryItemId.asKnown().getOrNull()?.size ?: 0) + + (registryOrganisationId.asKnown().getOrNull()?.size ?: 0) + + (if (resolutionUnit.asKnown().isPresent) 1 else 0) + + (if (rights.asKnown().isPresent) 1 else 0) + + (scene.asKnown().getOrNull()?.size ?: 0) + + (if (source.asKnown().isPresent) 1 else 0) + + (if (specialInstructions.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + (subject.asKnown().getOrNull()?.size ?: 0) + + (subjectCode.asKnown().getOrNull()?.size ?: 0) + + (subjectReference.asKnown().getOrNull()?.size ?: 0) + + (if (sublocation.asKnown().isPresent) 1 else 0) + + (if (timeCreated.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (if (transmissionReference.asKnown().isPresent) 1 else 0) + + (if (usageTerms.asKnown().isPresent) 1 else 0) + + (if (webStatement.asKnown().isPresent) 1 else 0) + + (if (writer.asKnown().isPresent) 1 else 0) + + (if (writerEditor.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 EmbeddedMetadata && + aboutCvTermCvId == other.aboutCvTermCvId && + aboutCvTermId == other.aboutCvTermId && + aboutCvTermName == other.aboutCvTermName && + aboutCvTermRefinedAbout == other.aboutCvTermRefinedAbout && + additionalModelInformation == other.additionalModelInformation && + applicationRecordVersion == other.applicationRecordVersion && + artist == other.artist && + artworkCircaDateCreated == other.artworkCircaDateCreated && + artworkContentDescription == other.artworkContentDescription && + artworkContributionDescription == other.artworkContributionDescription && + artworkCopyrightNotice == other.artworkCopyrightNotice && + artworkCopyrightOwnerId == other.artworkCopyrightOwnerId && + artworkCopyrightOwnerName == other.artworkCopyrightOwnerName && + artworkCreator == other.artworkCreator && + artworkCreatorId == other.artworkCreatorId && + artworkDateCreated == other.artworkDateCreated && + artworkLicensorId == other.artworkLicensorId && + artworkLicensorName == other.artworkLicensorName && + artworkPhysicalDescription == other.artworkPhysicalDescription && + artworkSource == other.artworkSource && + artworkSourceInventoryNo == other.artworkSourceInventoryNo && + artworkSourceInvUrl == other.artworkSourceInvUrl && + artworkStylePeriod == other.artworkStylePeriod && + artworkTitle == other.artworkTitle && + authorsPosition == other.authorsPosition && + byline == other.byline && + bylineTitle == other.bylineTitle && + caption == other.caption && + captionAbstract == other.captionAbstract && + captionWriter == other.captionWriter && + city == other.city && + colorSpace == other.colorSpace && + componentsConfiguration == other.componentsConfiguration && + copyright == other.copyright && + copyrightNotice == other.copyrightNotice && + copyrightOwnerId == other.copyrightOwnerId && + copyrightOwnerName == other.copyrightOwnerName && + country == other.country && + countryCode == other.countryCode && + countryPrimaryLocationCode == other.countryPrimaryLocationCode && + countryPrimaryLocationName == other.countryPrimaryLocationName && + creator == other.creator && + creatorAddress == other.creatorAddress && + creatorCity == other.creatorCity && + creatorCountry == other.creatorCountry && + creatorPostalCode == other.creatorPostalCode && + creatorRegion == other.creatorRegion && + creatorWorkEmail == other.creatorWorkEmail && + creatorWorkTelephone == other.creatorWorkTelephone && + creatorWorkUrl == other.creatorWorkUrl && + credit == other.credit && + dateCreated == other.dateCreated && + dateTimeCreated == other.dateTimeCreated && + dateTimeOriginal == other.dateTimeOriginal && + description == other.description && + digitalImageGuid == other.digitalImageGuid && + digitalSourceType == other.digitalSourceType && + embeddedEncodedRightsExpr == other.embeddedEncodedRightsExpr && + embeddedEncodedRightsExprLangId == other.embeddedEncodedRightsExprLangId && + embeddedEncodedRightsExprType == other.embeddedEncodedRightsExprType && + event == other.event && + exifVersion == other.exifVersion && + flashpixVersion == other.flashpixVersion && + genreCvId == other.genreCvId && + genreCvTermId == other.genreCvTermId && + genreCvTermName == other.genreCvTermName && + genreCvTermRefinedAbout == other.genreCvTermRefinedAbout && + headline == other.headline && + imageCreatorId == other.imageCreatorId && + imageCreatorImageId == other.imageCreatorImageId && + imageCreatorName == other.imageCreatorName && + imageDescription == other.imageDescription && + imageRegionBoundaryH == other.imageRegionBoundaryH && + imageRegionBoundaryRx == other.imageRegionBoundaryRx && + imageRegionBoundaryShape == other.imageRegionBoundaryShape && + imageRegionBoundaryUnit == other.imageRegionBoundaryUnit && + imageRegionBoundaryVerticesX == other.imageRegionBoundaryVerticesX && + imageRegionBoundaryVerticesY == other.imageRegionBoundaryVerticesY && + imageRegionBoundaryW == other.imageRegionBoundaryW && + imageRegionBoundaryX == other.imageRegionBoundaryX && + imageRegionBoundaryY == other.imageRegionBoundaryY && + imageRegionCtypeIdentifier == other.imageRegionCtypeIdentifier && + imageRegionCtypeName == other.imageRegionCtypeName && + imageRegionId == other.imageRegionId && + imageRegionName == other.imageRegionName && + imageRegionOrganisationInImageName == other.imageRegionOrganisationInImageName && + imageRegionPersonInImage == other.imageRegionPersonInImage && + imageRegionRoleIdentifier == other.imageRegionRoleIdentifier && + imageRegionRoleName == other.imageRegionRoleName && + imageSupplierId == other.imageSupplierId && + imageSupplierImageId == other.imageSupplierImageId && + imageSupplierName == other.imageSupplierName && + instructions == other.instructions && + intellectualGenre == other.intellectualGenre && + keywords == other.keywords && + licensorCity == other.licensorCity && + licensorCountry == other.licensorCountry && + licensorEmail == other.licensorEmail && + licensorExtendedAddress == other.licensorExtendedAddress && + licensorId == other.licensorId && + licensorName == other.licensorName && + licensorPostalCode == other.licensorPostalCode && + licensorRegion == other.licensorRegion && + licensorStreetAddress == other.licensorStreetAddress && + licensorTelephone1 == other.licensorTelephone1 && + licensorTelephone2 == other.licensorTelephone2 && + licensorUrl == other.licensorUrl && + linkedEncodedRightsExpr == other.linkedEncodedRightsExpr && + linkedEncodedRightsExprLangId == other.linkedEncodedRightsExprLangId && + linkedEncodedRightsExprType == other.linkedEncodedRightsExprType && + location == other.location && + locationCreatedCity == other.locationCreatedCity && + locationCreatedCountryCode == other.locationCreatedCountryCode && + locationCreatedCountryName == other.locationCreatedCountryName && + locationCreatedGpsAltitude == other.locationCreatedGpsAltitude && + locationCreatedGpsLatitude == other.locationCreatedGpsLatitude && + locationCreatedGpsLongitude == other.locationCreatedGpsLongitude && + locationCreatedLocationId == other.locationCreatedLocationId && + locationCreatedLocationName == other.locationCreatedLocationName && + locationCreatedProvinceState == other.locationCreatedProvinceState && + locationCreatedSublocation == other.locationCreatedSublocation && + locationCreatedWorldRegion == other.locationCreatedWorldRegion && + locationShownCity == other.locationShownCity && + locationShownCountryCode == other.locationShownCountryCode && + locationShownCountryName == other.locationShownCountryName && + locationShownGpsAltitude == other.locationShownGpsAltitude && + locationShownGpsLatitude == other.locationShownGpsLatitude && + locationShownGpsLongitude == other.locationShownGpsLongitude && + locationShownLocationId == other.locationShownLocationId && + locationShownLocationName == other.locationShownLocationName && + locationShownProvinceState == other.locationShownProvinceState && + locationShownSublocation == other.locationShownSublocation && + locationShownWorldRegion == other.locationShownWorldRegion && + maxAvailHeight == other.maxAvailHeight && + maxAvailWidth == other.maxAvailWidth && + modelAge == other.modelAge && + modelReleaseId == other.modelReleaseId && + objectAttributeReference == other.objectAttributeReference && + objectName == other.objectName && + offsetTimeOriginal == other.offsetTimeOriginal && + organisationInImageCode == other.organisationInImageCode && + organisationInImageName == other.organisationInImageName && + orientation == other.orientation && + originalTransmissionReference == other.originalTransmissionReference && + personInImage == other.personInImage && + personInImageCvTermCvId == other.personInImageCvTermCvId && + personInImageCvTermId == other.personInImageCvTermId && + personInImageCvTermName == other.personInImageCvTermName && + personInImageCvTermRefinedAbout == other.personInImageCvTermRefinedAbout && + personInImageDescription == other.personInImageDescription && + personInImageId == other.personInImageId && + personInImageName == other.personInImageName && + productInImageDescription == other.productInImageDescription && + productInImageGtin == other.productInImageGtin && + productInImageName == other.productInImageName && + propertyReleaseId == other.propertyReleaseId && + provinceState == other.provinceState && + rating == other.rating && + registryEntryRole == other.registryEntryRole && + registryItemId == other.registryItemId && + registryOrganisationId == other.registryOrganisationId && + resolutionUnit == other.resolutionUnit && + rights == other.rights && + scene == other.scene && + source == other.source && + specialInstructions == other.specialInstructions && + state == other.state && + subject == other.subject && + subjectCode == other.subjectCode && + subjectReference == other.subjectReference && + sublocation == other.sublocation && + timeCreated == other.timeCreated && + title == other.title && + transmissionReference == other.transmissionReference && + usageTerms == other.usageTerms && + webStatement == other.webStatement && + writer == other.writer && + writerEditor == other.writerEditor && + xResolution == other.xResolution && + yResolution == other.yResolution && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboutCvTermCvId, + aboutCvTermId, + aboutCvTermName, + aboutCvTermRefinedAbout, + additionalModelInformation, + applicationRecordVersion, + artist, + artworkCircaDateCreated, + artworkContentDescription, + artworkContributionDescription, + artworkCopyrightNotice, + artworkCopyrightOwnerId, + artworkCopyrightOwnerName, + artworkCreator, + artworkCreatorId, + artworkDateCreated, + artworkLicensorId, + artworkLicensorName, + artworkPhysicalDescription, + artworkSource, + artworkSourceInventoryNo, + artworkSourceInvUrl, + artworkStylePeriod, + artworkTitle, + authorsPosition, + byline, + bylineTitle, + caption, + captionAbstract, + captionWriter, + city, + colorSpace, + componentsConfiguration, + copyright, + copyrightNotice, + copyrightOwnerId, + copyrightOwnerName, + country, + countryCode, + countryPrimaryLocationCode, + countryPrimaryLocationName, + creator, + creatorAddress, + creatorCity, + creatorCountry, + creatorPostalCode, + creatorRegion, + creatorWorkEmail, + creatorWorkTelephone, + creatorWorkUrl, + credit, + dateCreated, + dateTimeCreated, + dateTimeOriginal, + description, + digitalImageGuid, + digitalSourceType, + embeddedEncodedRightsExpr, + embeddedEncodedRightsExprLangId, + embeddedEncodedRightsExprType, + event, + exifVersion, + flashpixVersion, + genreCvId, + genreCvTermId, + genreCvTermName, + genreCvTermRefinedAbout, + headline, + imageCreatorId, + imageCreatorImageId, + imageCreatorName, + imageDescription, + imageRegionBoundaryH, + imageRegionBoundaryRx, + imageRegionBoundaryShape, + imageRegionBoundaryUnit, + imageRegionBoundaryVerticesX, + imageRegionBoundaryVerticesY, + imageRegionBoundaryW, + imageRegionBoundaryX, + imageRegionBoundaryY, + imageRegionCtypeIdentifier, + imageRegionCtypeName, + imageRegionId, + imageRegionName, + imageRegionOrganisationInImageName, + imageRegionPersonInImage, + imageRegionRoleIdentifier, + imageRegionRoleName, + imageSupplierId, + imageSupplierImageId, + imageSupplierName, + instructions, + intellectualGenre, + keywords, + licensorCity, + licensorCountry, + licensorEmail, + licensorExtendedAddress, + licensorId, + licensorName, + licensorPostalCode, + licensorRegion, + licensorStreetAddress, + licensorTelephone1, + licensorTelephone2, + licensorUrl, + linkedEncodedRightsExpr, + linkedEncodedRightsExprLangId, + linkedEncodedRightsExprType, + location, + locationCreatedCity, + locationCreatedCountryCode, + locationCreatedCountryName, + locationCreatedGpsAltitude, + locationCreatedGpsLatitude, + locationCreatedGpsLongitude, + locationCreatedLocationId, + locationCreatedLocationName, + locationCreatedProvinceState, + locationCreatedSublocation, + locationCreatedWorldRegion, + locationShownCity, + locationShownCountryCode, + locationShownCountryName, + locationShownGpsAltitude, + locationShownGpsLatitude, + locationShownGpsLongitude, + locationShownLocationId, + locationShownLocationName, + locationShownProvinceState, + locationShownSublocation, + locationShownWorldRegion, + maxAvailHeight, + maxAvailWidth, + modelAge, + modelReleaseId, + objectAttributeReference, + objectName, + offsetTimeOriginal, + organisationInImageCode, + organisationInImageName, + orientation, + originalTransmissionReference, + personInImage, + personInImageCvTermCvId, + personInImageCvTermId, + personInImageCvTermName, + personInImageCvTermRefinedAbout, + personInImageDescription, + personInImageId, + personInImageName, + productInImageDescription, + productInImageGtin, + productInImageName, + propertyReleaseId, + provinceState, + rating, + registryEntryRole, + registryItemId, + registryOrganisationId, + resolutionUnit, + rights, + scene, + source, + specialInstructions, + state, + subject, + subjectCode, + subjectReference, + sublocation, + timeCreated, + title, + transmissionReference, + usageTerms, + webStatement, + writer, + writerEditor, + xResolution, + yResolution, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmbeddedMetadata{aboutCvTermCvId=$aboutCvTermCvId, aboutCvTermId=$aboutCvTermId, aboutCvTermName=$aboutCvTermName, aboutCvTermRefinedAbout=$aboutCvTermRefinedAbout, additionalModelInformation=$additionalModelInformation, applicationRecordVersion=$applicationRecordVersion, artist=$artist, artworkCircaDateCreated=$artworkCircaDateCreated, artworkContentDescription=$artworkContentDescription, artworkContributionDescription=$artworkContributionDescription, artworkCopyrightNotice=$artworkCopyrightNotice, artworkCopyrightOwnerId=$artworkCopyrightOwnerId, artworkCopyrightOwnerName=$artworkCopyrightOwnerName, artworkCreator=$artworkCreator, artworkCreatorId=$artworkCreatorId, artworkDateCreated=$artworkDateCreated, artworkLicensorId=$artworkLicensorId, artworkLicensorName=$artworkLicensorName, artworkPhysicalDescription=$artworkPhysicalDescription, artworkSource=$artworkSource, artworkSourceInventoryNo=$artworkSourceInventoryNo, artworkSourceInvUrl=$artworkSourceInvUrl, artworkStylePeriod=$artworkStylePeriod, artworkTitle=$artworkTitle, authorsPosition=$authorsPosition, byline=$byline, bylineTitle=$bylineTitle, caption=$caption, captionAbstract=$captionAbstract, captionWriter=$captionWriter, city=$city, colorSpace=$colorSpace, componentsConfiguration=$componentsConfiguration, copyright=$copyright, copyrightNotice=$copyrightNotice, copyrightOwnerId=$copyrightOwnerId, copyrightOwnerName=$copyrightOwnerName, country=$country, countryCode=$countryCode, countryPrimaryLocationCode=$countryPrimaryLocationCode, countryPrimaryLocationName=$countryPrimaryLocationName, creator=$creator, creatorAddress=$creatorAddress, creatorCity=$creatorCity, creatorCountry=$creatorCountry, creatorPostalCode=$creatorPostalCode, creatorRegion=$creatorRegion, creatorWorkEmail=$creatorWorkEmail, creatorWorkTelephone=$creatorWorkTelephone, creatorWorkUrl=$creatorWorkUrl, credit=$credit, dateCreated=$dateCreated, dateTimeCreated=$dateTimeCreated, dateTimeOriginal=$dateTimeOriginal, description=$description, digitalImageGuid=$digitalImageGuid, digitalSourceType=$digitalSourceType, embeddedEncodedRightsExpr=$embeddedEncodedRightsExpr, embeddedEncodedRightsExprLangId=$embeddedEncodedRightsExprLangId, embeddedEncodedRightsExprType=$embeddedEncodedRightsExprType, event=$event, exifVersion=$exifVersion, flashpixVersion=$flashpixVersion, genreCvId=$genreCvId, genreCvTermId=$genreCvTermId, genreCvTermName=$genreCvTermName, genreCvTermRefinedAbout=$genreCvTermRefinedAbout, headline=$headline, imageCreatorId=$imageCreatorId, imageCreatorImageId=$imageCreatorImageId, imageCreatorName=$imageCreatorName, imageDescription=$imageDescription, imageRegionBoundaryH=$imageRegionBoundaryH, imageRegionBoundaryRx=$imageRegionBoundaryRx, imageRegionBoundaryShape=$imageRegionBoundaryShape, imageRegionBoundaryUnit=$imageRegionBoundaryUnit, imageRegionBoundaryVerticesX=$imageRegionBoundaryVerticesX, imageRegionBoundaryVerticesY=$imageRegionBoundaryVerticesY, imageRegionBoundaryW=$imageRegionBoundaryW, imageRegionBoundaryX=$imageRegionBoundaryX, imageRegionBoundaryY=$imageRegionBoundaryY, imageRegionCtypeIdentifier=$imageRegionCtypeIdentifier, imageRegionCtypeName=$imageRegionCtypeName, imageRegionId=$imageRegionId, imageRegionName=$imageRegionName, imageRegionOrganisationInImageName=$imageRegionOrganisationInImageName, imageRegionPersonInImage=$imageRegionPersonInImage, imageRegionRoleIdentifier=$imageRegionRoleIdentifier, imageRegionRoleName=$imageRegionRoleName, imageSupplierId=$imageSupplierId, imageSupplierImageId=$imageSupplierImageId, imageSupplierName=$imageSupplierName, instructions=$instructions, intellectualGenre=$intellectualGenre, keywords=$keywords, licensorCity=$licensorCity, licensorCountry=$licensorCountry, licensorEmail=$licensorEmail, licensorExtendedAddress=$licensorExtendedAddress, licensorId=$licensorId, licensorName=$licensorName, licensorPostalCode=$licensorPostalCode, licensorRegion=$licensorRegion, licensorStreetAddress=$licensorStreetAddress, licensorTelephone1=$licensorTelephone1, licensorTelephone2=$licensorTelephone2, licensorUrl=$licensorUrl, linkedEncodedRightsExpr=$linkedEncodedRightsExpr, linkedEncodedRightsExprLangId=$linkedEncodedRightsExprLangId, linkedEncodedRightsExprType=$linkedEncodedRightsExprType, location=$location, locationCreatedCity=$locationCreatedCity, locationCreatedCountryCode=$locationCreatedCountryCode, locationCreatedCountryName=$locationCreatedCountryName, locationCreatedGpsAltitude=$locationCreatedGpsAltitude, locationCreatedGpsLatitude=$locationCreatedGpsLatitude, locationCreatedGpsLongitude=$locationCreatedGpsLongitude, locationCreatedLocationId=$locationCreatedLocationId, locationCreatedLocationName=$locationCreatedLocationName, locationCreatedProvinceState=$locationCreatedProvinceState, locationCreatedSublocation=$locationCreatedSublocation, locationCreatedWorldRegion=$locationCreatedWorldRegion, locationShownCity=$locationShownCity, locationShownCountryCode=$locationShownCountryCode, locationShownCountryName=$locationShownCountryName, locationShownGpsAltitude=$locationShownGpsAltitude, locationShownGpsLatitude=$locationShownGpsLatitude, locationShownGpsLongitude=$locationShownGpsLongitude, locationShownLocationId=$locationShownLocationId, locationShownLocationName=$locationShownLocationName, locationShownProvinceState=$locationShownProvinceState, locationShownSublocation=$locationShownSublocation, locationShownWorldRegion=$locationShownWorldRegion, maxAvailHeight=$maxAvailHeight, maxAvailWidth=$maxAvailWidth, modelAge=$modelAge, modelReleaseId=$modelReleaseId, objectAttributeReference=$objectAttributeReference, objectName=$objectName, offsetTimeOriginal=$offsetTimeOriginal, organisationInImageCode=$organisationInImageCode, organisationInImageName=$organisationInImageName, orientation=$orientation, originalTransmissionReference=$originalTransmissionReference, personInImage=$personInImage, personInImageCvTermCvId=$personInImageCvTermCvId, personInImageCvTermId=$personInImageCvTermId, personInImageCvTermName=$personInImageCvTermName, personInImageCvTermRefinedAbout=$personInImageCvTermRefinedAbout, personInImageDescription=$personInImageDescription, personInImageId=$personInImageId, personInImageName=$personInImageName, productInImageDescription=$productInImageDescription, productInImageGtin=$productInImageGtin, productInImageName=$productInImageName, propertyReleaseId=$propertyReleaseId, provinceState=$provinceState, rating=$rating, registryEntryRole=$registryEntryRole, registryItemId=$registryItemId, registryOrganisationId=$registryOrganisationId, resolutionUnit=$resolutionUnit, rights=$rights, scene=$scene, source=$source, specialInstructions=$specialInstructions, state=$state, subject=$subject, subjectCode=$subjectCode, subjectReference=$subjectReference, sublocation=$sublocation, timeCreated=$timeCreated, title=$title, transmissionReference=$transmissionReference, usageTerms=$usageTerms, webStatement=$webStatement, writer=$writer, writerEditor=$writerEditor, xResolution=$xResolution, yResolution=$yResolution, 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 awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @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(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 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 [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 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 { + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + 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( + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + 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 = + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + 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 && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the + * upload API response. + */ + 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: ExifDetails) = exif(JsonField.of(exif)) + + /** + * Sets [Builder.exif] to an arbitrary JSON value. + * + * 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 } + + /** 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: ExifImage) = image(JsonField.of(image)) + + /** + * Sets [Builder.image] to an arbitrary JSON value. + * + * You should usually call [Builder.image] with a well-typed [ExifImage] 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) + + 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}" + } + + 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}" + } + + /** 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 FileUploadV1Response && + aiTags == other.aiTags && + audioCodec == other.audioCodec && + bitRate == other.bitRate && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + 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() = + "FileUploadV1Response{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/FileUploadV2Params.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Params.kt new file mode 100644 index 00000000..7d4a8217 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Params.kt @@ -0,0 +1,2861 @@ +// 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.JsonValue +import com.imagekit.api.core.MultipartField +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 com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * 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 FileUploadV2Params +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please ensure + * that our servers can access the URL. In case ImageKit is unable to download the file from the + * specified URL, a `400` error response is returned. This will also result in a `400` error if + * the file download request is aborted if response headers are not received in 8 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 file(): String = 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() + + /** + * Stringified JSON key-value data to be associated with the asset. + * + * @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() + + /** + * Stringified JSON object with an array of extensions to be applied to the image. Refer to + * extensions schema in + * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). + * + * @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() + + /** + * Comma-separated values of the fields that you want the API to return in the response. + * + * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get the + * value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. + * + * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, + * `isPublished`, `customMetadata`, and `metadata`. + * + * @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. + * + * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all + * characters should not exceed 500. `%` is not allowed. + * + * If this field is not specified and the file is overwritten then the 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() + + /** + * Stringified JSON object with properties for pre and post transformations: + * + * `pre` - Accepts a "string" containing a valid transformation used for requesting a + * pre-transformation for an image or a video file. + * + * `post` - Accepts an array of objects with properties: + * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive bitrate + * streaming). + * - `value`: A "string" corresponding to the required transformation. Required if `type` is + * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. + * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. + * + * Read more about [Adaptive bitrate streaming (ABS)](/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 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 [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 [FileUploadV2Params]. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadV2Params]. */ + 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(fileUploadV2Params: FileUploadV2Params) = apply { + body = fileUploadV2Params.body.toBuilder() + additionalHeaders = fileUploadV2Params.additionalHeaders.toBuilder() + additionalQueryParams = fileUploadV2Params.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() } + + /** + * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please + * ensure that our servers can access the URL. In case ImageKit is unable to download the + * file from the specified URL, a `400` error response is returned. This will also result in + * a `400` error if the file download request is aborted if response headers are not + * received in 8 seconds. + */ + 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 [String] 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 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) + } + + /** Stringified JSON key-value data to be associated with the asset. */ + fun customMetadata(customMetadata: String) = apply { body.customMetadata(customMetadata) } + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed [String] 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) + } + + /** + * Stringified JSON object with an array of extensions to be applied to the image. Refer to + * extensions schema in + * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). + */ + fun extensions(extensions: String) = apply { body.extensions(extensions) } + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed [String] 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) } + + /** + * 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: IsPrivateFile) = apply { + body.isPrivateFile(isPrivateFile) + } + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [IsPrivateFile] 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: IsPublished) = apply { body.isPublished(isPublished) } + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [IsPublished] 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: OverwriteAiTags) = apply { + body.overwriteAiTags(overwriteAiTags) + } + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [OverwriteAiTags] + * 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: OverwriteCustomMetadata) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) + } + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed + * [OverwriteCustomMetadata] 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: String) = apply { body.overwriteFile(overwriteFile) } + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [String] 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: OverwriteTags) = apply { + body.overwriteTags(overwriteTags) + } + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [OverwriteTags] 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) + } + + /** + * Comma-separated values of the fields that you want the API to return in the response. + * + * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get + * the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. + * + * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, + * `isPublished`, `customMetadata`, and `metadata`. + */ + fun responseFields(responseFields: String) = apply { body.responseFields(responseFields) } + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] 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(responseFields: MultipartField) = apply { + body.responseFields(responseFields) + } + + /** + * Set the tags while uploading the file. + * + * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all + * characters should not exceed 500. `%` is not allowed. + * + * If this field is not specified and the file is overwritten then the tags will be removed. + */ + fun tags(tags: String) = apply { body.tags(tags) } + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed [String] 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) } + + /** + * Stringified JSON object with properties for pre and post transformations: + * + * `pre` - Accepts a "string" containing a valid transformation used for requesting a + * pre-transformation for an image or a video file. + * + * `post` - Accepts an array of objects with properties: + * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive + * bitrate streaming). + * - `value`: A "string" corresponding to the required transformation. Required if `type` is + * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. + * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. + * + * Read more about [Adaptive bitrate streaming (ABS)](/docs/adaptive-bitrate-streaming). + */ + fun transformation(transformation: String) = apply { body.transformation(transformation) } + + /** + * Sets [Builder.transformation] to an arbitrary multipart 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: 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: UseUniqueFileName) = apply { + body.useUniqueFileName(useUniqueFileName) + } + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [UseUniqueFileName] + * 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 [FileUploadV2Params]. + * + * 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(): FileUploadV2Params = + FileUploadV2Params( + 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(), + "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 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, + ) { + + /** + * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please + * ensure that our servers can access the URL. In case ImageKit is unable to download the + * file from the specified URL, a `400` error response is returned. This will also result in + * a `400` error if the file download request is aborted if response headers are not + * received in 8 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 file(): String = 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") + + /** + * Stringified JSON key-value data to be associated with the asset. + * + * @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") + + /** + * Stringified JSON object with an array of extensions to be applied to the image. Refer to + * extensions schema in + * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). + * + * @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") + + /** + * Comma-separated values of the fields that you want the API to return in the response. + * + * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get + * the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. + * + * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, + * `isPublished`, `customMetadata`, and `metadata`. + * + * @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. + * + * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all + * characters should not exceed 500. `%` is not allowed. + * + * If this field is not specified and the file is overwritten then the 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") + + /** + * Stringified JSON object with properties for pre and post transformations: + * + * `pre` - Accepts a "string" containing a valid transformation used for requesting a + * pre-transformation for an image or a video file. + * + * `post` - Accepts an array of objects with properties: + * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive + * bitrate streaming). + * - `value`: A "string" corresponding to the required transformation. Required if `type` is + * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. + * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. + * + * Read more about [Adaptive bitrate streaming (ABS)](/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 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 [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 extensions: MultipartField = MultipartField.of(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 = MultipartField.of(null) + private var tags: 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() + + @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 + extensions = body.extensions + folder = body.folder + isPrivateFile = body.isPrivateFile + isPublished = body.isPublished + overwriteAiTags = body.overwriteAiTags + overwriteCustomMetadata = body.overwriteCustomMetadata + overwriteFile = body.overwriteFile + overwriteTags = body.overwriteTags + responseFields = body.responseFields + tags = body.tags + transformation = body.transformation + useUniqueFileName = body.useUniqueFileName + webhookUrl = body.webhookUrl + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please + * ensure that our servers can access the URL. In case ImageKit is unable to download + * the file from the specified URL, a `400` error response is returned. This will also + * result in a `400` error if the file download request is aborted if response headers + * are not received in 8 seconds. + */ + 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 [String] 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 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 + } + + /** Stringified JSON key-value data to be associated with the asset. */ + fun customMetadata(customMetadata: String) = + customMetadata(MultipartField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed [String] 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 + } + + /** + * Stringified JSON object with an array of extensions to be applied to the image. Refer + * to extensions schema in + * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). + */ + fun extensions(extensions: String) = extensions(MultipartField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed [String] 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 + } + + /** + * 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: IsPrivateFile) = + isPrivateFile(MultipartField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [IsPrivateFile] + * 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: IsPublished) = isPublished(MultipartField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [IsPublished] 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: OverwriteAiTags) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [OverwriteAiTags] + * 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: OverwriteCustomMetadata) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed + * [OverwriteCustomMetadata] 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: String) = + overwriteFile(MultipartField.of(overwriteFile)) + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [String] 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: OverwriteTags) = + overwriteTags(MultipartField.of(overwriteTags)) + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [OverwriteTags] + * 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 + } + + /** + * Comma-separated values of the fields that you want the API to return in the response. + * + * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to + * get the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. + * + * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, + * `embeddedMetadata`, `isPublished`, `customMetadata`, and `metadata`. + */ + fun responseFields(responseFields: String) = + responseFields(MultipartField.of(responseFields)) + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] 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(responseFields: MultipartField) = apply { + this.responseFields = responseFields + } + + /** + * Set the tags while uploading the file. + * + * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of + * all characters should not exceed 500. `%` is not allowed. + * + * If this field is not specified and the file is overwritten then the tags will be + * removed. + */ + fun tags(tags: String) = tags(MultipartField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed [String] 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 } + + /** + * Stringified JSON object with properties for pre and post transformations: + * + * `pre` - Accepts a "string" containing a valid transformation used for requesting a + * pre-transformation for an image or a video file. + * + * `post` - Accepts an array of objects with properties: + * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive + * bitrate streaming). + * - `value`: A "string" corresponding to the required transformation. Required if + * `type` is `transformation` or `abs`. Optional if `type` is `gif-to-video` or + * `thumbnail`. + * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. + * + * Read more about [Adaptive bitrate streaming (ABS)](/docs/adaptive-bitrate-streaming). + */ + fun transformation(transformation: String) = + transformation(MultipartField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary multipart 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: 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: UseUniqueFileName) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed + * [UseUniqueFileName] 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, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + responseFields, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + fileName() + token() + checks() + customCoordinates() + customMetadata() + extensions() + folder() + isPrivateFile().ifPresent { it.validate() } + isPublished().ifPresent { it.validate() } + overwriteAiTags().ifPresent { it.validate() } + overwriteCustomMetadata().ifPresent { it.validate() } + overwriteFile() + overwriteTags().ifPresent { it.validate() } + responseFields() + tags() + transformation() + useUniqueFileName().ifPresent { it.validate() } + 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 && + 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, + 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, 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}" + } + + /** + * 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. + */ + class IsPrivateFile @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = IsPrivateFile(JsonField.of(value)) + } + + /** An enum containing [IsPrivateFile]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [IsPrivateFile]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IsPrivateFile] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [IsPrivateFile] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown IsPrivateFile: $value") + } + + /** + * Returns this class 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(): IsPrivateFile = 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 IsPrivateFile && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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. + */ + class IsPublished @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = IsPublished(JsonField.of(value)) + } + + /** An enum containing [IsPublished]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [IsPublished]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IsPublished] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [IsPublished] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown IsPublished: $value") + } + + /** + * Returns this class 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(): IsPublished = 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 IsPublished && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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. + */ + class OverwriteAiTags @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = OverwriteAiTags(JsonField.of(value)) + } + + /** An enum containing [OverwriteAiTags]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [OverwriteAiTags]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [OverwriteAiTags] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [OverwriteAiTags] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown OverwriteAiTags: $value") + } + + /** + * Returns this class 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(): OverwriteAiTags = 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 OverwriteAiTags && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + class OverwriteCustomMetadata + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = OverwriteCustomMetadata(JsonField.of(value)) + } + + /** An enum containing [OverwriteCustomMetadata]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [OverwriteCustomMetadata]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [OverwriteCustomMetadata] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [OverwriteCustomMetadata] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> + throw ImageKitInvalidDataException("Unknown OverwriteCustomMetadata: $value") + } + + /** + * Returns this class 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(): OverwriteCustomMetadata = 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 OverwriteCustomMetadata && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + class OverwriteTags @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = OverwriteTags(JsonField.of(value)) + } + + /** An enum containing [OverwriteTags]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [OverwriteTags]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [OverwriteTags] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [OverwriteTags] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown OverwriteTags: $value") + } + + /** + * Returns this class 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(): OverwriteTags = 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 OverwriteTags && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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. + */ + class UseUniqueFileName @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val FALSE = of("false") + + @JvmStatic fun of(value: String) = UseUniqueFileName(JsonField.of(value)) + } + + /** An enum containing [UseUniqueFileName]'s known values. */ + enum class Known { + TRUE, + FALSE, + } + + /** + * An enum containing [UseUniqueFileName]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UseUniqueFileName] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + FALSE, + /** + * An enum member indicating that [UseUniqueFileName] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + FALSE -> Value.FALSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + FALSE -> Known.FALSE + else -> throw ImageKitInvalidDataException("Unknown UseUniqueFileName: $value") + } + + /** + * Returns this class 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(): UseUniqueFileName = 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 UseUniqueFileName && 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 FileUploadV2Params && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileUploadV2Params{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Response.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Response.kt new file mode 100644 index 00000000..8a87fcf9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Response.kt @@ -0,0 +1,11793 @@ +// 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 successful upload. */ +class FileUploadV2Response +private constructor( + private val aiTags: JsonField>, + private val audioCodec: JsonField, + private val bitRate: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + 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: JsonValue = 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, + 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. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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 [FileUploadV2Response]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadV2Response]. */ + 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: JsonValue = 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(fileUploadV2Response: FileUploadV2Response) = apply { + aiTags = fileUploadV2Response.aiTags.map { it.toMutableList() } + audioCodec = fileUploadV2Response.audioCodec + bitRate = fileUploadV2Response.bitRate + customCoordinates = fileUploadV2Response.customCoordinates + customMetadata = fileUploadV2Response.customMetadata + duration = fileUploadV2Response.duration + embeddedMetadata = fileUploadV2Response.embeddedMetadata + extensionStatus = fileUploadV2Response.extensionStatus + fileId = fileUploadV2Response.fileId + filePath = fileUploadV2Response.filePath + fileType = fileUploadV2Response.fileType + height = fileUploadV2Response.height + isPrivateFile = fileUploadV2Response.isPrivateFile + isPublished = fileUploadV2Response.isPublished + metadata = fileUploadV2Response.metadata + name = fileUploadV2Response.name + size = fileUploadV2Response.size + tags = fileUploadV2Response.tags.map { it.toMutableList() } + thumbnailUrl = fileUploadV2Response.thumbnailUrl + url = fileUploadV2Response.url + versionInfo = fileUploadV2Response.versionInfo + videoCodec = fileUploadV2Response.videoCodec + width = fileUploadV2Response.width + additionalProperties = fileUploadV2Response.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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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 [FileUploadV2Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileUploadV2Response = + FileUploadV2Response( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + 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(): FileUploadV2Response = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + audioCodec() + bitRate() + customCoordinates() + 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) + + (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}" + } + + /** + * 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 + private constructor( + private val aboutCvTermCvId: JsonField, + private val aboutCvTermId: JsonField, + private val aboutCvTermName: JsonField, + private val aboutCvTermRefinedAbout: JsonField, + private val additionalModelInformation: JsonField, + private val applicationRecordVersion: JsonField, + private val artist: JsonField, + private val artworkCircaDateCreated: JsonField, + private val artworkContentDescription: JsonField, + private val artworkContributionDescription: JsonField, + private val artworkCopyrightNotice: JsonField, + private val artworkCopyrightOwnerId: JsonField, + private val artworkCopyrightOwnerName: JsonField, + private val artworkCreator: JsonField>, + private val artworkCreatorId: JsonField>, + private val artworkDateCreated: JsonField, + private val artworkLicensorId: JsonField, + private val artworkLicensorName: JsonField, + private val artworkPhysicalDescription: JsonField, + private val artworkSource: JsonField, + private val artworkSourceInventoryNo: JsonField, + private val artworkSourceInvUrl: JsonField, + private val artworkStylePeriod: JsonField>, + private val artworkTitle: JsonField, + private val authorsPosition: JsonField, + private val byline: JsonField, + private val bylineTitle: JsonField, + private val caption: JsonField, + private val captionAbstract: JsonField, + private val captionWriter: JsonField, + private val city: JsonField, + private val colorSpace: JsonField, + private val componentsConfiguration: JsonField, + private val copyright: JsonField, + private val copyrightNotice: JsonField, + private val copyrightOwnerId: JsonField>, + private val copyrightOwnerName: JsonField>, + private val country: JsonField, + private val countryCode: JsonField, + private val countryPrimaryLocationCode: JsonField, + private val countryPrimaryLocationName: JsonField, + private val creator: JsonField, + private val creatorAddress: JsonField, + private val creatorCity: JsonField, + private val creatorCountry: JsonField, + private val creatorPostalCode: JsonField, + private val creatorRegion: JsonField, + private val creatorWorkEmail: JsonField, + private val creatorWorkTelephone: JsonField, + private val creatorWorkUrl: JsonField, + private val credit: JsonField, + private val dateCreated: JsonField, + private val dateTimeCreated: JsonField, + private val dateTimeOriginal: JsonField, + private val description: JsonField, + private val digitalImageGuid: JsonField, + private val digitalSourceType: JsonField, + private val embeddedEncodedRightsExpr: JsonField, + private val embeddedEncodedRightsExprLangId: JsonField, + private val embeddedEncodedRightsExprType: JsonField, + private val event: JsonField, + private val exifVersion: JsonField, + private val flashpixVersion: JsonField, + private val genreCvId: JsonField, + private val genreCvTermId: JsonField, + private val genreCvTermName: JsonField, + private val genreCvTermRefinedAbout: JsonField, + private val headline: JsonField, + private val imageCreatorId: JsonField, + private val imageCreatorImageId: JsonField, + private val imageCreatorName: JsonField, + private val imageDescription: JsonField, + private val imageRegionBoundaryH: JsonField>, + private val imageRegionBoundaryRx: JsonField>, + private val imageRegionBoundaryShape: JsonField>, + private val imageRegionBoundaryUnit: JsonField>, + private val imageRegionBoundaryVerticesX: JsonField>, + private val imageRegionBoundaryVerticesY: JsonField>, + private val imageRegionBoundaryW: JsonField>, + private val imageRegionBoundaryX: JsonField>, + private val imageRegionBoundaryY: JsonField>, + private val imageRegionCtypeIdentifier: JsonField>, + private val imageRegionCtypeName: JsonField>, + private val imageRegionId: JsonField>, + private val imageRegionName: JsonField>, + private val imageRegionOrganisationInImageName: JsonField>, + private val imageRegionPersonInImage: JsonField>, + private val imageRegionRoleIdentifier: JsonField>, + private val imageRegionRoleName: JsonField>, + private val imageSupplierId: JsonField, + private val imageSupplierImageId: JsonField, + private val imageSupplierName: JsonField, + private val instructions: JsonField, + private val intellectualGenre: JsonField, + private val keywords: JsonField>, + private val licensorCity: JsonField>, + private val licensorCountry: JsonField>, + private val licensorEmail: JsonField>, + private val licensorExtendedAddress: JsonField>, + private val licensorId: JsonField>, + private val licensorName: JsonField>, + private val licensorPostalCode: JsonField>, + private val licensorRegion: JsonField>, + private val licensorStreetAddress: JsonField>, + private val licensorTelephone1: JsonField>, + private val licensorTelephone2: JsonField>, + private val licensorUrl: JsonField>, + private val linkedEncodedRightsExpr: JsonField, + private val linkedEncodedRightsExprLangId: JsonField, + private val linkedEncodedRightsExprType: JsonField, + private val location: JsonField, + private val locationCreatedCity: JsonField, + private val locationCreatedCountryCode: JsonField, + private val locationCreatedCountryName: JsonField, + private val locationCreatedGpsAltitude: JsonField, + private val locationCreatedGpsLatitude: JsonField, + private val locationCreatedGpsLongitude: JsonField, + private val locationCreatedLocationId: JsonField, + private val locationCreatedLocationName: JsonField, + private val locationCreatedProvinceState: JsonField, + private val locationCreatedSublocation: JsonField, + private val locationCreatedWorldRegion: JsonField, + private val locationShownCity: JsonField>, + private val locationShownCountryCode: JsonField>, + private val locationShownCountryName: JsonField>, + private val locationShownGpsAltitude: JsonField>, + private val locationShownGpsLatitude: JsonField>, + private val locationShownGpsLongitude: JsonField>, + private val locationShownLocationId: JsonField>, + private val locationShownLocationName: JsonField>, + private val locationShownProvinceState: JsonField>, + private val locationShownSublocation: JsonField>, + private val locationShownWorldRegion: JsonField>, + private val maxAvailHeight: JsonField, + private val maxAvailWidth: JsonField, + private val modelAge: JsonField>, + private val modelReleaseId: JsonField>, + private val objectAttributeReference: JsonField, + private val objectName: JsonField, + private val offsetTimeOriginal: JsonField, + private val organisationInImageCode: JsonField>, + private val organisationInImageName: JsonField>, + private val orientation: JsonField, + private val originalTransmissionReference: JsonField, + private val personInImage: JsonField>, + private val personInImageCvTermCvId: JsonField>, + private val personInImageCvTermId: JsonField>, + private val personInImageCvTermName: JsonField>, + private val personInImageCvTermRefinedAbout: JsonField>, + private val personInImageDescription: JsonField>, + private val personInImageId: JsonField>, + private val personInImageName: JsonField>, + private val productInImageDescription: JsonField>, + private val productInImageGtin: JsonField>, + private val productInImageName: JsonField>, + private val propertyReleaseId: JsonField>, + private val provinceState: JsonField, + private val rating: JsonField, + private val registryEntryRole: JsonField>, + private val registryItemId: JsonField>, + private val registryOrganisationId: JsonField>, + private val resolutionUnit: JsonField, + private val rights: JsonField, + private val scene: JsonField>, + private val source: JsonField, + private val specialInstructions: JsonField, + private val state: JsonField, + private val subject: JsonField>, + private val subjectCode: JsonField>, + private val subjectReference: JsonField>, + private val sublocation: JsonField, + private val timeCreated: JsonField, + private val title: JsonField, + private val transmissionReference: JsonField, + private val usageTerms: JsonField, + private val webStatement: JsonField, + private val writer: JsonField, + private val writerEditor: JsonField, + private val xResolution: JsonField, + private val yResolution: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("AboutCvTermCvId") + @ExcludeMissing + aboutCvTermCvId: JsonField = JsonMissing.of(), + @JsonProperty("AboutCvTermId") + @ExcludeMissing + aboutCvTermId: JsonField = JsonMissing.of(), + @JsonProperty("AboutCvTermName") + @ExcludeMissing + aboutCvTermName: JsonField = JsonMissing.of(), + @JsonProperty("AboutCvTermRefinedAbout") + @ExcludeMissing + aboutCvTermRefinedAbout: JsonField = JsonMissing.of(), + @JsonProperty("AdditionalModelInformation") + @ExcludeMissing + additionalModelInformation: JsonField = JsonMissing.of(), + @JsonProperty("ApplicationRecordVersion") + @ExcludeMissing + applicationRecordVersion: JsonField = JsonMissing.of(), + @JsonProperty("Artist") @ExcludeMissing artist: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCircaDateCreated") + @ExcludeMissing + artworkCircaDateCreated: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkContentDescription") + @ExcludeMissing + artworkContentDescription: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkContributionDescription") + @ExcludeMissing + artworkContributionDescription: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCopyrightNotice") + @ExcludeMissing + artworkCopyrightNotice: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCopyrightOwnerID") + @ExcludeMissing + artworkCopyrightOwnerId: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCopyrightOwnerName") + @ExcludeMissing + artworkCopyrightOwnerName: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkCreator") + @ExcludeMissing + artworkCreator: JsonField> = JsonMissing.of(), + @JsonProperty("ArtworkCreatorID") + @ExcludeMissing + artworkCreatorId: JsonField> = JsonMissing.of(), + @JsonProperty("ArtworkDateCreated") + @ExcludeMissing + artworkDateCreated: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkLicensorID") + @ExcludeMissing + artworkLicensorId: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkLicensorName") + @ExcludeMissing + artworkLicensorName: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkPhysicalDescription") + @ExcludeMissing + artworkPhysicalDescription: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkSource") + @ExcludeMissing + artworkSource: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkSourceInventoryNo") + @ExcludeMissing + artworkSourceInventoryNo: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkSourceInvURL") + @ExcludeMissing + artworkSourceInvUrl: JsonField = JsonMissing.of(), + @JsonProperty("ArtworkStylePeriod") + @ExcludeMissing + artworkStylePeriod: JsonField> = JsonMissing.of(), + @JsonProperty("ArtworkTitle") + @ExcludeMissing + artworkTitle: JsonField = JsonMissing.of(), + @JsonProperty("AuthorsPosition") + @ExcludeMissing + authorsPosition: JsonField = JsonMissing.of(), + @JsonProperty("Byline") @ExcludeMissing byline: JsonField = JsonMissing.of(), + @JsonProperty("BylineTitle") + @ExcludeMissing + bylineTitle: JsonField = JsonMissing.of(), + @JsonProperty("Caption") @ExcludeMissing caption: JsonField = JsonMissing.of(), + @JsonProperty("CaptionAbstract") + @ExcludeMissing + captionAbstract: JsonField = JsonMissing.of(), + @JsonProperty("CaptionWriter") + @ExcludeMissing + captionWriter: JsonField = JsonMissing.of(), + @JsonProperty("City") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("ColorSpace") + @ExcludeMissing + colorSpace: JsonField = JsonMissing.of(), + @JsonProperty("ComponentsConfiguration") + @ExcludeMissing + componentsConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("Copyright") + @ExcludeMissing + copyright: JsonField = JsonMissing.of(), + @JsonProperty("CopyrightNotice") + @ExcludeMissing + copyrightNotice: JsonField = JsonMissing.of(), + @JsonProperty("CopyrightOwnerID") + @ExcludeMissing + copyrightOwnerId: JsonField> = JsonMissing.of(), + @JsonProperty("CopyrightOwnerName") + @ExcludeMissing + copyrightOwnerName: JsonField> = JsonMissing.of(), + @JsonProperty("Country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("CountryCode") + @ExcludeMissing + countryCode: JsonField = JsonMissing.of(), + @JsonProperty("CountryPrimaryLocationCode") + @ExcludeMissing + countryPrimaryLocationCode: JsonField = JsonMissing.of(), + @JsonProperty("CountryPrimaryLocationName") + @ExcludeMissing + countryPrimaryLocationName: JsonField = JsonMissing.of(), + @JsonProperty("Creator") @ExcludeMissing creator: JsonField = JsonMissing.of(), + @JsonProperty("CreatorAddress") + @ExcludeMissing + creatorAddress: JsonField = JsonMissing.of(), + @JsonProperty("CreatorCity") + @ExcludeMissing + creatorCity: JsonField = JsonMissing.of(), + @JsonProperty("CreatorCountry") + @ExcludeMissing + creatorCountry: JsonField = JsonMissing.of(), + @JsonProperty("CreatorPostalCode") + @ExcludeMissing + creatorPostalCode: JsonField = JsonMissing.of(), + @JsonProperty("CreatorRegion") + @ExcludeMissing + creatorRegion: JsonField = JsonMissing.of(), + @JsonProperty("CreatorWorkEmail") + @ExcludeMissing + creatorWorkEmail: JsonField = JsonMissing.of(), + @JsonProperty("CreatorWorkTelephone") + @ExcludeMissing + creatorWorkTelephone: JsonField = JsonMissing.of(), + @JsonProperty("CreatorWorkURL") + @ExcludeMissing + creatorWorkUrl: JsonField = JsonMissing.of(), + @JsonProperty("Credit") @ExcludeMissing credit: JsonField = JsonMissing.of(), + @JsonProperty("DateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("DateTimeCreated") + @ExcludeMissing + dateTimeCreated: JsonField = JsonMissing.of(), + @JsonProperty("DateTimeOriginal") + @ExcludeMissing + dateTimeOriginal: JsonField = JsonMissing.of(), + @JsonProperty("Description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("DigitalImageGUID") + @ExcludeMissing + digitalImageGuid: JsonField = JsonMissing.of(), + @JsonProperty("DigitalSourceType") + @ExcludeMissing + digitalSourceType: JsonField = JsonMissing.of(), + @JsonProperty("EmbeddedEncodedRightsExpr") + @ExcludeMissing + embeddedEncodedRightsExpr: JsonField = JsonMissing.of(), + @JsonProperty("EmbeddedEncodedRightsExprLangID") + @ExcludeMissing + embeddedEncodedRightsExprLangId: JsonField = JsonMissing.of(), + @JsonProperty("EmbeddedEncodedRightsExprType") + @ExcludeMissing + embeddedEncodedRightsExprType: JsonField = JsonMissing.of(), + @JsonProperty("Event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("ExifVersion") + @ExcludeMissing + exifVersion: JsonField = JsonMissing.of(), + @JsonProperty("FlashpixVersion") + @ExcludeMissing + flashpixVersion: JsonField = JsonMissing.of(), + @JsonProperty("GenreCvId") + @ExcludeMissing + genreCvId: JsonField = JsonMissing.of(), + @JsonProperty("GenreCvTermId") + @ExcludeMissing + genreCvTermId: JsonField = JsonMissing.of(), + @JsonProperty("GenreCvTermName") + @ExcludeMissing + genreCvTermName: JsonField = JsonMissing.of(), + @JsonProperty("GenreCvTermRefinedAbout") + @ExcludeMissing + genreCvTermRefinedAbout: JsonField = JsonMissing.of(), + @JsonProperty("Headline") + @ExcludeMissing + headline: JsonField = JsonMissing.of(), + @JsonProperty("ImageCreatorID") + @ExcludeMissing + imageCreatorId: JsonField = JsonMissing.of(), + @JsonProperty("ImageCreatorImageID") + @ExcludeMissing + imageCreatorImageId: JsonField = JsonMissing.of(), + @JsonProperty("ImageCreatorName") + @ExcludeMissing + imageCreatorName: JsonField = JsonMissing.of(), + @JsonProperty("ImageDescription") + @ExcludeMissing + imageDescription: JsonField = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryH") + @ExcludeMissing + imageRegionBoundaryH: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryRx") + @ExcludeMissing + imageRegionBoundaryRx: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryShape") + @ExcludeMissing + imageRegionBoundaryShape: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryUnit") + @ExcludeMissing + imageRegionBoundaryUnit: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryVerticesX") + @ExcludeMissing + imageRegionBoundaryVerticesX: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryVerticesY") + @ExcludeMissing + imageRegionBoundaryVerticesY: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryW") + @ExcludeMissing + imageRegionBoundaryW: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryX") + @ExcludeMissing + imageRegionBoundaryX: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionBoundaryY") + @ExcludeMissing + imageRegionBoundaryY: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionCtypeIdentifier") + @ExcludeMissing + imageRegionCtypeIdentifier: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionCtypeName") + @ExcludeMissing + imageRegionCtypeName: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionID") + @ExcludeMissing + imageRegionId: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionName") + @ExcludeMissing + imageRegionName: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionOrganisationInImageName") + @ExcludeMissing + imageRegionOrganisationInImageName: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionPersonInImage") + @ExcludeMissing + imageRegionPersonInImage: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionRoleIdentifier") + @ExcludeMissing + imageRegionRoleIdentifier: JsonField> = JsonMissing.of(), + @JsonProperty("ImageRegionRoleName") + @ExcludeMissing + imageRegionRoleName: JsonField> = JsonMissing.of(), + @JsonProperty("ImageSupplierID") + @ExcludeMissing + imageSupplierId: JsonField = JsonMissing.of(), + @JsonProperty("ImageSupplierImageID") + @ExcludeMissing + imageSupplierImageId: JsonField = JsonMissing.of(), + @JsonProperty("ImageSupplierName") + @ExcludeMissing + imageSupplierName: JsonField = JsonMissing.of(), + @JsonProperty("Instructions") + @ExcludeMissing + instructions: JsonField = JsonMissing.of(), + @JsonProperty("IntellectualGenre") + @ExcludeMissing + intellectualGenre: JsonField = JsonMissing.of(), + @JsonProperty("Keywords") + @ExcludeMissing + keywords: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorCity") + @ExcludeMissing + licensorCity: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorCountry") + @ExcludeMissing + licensorCountry: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorEmail") + @ExcludeMissing + licensorEmail: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorExtendedAddress") + @ExcludeMissing + licensorExtendedAddress: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorID") + @ExcludeMissing + licensorId: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorName") + @ExcludeMissing + licensorName: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorPostalCode") + @ExcludeMissing + licensorPostalCode: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorRegion") + @ExcludeMissing + licensorRegion: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorStreetAddress") + @ExcludeMissing + licensorStreetAddress: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorTelephone1") + @ExcludeMissing + licensorTelephone1: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorTelephone2") + @ExcludeMissing + licensorTelephone2: JsonField> = JsonMissing.of(), + @JsonProperty("LicensorURL") + @ExcludeMissing + licensorUrl: JsonField> = JsonMissing.of(), + @JsonProperty("LinkedEncodedRightsExpr") + @ExcludeMissing + linkedEncodedRightsExpr: JsonField = JsonMissing.of(), + @JsonProperty("LinkedEncodedRightsExprLangID") + @ExcludeMissing + linkedEncodedRightsExprLangId: JsonField = JsonMissing.of(), + @JsonProperty("LinkedEncodedRightsExprType") + @ExcludeMissing + linkedEncodedRightsExprType: JsonField = JsonMissing.of(), + @JsonProperty("Location") + @ExcludeMissing + location: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedCity") + @ExcludeMissing + locationCreatedCity: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedCountryCode") + @ExcludeMissing + locationCreatedCountryCode: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedCountryName") + @ExcludeMissing + locationCreatedCountryName: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedGPSAltitude") + @ExcludeMissing + locationCreatedGpsAltitude: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedGPSLatitude") + @ExcludeMissing + locationCreatedGpsLatitude: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedGPSLongitude") + @ExcludeMissing + locationCreatedGpsLongitude: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedLocationId") + @ExcludeMissing + locationCreatedLocationId: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedLocationName") + @ExcludeMissing + locationCreatedLocationName: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedProvinceState") + @ExcludeMissing + locationCreatedProvinceState: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedSublocation") + @ExcludeMissing + locationCreatedSublocation: JsonField = JsonMissing.of(), + @JsonProperty("LocationCreatedWorldRegion") + @ExcludeMissing + locationCreatedWorldRegion: JsonField = JsonMissing.of(), + @JsonProperty("LocationShownCity") + @ExcludeMissing + locationShownCity: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownCountryCode") + @ExcludeMissing + locationShownCountryCode: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownCountryName") + @ExcludeMissing + locationShownCountryName: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownGPSAltitude") + @ExcludeMissing + locationShownGpsAltitude: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownGPSLatitude") + @ExcludeMissing + locationShownGpsLatitude: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownGPSLongitude") + @ExcludeMissing + locationShownGpsLongitude: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownLocationId") + @ExcludeMissing + locationShownLocationId: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownLocationName") + @ExcludeMissing + locationShownLocationName: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownProvinceState") + @ExcludeMissing + locationShownProvinceState: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownSublocation") + @ExcludeMissing + locationShownSublocation: JsonField> = JsonMissing.of(), + @JsonProperty("LocationShownWorldRegion") + @ExcludeMissing + locationShownWorldRegion: JsonField> = JsonMissing.of(), + @JsonProperty("MaxAvailHeight") + @ExcludeMissing + maxAvailHeight: JsonField = JsonMissing.of(), + @JsonProperty("MaxAvailWidth") + @ExcludeMissing + maxAvailWidth: JsonField = JsonMissing.of(), + @JsonProperty("ModelAge") + @ExcludeMissing + modelAge: JsonField> = JsonMissing.of(), + @JsonProperty("ModelReleaseID") + @ExcludeMissing + modelReleaseId: JsonField> = JsonMissing.of(), + @JsonProperty("ObjectAttributeReference") + @ExcludeMissing + objectAttributeReference: JsonField = JsonMissing.of(), + @JsonProperty("ObjectName") + @ExcludeMissing + objectName: JsonField = JsonMissing.of(), + @JsonProperty("OffsetTimeOriginal") + @ExcludeMissing + offsetTimeOriginal: JsonField = JsonMissing.of(), + @JsonProperty("OrganisationInImageCode") + @ExcludeMissing + organisationInImageCode: JsonField> = JsonMissing.of(), + @JsonProperty("OrganisationInImageName") + @ExcludeMissing + organisationInImageName: JsonField> = JsonMissing.of(), + @JsonProperty("Orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("OriginalTransmissionReference") + @ExcludeMissing + originalTransmissionReference: JsonField = JsonMissing.of(), + @JsonProperty("PersonInImage") + @ExcludeMissing + personInImage: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageCvTermCvId") + @ExcludeMissing + personInImageCvTermCvId: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageCvTermId") + @ExcludeMissing + personInImageCvTermId: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageCvTermName") + @ExcludeMissing + personInImageCvTermName: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageCvTermRefinedAbout") + @ExcludeMissing + personInImageCvTermRefinedAbout: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageDescription") + @ExcludeMissing + personInImageDescription: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageId") + @ExcludeMissing + personInImageId: JsonField> = JsonMissing.of(), + @JsonProperty("PersonInImageName") + @ExcludeMissing + personInImageName: JsonField> = JsonMissing.of(), + @JsonProperty("ProductInImageDescription") + @ExcludeMissing + productInImageDescription: JsonField> = JsonMissing.of(), + @JsonProperty("ProductInImageGTIN") + @ExcludeMissing + productInImageGtin: JsonField> = JsonMissing.of(), + @JsonProperty("ProductInImageName") + @ExcludeMissing + productInImageName: JsonField> = JsonMissing.of(), + @JsonProperty("PropertyReleaseID") + @ExcludeMissing + propertyReleaseId: JsonField> = JsonMissing.of(), + @JsonProperty("ProvinceState") + @ExcludeMissing + provinceState: JsonField = JsonMissing.of(), + @JsonProperty("Rating") @ExcludeMissing rating: JsonField = JsonMissing.of(), + @JsonProperty("RegistryEntryRole") + @ExcludeMissing + registryEntryRole: JsonField> = JsonMissing.of(), + @JsonProperty("RegistryItemID") + @ExcludeMissing + registryItemId: JsonField> = JsonMissing.of(), + @JsonProperty("RegistryOrganisationID") + @ExcludeMissing + registryOrganisationId: JsonField> = JsonMissing.of(), + @JsonProperty("ResolutionUnit") + @ExcludeMissing + resolutionUnit: JsonField = JsonMissing.of(), + @JsonProperty("Rights") @ExcludeMissing rights: JsonField = JsonMissing.of(), + @JsonProperty("Scene") + @ExcludeMissing + scene: JsonField> = JsonMissing.of(), + @JsonProperty("Source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("SpecialInstructions") + @ExcludeMissing + specialInstructions: JsonField = JsonMissing.of(), + @JsonProperty("State") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("Subject") + @ExcludeMissing + subject: JsonField> = JsonMissing.of(), + @JsonProperty("SubjectCode") + @ExcludeMissing + subjectCode: JsonField> = JsonMissing.of(), + @JsonProperty("SubjectReference") + @ExcludeMissing + subjectReference: JsonField> = JsonMissing.of(), + @JsonProperty("Sublocation") + @ExcludeMissing + sublocation: JsonField = JsonMissing.of(), + @JsonProperty("TimeCreated") + @ExcludeMissing + timeCreated: JsonField = JsonMissing.of(), + @JsonProperty("Title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("TransmissionReference") + @ExcludeMissing + transmissionReference: JsonField = JsonMissing.of(), + @JsonProperty("UsageTerms") + @ExcludeMissing + usageTerms: JsonField = JsonMissing.of(), + @JsonProperty("WebStatement") + @ExcludeMissing + webStatement: JsonField = JsonMissing.of(), + @JsonProperty("Writer") @ExcludeMissing writer: JsonField = JsonMissing.of(), + @JsonProperty("WriterEditor") + @ExcludeMissing + writerEditor: JsonField = JsonMissing.of(), + @JsonProperty("XResolution") + @ExcludeMissing + xResolution: JsonField = JsonMissing.of(), + @JsonProperty("YResolution") + @ExcludeMissing + yResolution: JsonField = JsonMissing.of(), + ) : this( + aboutCvTermCvId, + aboutCvTermId, + aboutCvTermName, + aboutCvTermRefinedAbout, + additionalModelInformation, + applicationRecordVersion, + artist, + artworkCircaDateCreated, + artworkContentDescription, + artworkContributionDescription, + artworkCopyrightNotice, + artworkCopyrightOwnerId, + artworkCopyrightOwnerName, + artworkCreator, + artworkCreatorId, + artworkDateCreated, + artworkLicensorId, + artworkLicensorName, + artworkPhysicalDescription, + artworkSource, + artworkSourceInventoryNo, + artworkSourceInvUrl, + artworkStylePeriod, + artworkTitle, + authorsPosition, + byline, + bylineTitle, + caption, + captionAbstract, + captionWriter, + city, + colorSpace, + componentsConfiguration, + copyright, + copyrightNotice, + copyrightOwnerId, + copyrightOwnerName, + country, + countryCode, + countryPrimaryLocationCode, + countryPrimaryLocationName, + creator, + creatorAddress, + creatorCity, + creatorCountry, + creatorPostalCode, + creatorRegion, + creatorWorkEmail, + creatorWorkTelephone, + creatorWorkUrl, + credit, + dateCreated, + dateTimeCreated, + dateTimeOriginal, + description, + digitalImageGuid, + digitalSourceType, + embeddedEncodedRightsExpr, + embeddedEncodedRightsExprLangId, + embeddedEncodedRightsExprType, + event, + exifVersion, + flashpixVersion, + genreCvId, + genreCvTermId, + genreCvTermName, + genreCvTermRefinedAbout, + headline, + imageCreatorId, + imageCreatorImageId, + imageCreatorName, + imageDescription, + imageRegionBoundaryH, + imageRegionBoundaryRx, + imageRegionBoundaryShape, + imageRegionBoundaryUnit, + imageRegionBoundaryVerticesX, + imageRegionBoundaryVerticesY, + imageRegionBoundaryW, + imageRegionBoundaryX, + imageRegionBoundaryY, + imageRegionCtypeIdentifier, + imageRegionCtypeName, + imageRegionId, + imageRegionName, + imageRegionOrganisationInImageName, + imageRegionPersonInImage, + imageRegionRoleIdentifier, + imageRegionRoleName, + imageSupplierId, + imageSupplierImageId, + imageSupplierName, + instructions, + intellectualGenre, + keywords, + licensorCity, + licensorCountry, + licensorEmail, + licensorExtendedAddress, + licensorId, + licensorName, + licensorPostalCode, + licensorRegion, + licensorStreetAddress, + licensorTelephone1, + licensorTelephone2, + licensorUrl, + linkedEncodedRightsExpr, + linkedEncodedRightsExprLangId, + linkedEncodedRightsExprType, + location, + locationCreatedCity, + locationCreatedCountryCode, + locationCreatedCountryName, + locationCreatedGpsAltitude, + locationCreatedGpsLatitude, + locationCreatedGpsLongitude, + locationCreatedLocationId, + locationCreatedLocationName, + locationCreatedProvinceState, + locationCreatedSublocation, + locationCreatedWorldRegion, + locationShownCity, + locationShownCountryCode, + locationShownCountryName, + locationShownGpsAltitude, + locationShownGpsLatitude, + locationShownGpsLongitude, + locationShownLocationId, + locationShownLocationName, + locationShownProvinceState, + locationShownSublocation, + locationShownWorldRegion, + maxAvailHeight, + maxAvailWidth, + modelAge, + modelReleaseId, + objectAttributeReference, + objectName, + offsetTimeOriginal, + organisationInImageCode, + organisationInImageName, + orientation, + originalTransmissionReference, + personInImage, + personInImageCvTermCvId, + personInImageCvTermId, + personInImageCvTermName, + personInImageCvTermRefinedAbout, + personInImageDescription, + personInImageId, + personInImageName, + productInImageDescription, + productInImageGtin, + productInImageName, + propertyReleaseId, + provinceState, + rating, + registryEntryRole, + registryItemId, + registryOrganisationId, + resolutionUnit, + rights, + scene, + source, + specialInstructions, + state, + subject, + subjectCode, + subjectReference, + sublocation, + timeCreated, + title, + transmissionReference, + usageTerms, + webStatement, + writer, + writerEditor, + xResolution, + yResolution, + mutableMapOf(), + ) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aboutCvTermCvId(): Optional = aboutCvTermCvId.getOptional("AboutCvTermCvId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aboutCvTermId(): Optional = aboutCvTermId.getOptional("AboutCvTermId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aboutCvTermName(): Optional = aboutCvTermName.getOptional("AboutCvTermName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aboutCvTermRefinedAbout(): Optional = + aboutCvTermRefinedAbout.getOptional("AboutCvTermRefinedAbout") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun additionalModelInformation(): Optional = + additionalModelInformation.getOptional("AdditionalModelInformation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun applicationRecordVersion(): Optional = + applicationRecordVersion.getOptional("ApplicationRecordVersion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artist(): Optional = artist.getOptional("Artist") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCircaDateCreated(): Optional = + artworkCircaDateCreated.getOptional("ArtworkCircaDateCreated") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkContentDescription(): Optional = + artworkContentDescription.getOptional("ArtworkContentDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkContributionDescription(): Optional = + artworkContributionDescription.getOptional("ArtworkContributionDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCopyrightNotice(): Optional = + artworkCopyrightNotice.getOptional("ArtworkCopyrightNotice") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCopyrightOwnerId(): Optional = + artworkCopyrightOwnerId.getOptional("ArtworkCopyrightOwnerID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCopyrightOwnerName(): Optional = + artworkCopyrightOwnerName.getOptional("ArtworkCopyrightOwnerName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCreator(): Optional> = artworkCreator.getOptional("ArtworkCreator") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkCreatorId(): Optional> = + artworkCreatorId.getOptional("ArtworkCreatorID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkDateCreated(): Optional = + artworkDateCreated.getOptional("ArtworkDateCreated") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkLicensorId(): Optional = + artworkLicensorId.getOptional("ArtworkLicensorID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkLicensorName(): Optional = + artworkLicensorName.getOptional("ArtworkLicensorName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkPhysicalDescription(): Optional = + artworkPhysicalDescription.getOptional("ArtworkPhysicalDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkSource(): Optional = artworkSource.getOptional("ArtworkSource") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkSourceInventoryNo(): Optional = + artworkSourceInventoryNo.getOptional("ArtworkSourceInventoryNo") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkSourceInvUrl(): Optional = + artworkSourceInvUrl.getOptional("ArtworkSourceInvURL") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkStylePeriod(): Optional> = + artworkStylePeriod.getOptional("ArtworkStylePeriod") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun artworkTitle(): Optional = artworkTitle.getOptional("ArtworkTitle") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun authorsPosition(): Optional = authorsPosition.getOptional("AuthorsPosition") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun byline(): Optional = byline.getOptional("Byline") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun bylineTitle(): Optional = bylineTitle.getOptional("BylineTitle") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun caption(): Optional = caption.getOptional("Caption") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun captionAbstract(): Optional = captionAbstract.getOptional("CaptionAbstract") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun captionWriter(): Optional = captionWriter.getOptional("CaptionWriter") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun city(): Optional = city.getOptional("City") + + /** + * @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 componentsConfiguration(): Optional = + componentsConfiguration.getOptional("ComponentsConfiguration") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun copyright(): Optional = copyright.getOptional("Copyright") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun copyrightNotice(): Optional = copyrightNotice.getOptional("CopyrightNotice") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun copyrightOwnerId(): Optional> = + copyrightOwnerId.getOptional("CopyrightOwnerID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun copyrightOwnerName(): Optional> = + copyrightOwnerName.getOptional("CopyrightOwnerName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun country(): Optional = country.getOptional("Country") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun countryCode(): Optional = countryCode.getOptional("CountryCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun countryPrimaryLocationCode(): Optional = + countryPrimaryLocationCode.getOptional("CountryPrimaryLocationCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun countryPrimaryLocationName(): Optional = + countryPrimaryLocationName.getOptional("CountryPrimaryLocationName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creator(): Optional = creator.getOptional("Creator") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorAddress(): Optional = creatorAddress.getOptional("CreatorAddress") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorCity(): Optional = creatorCity.getOptional("CreatorCity") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorCountry(): Optional = creatorCountry.getOptional("CreatorCountry") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorPostalCode(): Optional = + creatorPostalCode.getOptional("CreatorPostalCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorRegion(): Optional = creatorRegion.getOptional("CreatorRegion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorWorkEmail(): Optional = creatorWorkEmail.getOptional("CreatorWorkEmail") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorWorkTelephone(): Optional = + creatorWorkTelephone.getOptional("CreatorWorkTelephone") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorWorkUrl(): Optional = creatorWorkUrl.getOptional("CreatorWorkURL") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credit(): Optional = credit.getOptional("Credit") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateCreated(): Optional = dateCreated.getOptional("DateCreated") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateTimeCreated(): Optional = + dateTimeCreated.getOptional("DateTimeCreated") + + /** + * @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 description(): Optional = description.getOptional("Description") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun digitalImageGuid(): Optional = digitalImageGuid.getOptional("DigitalImageGUID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun digitalSourceType(): Optional = + digitalSourceType.getOptional("DigitalSourceType") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun embeddedEncodedRightsExpr(): Optional = + embeddedEncodedRightsExpr.getOptional("EmbeddedEncodedRightsExpr") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun embeddedEncodedRightsExprLangId(): Optional = + embeddedEncodedRightsExprLangId.getOptional("EmbeddedEncodedRightsExprLangID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun embeddedEncodedRightsExprType(): Optional = + embeddedEncodedRightsExprType.getOptional("EmbeddedEncodedRightsExprType") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun event(): Optional = event.getOptional("Event") + + /** + * @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 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 genreCvId(): Optional = genreCvId.getOptional("GenreCvId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun genreCvTermId(): Optional = genreCvTermId.getOptional("GenreCvTermId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun genreCvTermName(): Optional = genreCvTermName.getOptional("GenreCvTermName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun genreCvTermRefinedAbout(): Optional = + genreCvTermRefinedAbout.getOptional("GenreCvTermRefinedAbout") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun headline(): Optional = headline.getOptional("Headline") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageCreatorId(): Optional = imageCreatorId.getOptional("ImageCreatorID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageCreatorImageId(): Optional = + imageCreatorImageId.getOptional("ImageCreatorImageID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageCreatorName(): Optional = imageCreatorName.getOptional("ImageCreatorName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageDescription(): Optional = imageDescription.getOptional("ImageDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryH(): Optional> = + imageRegionBoundaryH.getOptional("ImageRegionBoundaryH") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryRx(): Optional> = + imageRegionBoundaryRx.getOptional("ImageRegionBoundaryRx") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryShape(): Optional> = + imageRegionBoundaryShape.getOptional("ImageRegionBoundaryShape") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryUnit(): Optional> = + imageRegionBoundaryUnit.getOptional("ImageRegionBoundaryUnit") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryVerticesX(): Optional> = + imageRegionBoundaryVerticesX.getOptional("ImageRegionBoundaryVerticesX") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryVerticesY(): Optional> = + imageRegionBoundaryVerticesY.getOptional("ImageRegionBoundaryVerticesY") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryW(): Optional> = + imageRegionBoundaryW.getOptional("ImageRegionBoundaryW") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryX(): Optional> = + imageRegionBoundaryX.getOptional("ImageRegionBoundaryX") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionBoundaryY(): Optional> = + imageRegionBoundaryY.getOptional("ImageRegionBoundaryY") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionCtypeIdentifier(): Optional> = + imageRegionCtypeIdentifier.getOptional("ImageRegionCtypeIdentifier") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionCtypeName(): Optional> = + imageRegionCtypeName.getOptional("ImageRegionCtypeName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionId(): Optional> = imageRegionId.getOptional("ImageRegionID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionName(): Optional> = + imageRegionName.getOptional("ImageRegionName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionOrganisationInImageName(): Optional> = + imageRegionOrganisationInImageName.getOptional("ImageRegionOrganisationInImageName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionPersonInImage(): Optional> = + imageRegionPersonInImage.getOptional("ImageRegionPersonInImage") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionRoleIdentifier(): Optional> = + imageRegionRoleIdentifier.getOptional("ImageRegionRoleIdentifier") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageRegionRoleName(): Optional> = + imageRegionRoleName.getOptional("ImageRegionRoleName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageSupplierId(): Optional = imageSupplierId.getOptional("ImageSupplierID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageSupplierImageId(): Optional = + imageSupplierImageId.getOptional("ImageSupplierImageID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun imageSupplierName(): Optional = + imageSupplierName.getOptional("ImageSupplierName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun instructions(): Optional = instructions.getOptional("Instructions") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun intellectualGenre(): Optional = + intellectualGenre.getOptional("IntellectualGenre") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun keywords(): Optional> = keywords.getOptional("Keywords") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorCity(): Optional> = licensorCity.getOptional("LicensorCity") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorCountry(): Optional> = + licensorCountry.getOptional("LicensorCountry") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorEmail(): Optional> = licensorEmail.getOptional("LicensorEmail") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorExtendedAddress(): Optional> = + licensorExtendedAddress.getOptional("LicensorExtendedAddress") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorId(): Optional> = licensorId.getOptional("LicensorID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorName(): Optional> = licensorName.getOptional("LicensorName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorPostalCode(): Optional> = + licensorPostalCode.getOptional("LicensorPostalCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorRegion(): Optional> = licensorRegion.getOptional("LicensorRegion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorStreetAddress(): Optional> = + licensorStreetAddress.getOptional("LicensorStreetAddress") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorTelephone1(): Optional> = + licensorTelephone1.getOptional("LicensorTelephone1") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorTelephone2(): Optional> = + licensorTelephone2.getOptional("LicensorTelephone2") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun licensorUrl(): Optional> = licensorUrl.getOptional("LicensorURL") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedEncodedRightsExpr(): Optional = + linkedEncodedRightsExpr.getOptional("LinkedEncodedRightsExpr") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedEncodedRightsExprLangId(): Optional = + linkedEncodedRightsExprLangId.getOptional("LinkedEncodedRightsExprLangID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedEncodedRightsExprType(): Optional = + linkedEncodedRightsExprType.getOptional("LinkedEncodedRightsExprType") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun location(): Optional = location.getOptional("Location") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedCity(): Optional = + locationCreatedCity.getOptional("LocationCreatedCity") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedCountryCode(): Optional = + locationCreatedCountryCode.getOptional("LocationCreatedCountryCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedCountryName(): Optional = + locationCreatedCountryName.getOptional("LocationCreatedCountryName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedGpsAltitude(): Optional = + locationCreatedGpsAltitude.getOptional("LocationCreatedGPSAltitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedGpsLatitude(): Optional = + locationCreatedGpsLatitude.getOptional("LocationCreatedGPSLatitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedGpsLongitude(): Optional = + locationCreatedGpsLongitude.getOptional("LocationCreatedGPSLongitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedLocationId(): Optional = + locationCreatedLocationId.getOptional("LocationCreatedLocationId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedLocationName(): Optional = + locationCreatedLocationName.getOptional("LocationCreatedLocationName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedProvinceState(): Optional = + locationCreatedProvinceState.getOptional("LocationCreatedProvinceState") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedSublocation(): Optional = + locationCreatedSublocation.getOptional("LocationCreatedSublocation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationCreatedWorldRegion(): Optional = + locationCreatedWorldRegion.getOptional("LocationCreatedWorldRegion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownCity(): Optional> = + locationShownCity.getOptional("LocationShownCity") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownCountryCode(): Optional> = + locationShownCountryCode.getOptional("LocationShownCountryCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownCountryName(): Optional> = + locationShownCountryName.getOptional("LocationShownCountryName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownGpsAltitude(): Optional> = + locationShownGpsAltitude.getOptional("LocationShownGPSAltitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownGpsLatitude(): Optional> = + locationShownGpsLatitude.getOptional("LocationShownGPSLatitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownGpsLongitude(): Optional> = + locationShownGpsLongitude.getOptional("LocationShownGPSLongitude") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownLocationId(): Optional> = + locationShownLocationId.getOptional("LocationShownLocationId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownLocationName(): Optional> = + locationShownLocationName.getOptional("LocationShownLocationName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownProvinceState(): Optional> = + locationShownProvinceState.getOptional("LocationShownProvinceState") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownSublocation(): Optional> = + locationShownSublocation.getOptional("LocationShownSublocation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun locationShownWorldRegion(): Optional> = + locationShownWorldRegion.getOptional("LocationShownWorldRegion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxAvailHeight(): Optional = maxAvailHeight.getOptional("MaxAvailHeight") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxAvailWidth(): Optional = maxAvailWidth.getOptional("MaxAvailWidth") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelAge(): Optional> = modelAge.getOptional("ModelAge") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun modelReleaseId(): Optional> = modelReleaseId.getOptional("ModelReleaseID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun objectAttributeReference(): Optional = + objectAttributeReference.getOptional("ObjectAttributeReference") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun objectName(): Optional = objectName.getOptional("ObjectName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun offsetTimeOriginal(): Optional = + offsetTimeOriginal.getOptional("OffsetTimeOriginal") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organisationInImageCode(): Optional> = + organisationInImageCode.getOptional("OrganisationInImageCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun organisationInImageName(): Optional> = + organisationInImageName.getOptional("OrganisationInImageName") + + /** + * @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 originalTransmissionReference(): Optional = + originalTransmissionReference.getOptional("OriginalTransmissionReference") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImage(): Optional> = personInImage.getOptional("PersonInImage") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageCvTermCvId(): Optional> = + personInImageCvTermCvId.getOptional("PersonInImageCvTermCvId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageCvTermId(): Optional> = + personInImageCvTermId.getOptional("PersonInImageCvTermId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageCvTermName(): Optional> = + personInImageCvTermName.getOptional("PersonInImageCvTermName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageCvTermRefinedAbout(): Optional> = + personInImageCvTermRefinedAbout.getOptional("PersonInImageCvTermRefinedAbout") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageDescription(): Optional> = + personInImageDescription.getOptional("PersonInImageDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageId(): Optional> = + personInImageId.getOptional("PersonInImageId") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun personInImageName(): Optional> = + personInImageName.getOptional("PersonInImageName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productInImageDescription(): Optional> = + productInImageDescription.getOptional("ProductInImageDescription") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productInImageGtin(): Optional> = + productInImageGtin.getOptional("ProductInImageGTIN") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productInImageName(): Optional> = + productInImageName.getOptional("ProductInImageName") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun propertyReleaseId(): Optional> = + propertyReleaseId.getOptional("PropertyReleaseID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun provinceState(): Optional = provinceState.getOptional("ProvinceState") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rating(): Optional = rating.getOptional("Rating") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun registryEntryRole(): Optional> = + registryEntryRole.getOptional("RegistryEntryRole") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun registryItemId(): Optional> = registryItemId.getOptional("RegistryItemID") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun registryOrganisationId(): Optional> = + registryOrganisationId.getOptional("RegistryOrganisationID") + + /** + * @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 rights(): Optional = rights.getOptional("Rights") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun scene(): Optional> = scene.getOptional("Scene") + + /** + * @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") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun specialInstructions(): Optional = + specialInstructions.getOptional("SpecialInstructions") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("State") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subject(): Optional> = subject.getOptional("Subject") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subjectCode(): Optional> = subjectCode.getOptional("SubjectCode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subjectReference(): Optional> = + subjectReference.getOptional("SubjectReference") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sublocation(): Optional = sublocation.getOptional("Sublocation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timeCreated(): Optional = timeCreated.getOptional("TimeCreated") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun title(): Optional = title.getOptional("Title") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transmissionReference(): Optional = + transmissionReference.getOptional("TransmissionReference") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun usageTerms(): Optional = usageTerms.getOptional("UsageTerms") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webStatement(): Optional = webStatement.getOptional("WebStatement") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writer(): Optional = writer.getOptional("Writer") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun writerEditor(): Optional = writerEditor.getOptional("WriterEditor") + + /** + * @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 [aboutCvTermCvId]. + * + * Unlike [aboutCvTermCvId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("AboutCvTermCvId") + @ExcludeMissing + fun _aboutCvTermCvId(): JsonField = aboutCvTermCvId + + /** + * Returns the raw JSON value of [aboutCvTermId]. + * + * Unlike [aboutCvTermId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("AboutCvTermId") + @ExcludeMissing + fun _aboutCvTermId(): JsonField = aboutCvTermId + + /** + * Returns the raw JSON value of [aboutCvTermName]. + * + * Unlike [aboutCvTermName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("AboutCvTermName") + @ExcludeMissing + fun _aboutCvTermName(): JsonField = aboutCvTermName + + /** + * Returns the raw JSON value of [aboutCvTermRefinedAbout]. + * + * Unlike [aboutCvTermRefinedAbout], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("AboutCvTermRefinedAbout") + @ExcludeMissing + fun _aboutCvTermRefinedAbout(): JsonField = aboutCvTermRefinedAbout + + /** + * Returns the raw JSON value of [additionalModelInformation]. + * + * Unlike [additionalModelInformation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("AdditionalModelInformation") + @ExcludeMissing + fun _additionalModelInformation(): JsonField = additionalModelInformation + + /** + * Returns the raw JSON value of [applicationRecordVersion]. + * + * Unlike [applicationRecordVersion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ApplicationRecordVersion") + @ExcludeMissing + fun _applicationRecordVersion(): JsonField = applicationRecordVersion + + /** + * Returns the raw JSON value of [artist]. + * + * Unlike [artist], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Artist") @ExcludeMissing fun _artist(): JsonField = artist + + /** + * Returns the raw JSON value of [artworkCircaDateCreated]. + * + * Unlike [artworkCircaDateCreated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkCircaDateCreated") + @ExcludeMissing + fun _artworkCircaDateCreated(): JsonField = artworkCircaDateCreated + + /** + * Returns the raw JSON value of [artworkContentDescription]. + * + * Unlike [artworkContentDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkContentDescription") + @ExcludeMissing + fun _artworkContentDescription(): JsonField = artworkContentDescription + + /** + * Returns the raw JSON value of [artworkContributionDescription]. + * + * Unlike [artworkContributionDescription], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("ArtworkContributionDescription") + @ExcludeMissing + fun _artworkContributionDescription(): JsonField = artworkContributionDescription + + /** + * Returns the raw JSON value of [artworkCopyrightNotice]. + * + * Unlike [artworkCopyrightNotice], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkCopyrightNotice") + @ExcludeMissing + fun _artworkCopyrightNotice(): JsonField = artworkCopyrightNotice + + /** + * Returns the raw JSON value of [artworkCopyrightOwnerId]. + * + * Unlike [artworkCopyrightOwnerId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkCopyrightOwnerID") + @ExcludeMissing + fun _artworkCopyrightOwnerId(): JsonField = artworkCopyrightOwnerId + + /** + * Returns the raw JSON value of [artworkCopyrightOwnerName]. + * + * Unlike [artworkCopyrightOwnerName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkCopyrightOwnerName") + @ExcludeMissing + fun _artworkCopyrightOwnerName(): JsonField = artworkCopyrightOwnerName + + /** + * Returns the raw JSON value of [artworkCreator]. + * + * Unlike [artworkCreator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkCreator") + @ExcludeMissing + fun _artworkCreator(): JsonField> = artworkCreator + + /** + * Returns the raw JSON value of [artworkCreatorId]. + * + * Unlike [artworkCreatorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkCreatorID") + @ExcludeMissing + fun _artworkCreatorId(): JsonField> = artworkCreatorId + + /** + * Returns the raw JSON value of [artworkDateCreated]. + * + * Unlike [artworkDateCreated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkDateCreated") + @ExcludeMissing + fun _artworkDateCreated(): JsonField = artworkDateCreated + + /** + * Returns the raw JSON value of [artworkLicensorId]. + * + * Unlike [artworkLicensorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkLicensorID") + @ExcludeMissing + fun _artworkLicensorId(): JsonField = artworkLicensorId + + /** + * Returns the raw JSON value of [artworkLicensorName]. + * + * Unlike [artworkLicensorName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkLicensorName") + @ExcludeMissing + fun _artworkLicensorName(): JsonField = artworkLicensorName + + /** + * Returns the raw JSON value of [artworkPhysicalDescription]. + * + * Unlike [artworkPhysicalDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkPhysicalDescription") + @ExcludeMissing + fun _artworkPhysicalDescription(): JsonField = artworkPhysicalDescription + + /** + * Returns the raw JSON value of [artworkSource]. + * + * Unlike [artworkSource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkSource") + @ExcludeMissing + fun _artworkSource(): JsonField = artworkSource + + /** + * Returns the raw JSON value of [artworkSourceInventoryNo]. + * + * Unlike [artworkSourceInventoryNo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkSourceInventoryNo") + @ExcludeMissing + fun _artworkSourceInventoryNo(): JsonField = artworkSourceInventoryNo + + /** + * Returns the raw JSON value of [artworkSourceInvUrl]. + * + * Unlike [artworkSourceInvUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkSourceInvURL") + @ExcludeMissing + fun _artworkSourceInvUrl(): JsonField = artworkSourceInvUrl + + /** + * Returns the raw JSON value of [artworkStylePeriod]. + * + * Unlike [artworkStylePeriod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ArtworkStylePeriod") + @ExcludeMissing + fun _artworkStylePeriod(): JsonField> = artworkStylePeriod + + /** + * Returns the raw JSON value of [artworkTitle]. + * + * Unlike [artworkTitle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ArtworkTitle") + @ExcludeMissing + fun _artworkTitle(): JsonField = artworkTitle + + /** + * Returns the raw JSON value of [authorsPosition]. + * + * Unlike [authorsPosition], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("AuthorsPosition") + @ExcludeMissing + fun _authorsPosition(): JsonField = authorsPosition + + /** + * Returns the raw JSON value of [byline]. + * + * Unlike [byline], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Byline") @ExcludeMissing fun _byline(): JsonField = byline + + /** + * Returns the raw JSON value of [bylineTitle]. + * + * Unlike [bylineTitle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("BylineTitle") + @ExcludeMissing + fun _bylineTitle(): JsonField = bylineTitle + + /** + * Returns the raw JSON value of [caption]. + * + * Unlike [caption], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Caption") @ExcludeMissing fun _caption(): JsonField = caption + + /** + * Returns the raw JSON value of [captionAbstract]. + * + * Unlike [captionAbstract], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CaptionAbstract") + @ExcludeMissing + fun _captionAbstract(): JsonField = captionAbstract + + /** + * Returns the raw JSON value of [captionWriter]. + * + * Unlike [captionWriter], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CaptionWriter") + @ExcludeMissing + fun _captionWriter(): JsonField = captionWriter + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("City") @ExcludeMissing fun _city(): JsonField = city + + /** + * 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 [componentsConfiguration]. + * + * Unlike [componentsConfiguration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ComponentsConfiguration") + @ExcludeMissing + fun _componentsConfiguration(): JsonField = componentsConfiguration + + /** + * Returns the raw JSON value of [copyright]. + * + * Unlike [copyright], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Copyright") @ExcludeMissing fun _copyright(): JsonField = copyright + + /** + * Returns the raw JSON value of [copyrightNotice]. + * + * Unlike [copyrightNotice], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CopyrightNotice") + @ExcludeMissing + fun _copyrightNotice(): JsonField = copyrightNotice + + /** + * Returns the raw JSON value of [copyrightOwnerId]. + * + * Unlike [copyrightOwnerId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CopyrightOwnerID") + @ExcludeMissing + fun _copyrightOwnerId(): JsonField> = copyrightOwnerId + + /** + * Returns the raw JSON value of [copyrightOwnerName]. + * + * Unlike [copyrightOwnerName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CopyrightOwnerName") + @ExcludeMissing + fun _copyrightOwnerName(): JsonField> = copyrightOwnerName + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [countryCode]. + * + * Unlike [countryCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("CountryCode") + @ExcludeMissing + fun _countryCode(): JsonField = countryCode + + /** + * Returns the raw JSON value of [countryPrimaryLocationCode]. + * + * Unlike [countryPrimaryLocationCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CountryPrimaryLocationCode") + @ExcludeMissing + fun _countryPrimaryLocationCode(): JsonField = countryPrimaryLocationCode + + /** + * Returns the raw JSON value of [countryPrimaryLocationName]. + * + * Unlike [countryPrimaryLocationName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CountryPrimaryLocationName") + @ExcludeMissing + fun _countryPrimaryLocationName(): JsonField = countryPrimaryLocationName + + /** + * Returns the raw JSON value of [creator]. + * + * Unlike [creator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Creator") @ExcludeMissing fun _creator(): JsonField = creator + + /** + * Returns the raw JSON value of [creatorAddress]. + * + * Unlike [creatorAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorAddress") + @ExcludeMissing + fun _creatorAddress(): JsonField = creatorAddress + + /** + * Returns the raw JSON value of [creatorCity]. + * + * Unlike [creatorCity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("CreatorCity") + @ExcludeMissing + fun _creatorCity(): JsonField = creatorCity + + /** + * Returns the raw JSON value of [creatorCountry]. + * + * Unlike [creatorCountry], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorCountry") + @ExcludeMissing + fun _creatorCountry(): JsonField = creatorCountry + + /** + * Returns the raw JSON value of [creatorPostalCode]. + * + * Unlike [creatorPostalCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorPostalCode") + @ExcludeMissing + fun _creatorPostalCode(): JsonField = creatorPostalCode + + /** + * Returns the raw JSON value of [creatorRegion]. + * + * Unlike [creatorRegion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorRegion") + @ExcludeMissing + fun _creatorRegion(): JsonField = creatorRegion + + /** + * Returns the raw JSON value of [creatorWorkEmail]. + * + * Unlike [creatorWorkEmail], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorWorkEmail") + @ExcludeMissing + fun _creatorWorkEmail(): JsonField = creatorWorkEmail + + /** + * Returns the raw JSON value of [creatorWorkTelephone]. + * + * Unlike [creatorWorkTelephone], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CreatorWorkTelephone") + @ExcludeMissing + fun _creatorWorkTelephone(): JsonField = creatorWorkTelephone + + /** + * Returns the raw JSON value of [creatorWorkUrl]. + * + * Unlike [creatorWorkUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreatorWorkURL") + @ExcludeMissing + fun _creatorWorkUrl(): JsonField = creatorWorkUrl + + /** + * Returns the raw JSON value of [credit]. + * + * Unlike [credit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Credit") @ExcludeMissing fun _credit(): JsonField = credit + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("DateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateTimeCreated]. + * + * Unlike [dateTimeCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("DateTimeCreated") + @ExcludeMissing + fun _dateTimeCreated(): JsonField = dateTimeCreated + + /** + * 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 [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 [digitalImageGuid]. + * + * Unlike [digitalImageGuid], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("DigitalImageGUID") + @ExcludeMissing + fun _digitalImageGuid(): JsonField = digitalImageGuid + + /** + * Returns the raw JSON value of [digitalSourceType]. + * + * Unlike [digitalSourceType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("DigitalSourceType") + @ExcludeMissing + fun _digitalSourceType(): JsonField = digitalSourceType + + /** + * Returns the raw JSON value of [embeddedEncodedRightsExpr]. + * + * Unlike [embeddedEncodedRightsExpr], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("EmbeddedEncodedRightsExpr") + @ExcludeMissing + fun _embeddedEncodedRightsExpr(): JsonField = embeddedEncodedRightsExpr + + /** + * Returns the raw JSON value of [embeddedEncodedRightsExprLangId]. + * + * Unlike [embeddedEncodedRightsExprLangId], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("EmbeddedEncodedRightsExprLangID") + @ExcludeMissing + fun _embeddedEncodedRightsExprLangId(): JsonField = embeddedEncodedRightsExprLangId + + /** + * Returns the raw JSON value of [embeddedEncodedRightsExprType]. + * + * Unlike [embeddedEncodedRightsExprType], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("EmbeddedEncodedRightsExprType") + @ExcludeMissing + fun _embeddedEncodedRightsExprType(): JsonField = embeddedEncodedRightsExprType + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Event") @ExcludeMissing fun _event(): JsonField = event + + /** + * 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 [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 [genreCvId]. + * + * Unlike [genreCvId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("GenreCvId") @ExcludeMissing fun _genreCvId(): JsonField = genreCvId + + /** + * Returns the raw JSON value of [genreCvTermId]. + * + * Unlike [genreCvTermId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("GenreCvTermId") + @ExcludeMissing + fun _genreCvTermId(): JsonField = genreCvTermId + + /** + * Returns the raw JSON value of [genreCvTermName]. + * + * Unlike [genreCvTermName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("GenreCvTermName") + @ExcludeMissing + fun _genreCvTermName(): JsonField = genreCvTermName + + /** + * Returns the raw JSON value of [genreCvTermRefinedAbout]. + * + * Unlike [genreCvTermRefinedAbout], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("GenreCvTermRefinedAbout") + @ExcludeMissing + fun _genreCvTermRefinedAbout(): JsonField = genreCvTermRefinedAbout + + /** + * Returns the raw JSON value of [headline]. + * + * Unlike [headline], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Headline") @ExcludeMissing fun _headline(): JsonField = headline + + /** + * Returns the raw JSON value of [imageCreatorId]. + * + * Unlike [imageCreatorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageCreatorID") + @ExcludeMissing + fun _imageCreatorId(): JsonField = imageCreatorId + + /** + * Returns the raw JSON value of [imageCreatorImageId]. + * + * Unlike [imageCreatorImageId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageCreatorImageID") + @ExcludeMissing + fun _imageCreatorImageId(): JsonField = imageCreatorImageId + + /** + * Returns the raw JSON value of [imageCreatorName]. + * + * Unlike [imageCreatorName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageCreatorName") + @ExcludeMissing + fun _imageCreatorName(): JsonField = imageCreatorName + + /** + * Returns the raw JSON value of [imageDescription]. + * + * Unlike [imageDescription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageDescription") + @ExcludeMissing + fun _imageDescription(): JsonField = imageDescription + + /** + * Returns the raw JSON value of [imageRegionBoundaryH]. + * + * Unlike [imageRegionBoundaryH], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryH") + @ExcludeMissing + fun _imageRegionBoundaryH(): JsonField> = imageRegionBoundaryH + + /** + * Returns the raw JSON value of [imageRegionBoundaryRx]. + * + * Unlike [imageRegionBoundaryRx], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryRx") + @ExcludeMissing + fun _imageRegionBoundaryRx(): JsonField> = imageRegionBoundaryRx + + /** + * Returns the raw JSON value of [imageRegionBoundaryShape]. + * + * Unlike [imageRegionBoundaryShape], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryShape") + @ExcludeMissing + fun _imageRegionBoundaryShape(): JsonField> = imageRegionBoundaryShape + + /** + * Returns the raw JSON value of [imageRegionBoundaryUnit]. + * + * Unlike [imageRegionBoundaryUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryUnit") + @ExcludeMissing + fun _imageRegionBoundaryUnit(): JsonField> = imageRegionBoundaryUnit + + /** + * Returns the raw JSON value of [imageRegionBoundaryVerticesX]. + * + * Unlike [imageRegionBoundaryVerticesX], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryVerticesX") + @ExcludeMissing + fun _imageRegionBoundaryVerticesX(): JsonField> = imageRegionBoundaryVerticesX + + /** + * Returns the raw JSON value of [imageRegionBoundaryVerticesY]. + * + * Unlike [imageRegionBoundaryVerticesY], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryVerticesY") + @ExcludeMissing + fun _imageRegionBoundaryVerticesY(): JsonField> = imageRegionBoundaryVerticesY + + /** + * Returns the raw JSON value of [imageRegionBoundaryW]. + * + * Unlike [imageRegionBoundaryW], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryW") + @ExcludeMissing + fun _imageRegionBoundaryW(): JsonField> = imageRegionBoundaryW + + /** + * Returns the raw JSON value of [imageRegionBoundaryX]. + * + * Unlike [imageRegionBoundaryX], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryX") + @ExcludeMissing + fun _imageRegionBoundaryX(): JsonField> = imageRegionBoundaryX + + /** + * Returns the raw JSON value of [imageRegionBoundaryY]. + * + * Unlike [imageRegionBoundaryY], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionBoundaryY") + @ExcludeMissing + fun _imageRegionBoundaryY(): JsonField> = imageRegionBoundaryY + + /** + * Returns the raw JSON value of [imageRegionCtypeIdentifier]. + * + * Unlike [imageRegionCtypeIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionCtypeIdentifier") + @ExcludeMissing + fun _imageRegionCtypeIdentifier(): JsonField> = imageRegionCtypeIdentifier + + /** + * Returns the raw JSON value of [imageRegionCtypeName]. + * + * Unlike [imageRegionCtypeName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionCtypeName") + @ExcludeMissing + fun _imageRegionCtypeName(): JsonField> = imageRegionCtypeName + + /** + * Returns the raw JSON value of [imageRegionId]. + * + * Unlike [imageRegionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageRegionID") + @ExcludeMissing + fun _imageRegionId(): JsonField> = imageRegionId + + /** + * Returns the raw JSON value of [imageRegionName]. + * + * Unlike [imageRegionName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageRegionName") + @ExcludeMissing + fun _imageRegionName(): JsonField> = imageRegionName + + /** + * Returns the raw JSON value of [imageRegionOrganisationInImageName]. + * + * Unlike [imageRegionOrganisationInImageName], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("ImageRegionOrganisationInImageName") + @ExcludeMissing + fun _imageRegionOrganisationInImageName(): JsonField> = + imageRegionOrganisationInImageName + + /** + * Returns the raw JSON value of [imageRegionPersonInImage]. + * + * Unlike [imageRegionPersonInImage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionPersonInImage") + @ExcludeMissing + fun _imageRegionPersonInImage(): JsonField> = imageRegionPersonInImage + + /** + * Returns the raw JSON value of [imageRegionRoleIdentifier]. + * + * Unlike [imageRegionRoleIdentifier], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionRoleIdentifier") + @ExcludeMissing + fun _imageRegionRoleIdentifier(): JsonField> = imageRegionRoleIdentifier + + /** + * Returns the raw JSON value of [imageRegionRoleName]. + * + * Unlike [imageRegionRoleName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageRegionRoleName") + @ExcludeMissing + fun _imageRegionRoleName(): JsonField> = imageRegionRoleName + + /** + * Returns the raw JSON value of [imageSupplierId]. + * + * Unlike [imageSupplierId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageSupplierID") + @ExcludeMissing + fun _imageSupplierId(): JsonField = imageSupplierId + + /** + * Returns the raw JSON value of [imageSupplierImageId]. + * + * Unlike [imageSupplierImageId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ImageSupplierImageID") + @ExcludeMissing + fun _imageSupplierImageId(): JsonField = imageSupplierImageId + + /** + * Returns the raw JSON value of [imageSupplierName]. + * + * Unlike [imageSupplierName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ImageSupplierName") + @ExcludeMissing + fun _imageSupplierName(): JsonField = imageSupplierName + + /** + * Returns the raw JSON value of [instructions]. + * + * Unlike [instructions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("Instructions") + @ExcludeMissing + fun _instructions(): JsonField = instructions + + /** + * Returns the raw JSON value of [intellectualGenre]. + * + * Unlike [intellectualGenre], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("IntellectualGenre") + @ExcludeMissing + fun _intellectualGenre(): JsonField = intellectualGenre + + /** + * Returns the raw JSON value of [keywords]. + * + * Unlike [keywords], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Keywords") + @ExcludeMissing + fun _keywords(): JsonField> = keywords + + /** + * Returns the raw JSON value of [licensorCity]. + * + * Unlike [licensorCity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorCity") + @ExcludeMissing + fun _licensorCity(): JsonField> = licensorCity + + /** + * Returns the raw JSON value of [licensorCountry]. + * + * Unlike [licensorCountry], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorCountry") + @ExcludeMissing + fun _licensorCountry(): JsonField> = licensorCountry + + /** + * Returns the raw JSON value of [licensorEmail]. + * + * Unlike [licensorEmail], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorEmail") + @ExcludeMissing + fun _licensorEmail(): JsonField> = licensorEmail + + /** + * Returns the raw JSON value of [licensorExtendedAddress]. + * + * Unlike [licensorExtendedAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorExtendedAddress") + @ExcludeMissing + fun _licensorExtendedAddress(): JsonField> = licensorExtendedAddress + + /** + * Returns the raw JSON value of [licensorId]. + * + * Unlike [licensorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("LicensorID") + @ExcludeMissing + fun _licensorId(): JsonField> = licensorId + + /** + * Returns the raw JSON value of [licensorName]. + * + * Unlike [licensorName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorName") + @ExcludeMissing + fun _licensorName(): JsonField> = licensorName + + /** + * Returns the raw JSON value of [licensorPostalCode]. + * + * Unlike [licensorPostalCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorPostalCode") + @ExcludeMissing + fun _licensorPostalCode(): JsonField> = licensorPostalCode + + /** + * Returns the raw JSON value of [licensorRegion]. + * + * Unlike [licensorRegion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LicensorRegion") + @ExcludeMissing + fun _licensorRegion(): JsonField> = licensorRegion + + /** + * Returns the raw JSON value of [licensorStreetAddress]. + * + * Unlike [licensorStreetAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorStreetAddress") + @ExcludeMissing + fun _licensorStreetAddress(): JsonField> = licensorStreetAddress + + /** + * Returns the raw JSON value of [licensorTelephone1]. + * + * Unlike [licensorTelephone1], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorTelephone1") + @ExcludeMissing + fun _licensorTelephone1(): JsonField> = licensorTelephone1 + + /** + * Returns the raw JSON value of [licensorTelephone2]. + * + * Unlike [licensorTelephone2], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LicensorTelephone2") + @ExcludeMissing + fun _licensorTelephone2(): JsonField> = licensorTelephone2 + + /** + * Returns the raw JSON value of [licensorUrl]. + * + * Unlike [licensorUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("LicensorURL") + @ExcludeMissing + fun _licensorUrl(): JsonField> = licensorUrl + + /** + * Returns the raw JSON value of [linkedEncodedRightsExpr]. + * + * Unlike [linkedEncodedRightsExpr], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LinkedEncodedRightsExpr") + @ExcludeMissing + fun _linkedEncodedRightsExpr(): JsonField = linkedEncodedRightsExpr + + /** + * Returns the raw JSON value of [linkedEncodedRightsExprLangId]. + * + * Unlike [linkedEncodedRightsExprLangId], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("LinkedEncodedRightsExprLangID") + @ExcludeMissing + fun _linkedEncodedRightsExprLangId(): JsonField = linkedEncodedRightsExprLangId + + /** + * Returns the raw JSON value of [linkedEncodedRightsExprType]. + * + * Unlike [linkedEncodedRightsExprType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LinkedEncodedRightsExprType") + @ExcludeMissing + fun _linkedEncodedRightsExprType(): JsonField = linkedEncodedRightsExprType + + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Location") @ExcludeMissing fun _location(): JsonField = location + + /** + * Returns the raw JSON value of [locationCreatedCity]. + * + * Unlike [locationCreatedCity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedCity") + @ExcludeMissing + fun _locationCreatedCity(): JsonField = locationCreatedCity + + /** + * Returns the raw JSON value of [locationCreatedCountryCode]. + * + * Unlike [locationCreatedCountryCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedCountryCode") + @ExcludeMissing + fun _locationCreatedCountryCode(): JsonField = locationCreatedCountryCode + + /** + * Returns the raw JSON value of [locationCreatedCountryName]. + * + * Unlike [locationCreatedCountryName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedCountryName") + @ExcludeMissing + fun _locationCreatedCountryName(): JsonField = locationCreatedCountryName + + /** + * Returns the raw JSON value of [locationCreatedGpsAltitude]. + * + * Unlike [locationCreatedGpsAltitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedGPSAltitude") + @ExcludeMissing + fun _locationCreatedGpsAltitude(): JsonField = locationCreatedGpsAltitude + + /** + * Returns the raw JSON value of [locationCreatedGpsLatitude]. + * + * Unlike [locationCreatedGpsLatitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedGPSLatitude") + @ExcludeMissing + fun _locationCreatedGpsLatitude(): JsonField = locationCreatedGpsLatitude + + /** + * Returns the raw JSON value of [locationCreatedGpsLongitude]. + * + * Unlike [locationCreatedGpsLongitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedGPSLongitude") + @ExcludeMissing + fun _locationCreatedGpsLongitude(): JsonField = locationCreatedGpsLongitude + + /** + * Returns the raw JSON value of [locationCreatedLocationId]. + * + * Unlike [locationCreatedLocationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedLocationId") + @ExcludeMissing + fun _locationCreatedLocationId(): JsonField = locationCreatedLocationId + + /** + * Returns the raw JSON value of [locationCreatedLocationName]. + * + * Unlike [locationCreatedLocationName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedLocationName") + @ExcludeMissing + fun _locationCreatedLocationName(): JsonField = locationCreatedLocationName + + /** + * Returns the raw JSON value of [locationCreatedProvinceState]. + * + * Unlike [locationCreatedProvinceState], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedProvinceState") + @ExcludeMissing + fun _locationCreatedProvinceState(): JsonField = locationCreatedProvinceState + + /** + * Returns the raw JSON value of [locationCreatedSublocation]. + * + * Unlike [locationCreatedSublocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedSublocation") + @ExcludeMissing + fun _locationCreatedSublocation(): JsonField = locationCreatedSublocation + + /** + * Returns the raw JSON value of [locationCreatedWorldRegion]. + * + * Unlike [locationCreatedWorldRegion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationCreatedWorldRegion") + @ExcludeMissing + fun _locationCreatedWorldRegion(): JsonField = locationCreatedWorldRegion + + /** + * Returns the raw JSON value of [locationShownCity]. + * + * Unlike [locationShownCity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("LocationShownCity") + @ExcludeMissing + fun _locationShownCity(): JsonField> = locationShownCity + + /** + * Returns the raw JSON value of [locationShownCountryCode]. + * + * Unlike [locationShownCountryCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownCountryCode") + @ExcludeMissing + fun _locationShownCountryCode(): JsonField> = locationShownCountryCode + + /** + * Returns the raw JSON value of [locationShownCountryName]. + * + * Unlike [locationShownCountryName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownCountryName") + @ExcludeMissing + fun _locationShownCountryName(): JsonField> = locationShownCountryName + + /** + * Returns the raw JSON value of [locationShownGpsAltitude]. + * + * Unlike [locationShownGpsAltitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownGPSAltitude") + @ExcludeMissing + fun _locationShownGpsAltitude(): JsonField> = locationShownGpsAltitude + + /** + * Returns the raw JSON value of [locationShownGpsLatitude]. + * + * Unlike [locationShownGpsLatitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownGPSLatitude") + @ExcludeMissing + fun _locationShownGpsLatitude(): JsonField> = locationShownGpsLatitude + + /** + * Returns the raw JSON value of [locationShownGpsLongitude]. + * + * Unlike [locationShownGpsLongitude], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownGPSLongitude") + @ExcludeMissing + fun _locationShownGpsLongitude(): JsonField> = locationShownGpsLongitude + + /** + * Returns the raw JSON value of [locationShownLocationId]. + * + * Unlike [locationShownLocationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownLocationId") + @ExcludeMissing + fun _locationShownLocationId(): JsonField> = locationShownLocationId + + /** + * Returns the raw JSON value of [locationShownLocationName]. + * + * Unlike [locationShownLocationName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownLocationName") + @ExcludeMissing + fun _locationShownLocationName(): JsonField> = locationShownLocationName + + /** + * Returns the raw JSON value of [locationShownProvinceState]. + * + * Unlike [locationShownProvinceState], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownProvinceState") + @ExcludeMissing + fun _locationShownProvinceState(): JsonField> = locationShownProvinceState + + /** + * Returns the raw JSON value of [locationShownSublocation]. + * + * Unlike [locationShownSublocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownSublocation") + @ExcludeMissing + fun _locationShownSublocation(): JsonField> = locationShownSublocation + + /** + * Returns the raw JSON value of [locationShownWorldRegion]. + * + * Unlike [locationShownWorldRegion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("LocationShownWorldRegion") + @ExcludeMissing + fun _locationShownWorldRegion(): JsonField> = locationShownWorldRegion + + /** + * Returns the raw JSON value of [maxAvailHeight]. + * + * Unlike [maxAvailHeight], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("MaxAvailHeight") + @ExcludeMissing + fun _maxAvailHeight(): JsonField = maxAvailHeight + + /** + * Returns the raw JSON value of [maxAvailWidth]. + * + * Unlike [maxAvailWidth], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("MaxAvailWidth") + @ExcludeMissing + fun _maxAvailWidth(): JsonField = maxAvailWidth + + /** + * Returns the raw JSON value of [modelAge]. + * + * Unlike [modelAge], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ModelAge") + @ExcludeMissing + fun _modelAge(): JsonField> = modelAge + + /** + * Returns the raw JSON value of [modelReleaseId]. + * + * Unlike [modelReleaseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ModelReleaseID") + @ExcludeMissing + fun _modelReleaseId(): JsonField> = modelReleaseId + + /** + * Returns the raw JSON value of [objectAttributeReference]. + * + * Unlike [objectAttributeReference], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ObjectAttributeReference") + @ExcludeMissing + fun _objectAttributeReference(): JsonField = objectAttributeReference + + /** + * Returns the raw JSON value of [objectName]. + * + * Unlike [objectName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ObjectName") + @ExcludeMissing + fun _objectName(): JsonField = objectName + + /** + * Returns the raw JSON value of [offsetTimeOriginal]. + * + * Unlike [offsetTimeOriginal], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("OffsetTimeOriginal") + @ExcludeMissing + fun _offsetTimeOriginal(): JsonField = offsetTimeOriginal + + /** + * Returns the raw JSON value of [organisationInImageCode]. + * + * Unlike [organisationInImageCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("OrganisationInImageCode") + @ExcludeMissing + fun _organisationInImageCode(): JsonField> = organisationInImageCode + + /** + * Returns the raw JSON value of [organisationInImageName]. + * + * Unlike [organisationInImageName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("OrganisationInImageName") + @ExcludeMissing + fun _organisationInImageName(): JsonField> = organisationInImageName + + /** + * 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 [originalTransmissionReference]. + * + * Unlike [originalTransmissionReference], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("OriginalTransmissionReference") + @ExcludeMissing + fun _originalTransmissionReference(): JsonField = originalTransmissionReference + + /** + * Returns the raw JSON value of [personInImage]. + * + * Unlike [personInImage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("PersonInImage") + @ExcludeMissing + fun _personInImage(): JsonField> = personInImage + + /** + * Returns the raw JSON value of [personInImageCvTermCvId]. + * + * Unlike [personInImageCvTermCvId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("PersonInImageCvTermCvId") + @ExcludeMissing + fun _personInImageCvTermCvId(): JsonField> = personInImageCvTermCvId + + /** + * Returns the raw JSON value of [personInImageCvTermId]. + * + * Unlike [personInImageCvTermId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("PersonInImageCvTermId") + @ExcludeMissing + fun _personInImageCvTermId(): JsonField> = personInImageCvTermId + + /** + * Returns the raw JSON value of [personInImageCvTermName]. + * + * Unlike [personInImageCvTermName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("PersonInImageCvTermName") + @ExcludeMissing + fun _personInImageCvTermName(): JsonField> = personInImageCvTermName + + /** + * Returns the raw JSON value of [personInImageCvTermRefinedAbout]. + * + * Unlike [personInImageCvTermRefinedAbout], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("PersonInImageCvTermRefinedAbout") + @ExcludeMissing + fun _personInImageCvTermRefinedAbout(): JsonField> = + personInImageCvTermRefinedAbout + + /** + * Returns the raw JSON value of [personInImageDescription]. + * + * Unlike [personInImageDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("PersonInImageDescription") + @ExcludeMissing + fun _personInImageDescription(): JsonField> = personInImageDescription + + /** + * Returns the raw JSON value of [personInImageId]. + * + * Unlike [personInImageId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("PersonInImageId") + @ExcludeMissing + fun _personInImageId(): JsonField> = personInImageId + + /** + * Returns the raw JSON value of [personInImageName]. + * + * Unlike [personInImageName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("PersonInImageName") + @ExcludeMissing + fun _personInImageName(): JsonField> = personInImageName + + /** + * Returns the raw JSON value of [productInImageDescription]. + * + * Unlike [productInImageDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ProductInImageDescription") + @ExcludeMissing + fun _productInImageDescription(): JsonField> = productInImageDescription + + /** + * Returns the raw JSON value of [productInImageGtin]. + * + * Unlike [productInImageGtin], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ProductInImageGTIN") + @ExcludeMissing + fun _productInImageGtin(): JsonField> = productInImageGtin + + /** + * Returns the raw JSON value of [productInImageName]. + * + * Unlike [productInImageName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ProductInImageName") + @ExcludeMissing + fun _productInImageName(): JsonField> = productInImageName + + /** + * Returns the raw JSON value of [propertyReleaseId]. + * + * Unlike [propertyReleaseId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("PropertyReleaseID") + @ExcludeMissing + fun _propertyReleaseId(): JsonField> = propertyReleaseId + + /** + * Returns the raw JSON value of [provinceState]. + * + * Unlike [provinceState], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ProvinceState") + @ExcludeMissing + fun _provinceState(): JsonField = provinceState + + /** + * Returns the raw JSON value of [rating]. + * + * Unlike [rating], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Rating") @ExcludeMissing fun _rating(): JsonField = rating + + /** + * Returns the raw JSON value of [registryEntryRole]. + * + * Unlike [registryEntryRole], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("RegistryEntryRole") + @ExcludeMissing + fun _registryEntryRole(): JsonField> = registryEntryRole + + /** + * Returns the raw JSON value of [registryItemId]. + * + * Unlike [registryItemId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("RegistryItemID") + @ExcludeMissing + fun _registryItemId(): JsonField> = registryItemId + + /** + * Returns the raw JSON value of [registryOrganisationId]. + * + * Unlike [registryOrganisationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("RegistryOrganisationID") + @ExcludeMissing + fun _registryOrganisationId(): JsonField> = registryOrganisationId + + /** + * 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 [rights]. + * + * Unlike [rights], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Rights") @ExcludeMissing fun _rights(): JsonField = rights + + /** + * Returns the raw JSON value of [scene]. + * + * Unlike [scene], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Scene") @ExcludeMissing fun _scene(): JsonField> = scene + + /** + * 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 + + /** + * Returns the raw JSON value of [specialInstructions]. + * + * Unlike [specialInstructions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("SpecialInstructions") + @ExcludeMissing + fun _specialInstructions(): JsonField = specialInstructions + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("State") @ExcludeMissing fun _state(): JsonField = state + + /** + * Returns the raw JSON value of [subject]. + * + * Unlike [subject], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Subject") @ExcludeMissing fun _subject(): JsonField> = subject + + /** + * Returns the raw JSON value of [subjectCode]. + * + * Unlike [subjectCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("SubjectCode") + @ExcludeMissing + fun _subjectCode(): JsonField> = subjectCode + + /** + * Returns the raw JSON value of [subjectReference]. + * + * Unlike [subjectReference], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("SubjectReference") + @ExcludeMissing + fun _subjectReference(): JsonField> = subjectReference + + /** + * Returns the raw JSON value of [sublocation]. + * + * Unlike [sublocation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Sublocation") + @ExcludeMissing + fun _sublocation(): JsonField = sublocation + + /** + * Returns the raw JSON value of [timeCreated]. + * + * Unlike [timeCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("TimeCreated") + @ExcludeMissing + fun _timeCreated(): JsonField = timeCreated + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [transmissionReference]. + * + * Unlike [transmissionReference], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("TransmissionReference") + @ExcludeMissing + fun _transmissionReference(): JsonField = transmissionReference + + /** + * Returns the raw JSON value of [usageTerms]. + * + * Unlike [usageTerms], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("UsageTerms") + @ExcludeMissing + fun _usageTerms(): JsonField = usageTerms + + /** + * Returns the raw JSON value of [webStatement]. + * + * Unlike [webStatement], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("WebStatement") + @ExcludeMissing + fun _webStatement(): JsonField = webStatement + + /** + * Returns the raw JSON value of [writer]. + * + * Unlike [writer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Writer") @ExcludeMissing fun _writer(): JsonField = writer + + /** + * Returns the raw JSON value of [writerEditor]. + * + * Unlike [writerEditor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("WriterEditor") + @ExcludeMissing + fun _writerEditor(): JsonField = writerEditor + + /** + * 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 [EmbeddedMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmbeddedMetadata]. */ + class Builder internal constructor() { + + private var aboutCvTermCvId: JsonField = JsonMissing.of() + private var aboutCvTermId: JsonField = JsonMissing.of() + private var aboutCvTermName: JsonField = JsonMissing.of() + private var aboutCvTermRefinedAbout: JsonField = JsonMissing.of() + private var additionalModelInformation: JsonField = JsonMissing.of() + private var applicationRecordVersion: JsonField = JsonMissing.of() + private var artist: JsonField = JsonMissing.of() + private var artworkCircaDateCreated: JsonField = JsonMissing.of() + private var artworkContentDescription: JsonField = JsonMissing.of() + private var artworkContributionDescription: JsonField = JsonMissing.of() + private var artworkCopyrightNotice: JsonField = JsonMissing.of() + private var artworkCopyrightOwnerId: JsonField = JsonMissing.of() + private var artworkCopyrightOwnerName: JsonField = JsonMissing.of() + private var artworkCreator: JsonField>? = null + private var artworkCreatorId: JsonField>? = null + private var artworkDateCreated: JsonField = JsonMissing.of() + private var artworkLicensorId: JsonField = JsonMissing.of() + private var artworkLicensorName: JsonField = JsonMissing.of() + private var artworkPhysicalDescription: JsonField = JsonMissing.of() + private var artworkSource: JsonField = JsonMissing.of() + private var artworkSourceInventoryNo: JsonField = JsonMissing.of() + private var artworkSourceInvUrl: JsonField = JsonMissing.of() + private var artworkStylePeriod: JsonField>? = null + private var artworkTitle: JsonField = JsonMissing.of() + private var authorsPosition: JsonField = JsonMissing.of() + private var byline: JsonField = JsonMissing.of() + private var bylineTitle: JsonField = JsonMissing.of() + private var caption: JsonField = JsonMissing.of() + private var captionAbstract: JsonField = JsonMissing.of() + private var captionWriter: JsonField = JsonMissing.of() + private var city: JsonField = JsonMissing.of() + private var colorSpace: JsonField = JsonMissing.of() + private var componentsConfiguration: JsonField = JsonMissing.of() + private var copyright: JsonField = JsonMissing.of() + private var copyrightNotice: JsonField = JsonMissing.of() + private var copyrightOwnerId: JsonField>? = null + private var copyrightOwnerName: JsonField>? = null + private var country: JsonField = JsonMissing.of() + private var countryCode: JsonField = JsonMissing.of() + private var countryPrimaryLocationCode: JsonField = JsonMissing.of() + private var countryPrimaryLocationName: JsonField = JsonMissing.of() + private var creator: JsonField = JsonMissing.of() + private var creatorAddress: JsonField = JsonMissing.of() + private var creatorCity: JsonField = JsonMissing.of() + private var creatorCountry: JsonField = JsonMissing.of() + private var creatorPostalCode: JsonField = JsonMissing.of() + private var creatorRegion: JsonField = JsonMissing.of() + private var creatorWorkEmail: JsonField = JsonMissing.of() + private var creatorWorkTelephone: JsonField = JsonMissing.of() + private var creatorWorkUrl: JsonField = JsonMissing.of() + private var credit: JsonField = JsonMissing.of() + private var dateCreated: JsonField = JsonMissing.of() + private var dateTimeCreated: JsonField = JsonMissing.of() + private var dateTimeOriginal: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var digitalImageGuid: JsonField = JsonMissing.of() + private var digitalSourceType: JsonField = JsonMissing.of() + private var embeddedEncodedRightsExpr: JsonField = JsonMissing.of() + private var embeddedEncodedRightsExprLangId: JsonField = JsonMissing.of() + private var embeddedEncodedRightsExprType: JsonField = JsonMissing.of() + private var event: JsonField = JsonMissing.of() + private var exifVersion: JsonField = JsonMissing.of() + private var flashpixVersion: JsonField = JsonMissing.of() + private var genreCvId: JsonField = JsonMissing.of() + private var genreCvTermId: JsonField = JsonMissing.of() + private var genreCvTermName: JsonField = JsonMissing.of() + private var genreCvTermRefinedAbout: JsonField = JsonMissing.of() + private var headline: JsonField = JsonMissing.of() + private var imageCreatorId: JsonField = JsonMissing.of() + private var imageCreatorImageId: JsonField = JsonMissing.of() + private var imageCreatorName: JsonField = JsonMissing.of() + private var imageDescription: JsonField = JsonMissing.of() + private var imageRegionBoundaryH: JsonField>? = null + private var imageRegionBoundaryRx: JsonField>? = null + private var imageRegionBoundaryShape: JsonField>? = null + private var imageRegionBoundaryUnit: JsonField>? = null + private var imageRegionBoundaryVerticesX: JsonField>? = null + private var imageRegionBoundaryVerticesY: JsonField>? = null + private var imageRegionBoundaryW: JsonField>? = null + private var imageRegionBoundaryX: JsonField>? = null + private var imageRegionBoundaryY: JsonField>? = null + private var imageRegionCtypeIdentifier: JsonField>? = null + private var imageRegionCtypeName: JsonField>? = null + private var imageRegionId: JsonField>? = null + private var imageRegionName: JsonField>? = null + private var imageRegionOrganisationInImageName: JsonField>? = null + private var imageRegionPersonInImage: JsonField>? = null + private var imageRegionRoleIdentifier: JsonField>? = null + private var imageRegionRoleName: JsonField>? = null + private var imageSupplierId: JsonField = JsonMissing.of() + private var imageSupplierImageId: JsonField = JsonMissing.of() + private var imageSupplierName: JsonField = JsonMissing.of() + private var instructions: JsonField = JsonMissing.of() + private var intellectualGenre: JsonField = JsonMissing.of() + private var keywords: JsonField>? = null + private var licensorCity: JsonField>? = null + private var licensorCountry: JsonField>? = null + private var licensorEmail: JsonField>? = null + private var licensorExtendedAddress: JsonField>? = null + private var licensorId: JsonField>? = null + private var licensorName: JsonField>? = null + private var licensorPostalCode: JsonField>? = null + private var licensorRegion: JsonField>? = null + private var licensorStreetAddress: JsonField>? = null + private var licensorTelephone1: JsonField>? = null + private var licensorTelephone2: JsonField>? = null + private var licensorUrl: JsonField>? = null + private var linkedEncodedRightsExpr: JsonField = JsonMissing.of() + private var linkedEncodedRightsExprLangId: JsonField = JsonMissing.of() + private var linkedEncodedRightsExprType: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var locationCreatedCity: JsonField = JsonMissing.of() + private var locationCreatedCountryCode: JsonField = JsonMissing.of() + private var locationCreatedCountryName: JsonField = JsonMissing.of() + private var locationCreatedGpsAltitude: JsonField = JsonMissing.of() + private var locationCreatedGpsLatitude: JsonField = JsonMissing.of() + private var locationCreatedGpsLongitude: JsonField = JsonMissing.of() + private var locationCreatedLocationId: JsonField = JsonMissing.of() + private var locationCreatedLocationName: JsonField = JsonMissing.of() + private var locationCreatedProvinceState: JsonField = JsonMissing.of() + private var locationCreatedSublocation: JsonField = JsonMissing.of() + private var locationCreatedWorldRegion: JsonField = JsonMissing.of() + private var locationShownCity: JsonField>? = null + private var locationShownCountryCode: JsonField>? = null + private var locationShownCountryName: JsonField>? = null + private var locationShownGpsAltitude: JsonField>? = null + private var locationShownGpsLatitude: JsonField>? = null + private var locationShownGpsLongitude: JsonField>? = null + private var locationShownLocationId: JsonField>? = null + private var locationShownLocationName: JsonField>? = null + private var locationShownProvinceState: JsonField>? = null + private var locationShownSublocation: JsonField>? = null + private var locationShownWorldRegion: JsonField>? = null + private var maxAvailHeight: JsonField = JsonMissing.of() + private var maxAvailWidth: JsonField = JsonMissing.of() + private var modelAge: JsonField>? = null + private var modelReleaseId: JsonField>? = null + private var objectAttributeReference: JsonField = JsonMissing.of() + private var objectName: JsonField = JsonMissing.of() + private var offsetTimeOriginal: JsonField = JsonMissing.of() + private var organisationInImageCode: JsonField>? = null + private var organisationInImageName: JsonField>? = null + private var orientation: JsonField = JsonMissing.of() + private var originalTransmissionReference: JsonField = JsonMissing.of() + private var personInImage: JsonField>? = null + private var personInImageCvTermCvId: JsonField>? = null + private var personInImageCvTermId: JsonField>? = null + private var personInImageCvTermName: JsonField>? = null + private var personInImageCvTermRefinedAbout: JsonField>? = null + private var personInImageDescription: JsonField>? = null + private var personInImageId: JsonField>? = null + private var personInImageName: JsonField>? = null + private var productInImageDescription: JsonField>? = null + private var productInImageGtin: JsonField>? = null + private var productInImageName: JsonField>? = null + private var propertyReleaseId: JsonField>? = null + private var provinceState: JsonField = JsonMissing.of() + private var rating: JsonField = JsonMissing.of() + private var registryEntryRole: JsonField>? = null + private var registryItemId: JsonField>? = null + private var registryOrganisationId: JsonField>? = null + private var resolutionUnit: JsonField = JsonMissing.of() + private var rights: JsonField = JsonMissing.of() + private var scene: JsonField>? = null + private var source: JsonField = JsonMissing.of() + private var specialInstructions: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var subject: JsonField>? = null + private var subjectCode: JsonField>? = null + private var subjectReference: JsonField>? = null + private var sublocation: JsonField = JsonMissing.of() + private var timeCreated: JsonField = JsonMissing.of() + private var title: JsonField = JsonMissing.of() + private var transmissionReference: JsonField = JsonMissing.of() + private var usageTerms: JsonField = JsonMissing.of() + private var webStatement: JsonField = JsonMissing.of() + private var writer: JsonField = JsonMissing.of() + private var writerEditor: JsonField = JsonMissing.of() + private var xResolution: JsonField = JsonMissing.of() + private var yResolution: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { + aboutCvTermCvId = embeddedMetadata.aboutCvTermCvId + aboutCvTermId = embeddedMetadata.aboutCvTermId + aboutCvTermName = embeddedMetadata.aboutCvTermName + aboutCvTermRefinedAbout = embeddedMetadata.aboutCvTermRefinedAbout + additionalModelInformation = embeddedMetadata.additionalModelInformation + applicationRecordVersion = embeddedMetadata.applicationRecordVersion + artist = embeddedMetadata.artist + artworkCircaDateCreated = embeddedMetadata.artworkCircaDateCreated + artworkContentDescription = embeddedMetadata.artworkContentDescription + artworkContributionDescription = embeddedMetadata.artworkContributionDescription + artworkCopyrightNotice = embeddedMetadata.artworkCopyrightNotice + artworkCopyrightOwnerId = embeddedMetadata.artworkCopyrightOwnerId + artworkCopyrightOwnerName = embeddedMetadata.artworkCopyrightOwnerName + artworkCreator = embeddedMetadata.artworkCreator.map { it.toMutableList() } + artworkCreatorId = embeddedMetadata.artworkCreatorId.map { it.toMutableList() } + artworkDateCreated = embeddedMetadata.artworkDateCreated + artworkLicensorId = embeddedMetadata.artworkLicensorId + artworkLicensorName = embeddedMetadata.artworkLicensorName + artworkPhysicalDescription = embeddedMetadata.artworkPhysicalDescription + artworkSource = embeddedMetadata.artworkSource + artworkSourceInventoryNo = embeddedMetadata.artworkSourceInventoryNo + artworkSourceInvUrl = embeddedMetadata.artworkSourceInvUrl + artworkStylePeriod = embeddedMetadata.artworkStylePeriod.map { it.toMutableList() } + artworkTitle = embeddedMetadata.artworkTitle + authorsPosition = embeddedMetadata.authorsPosition + byline = embeddedMetadata.byline + bylineTitle = embeddedMetadata.bylineTitle + caption = embeddedMetadata.caption + captionAbstract = embeddedMetadata.captionAbstract + captionWriter = embeddedMetadata.captionWriter + city = embeddedMetadata.city + colorSpace = embeddedMetadata.colorSpace + componentsConfiguration = embeddedMetadata.componentsConfiguration + copyright = embeddedMetadata.copyright + copyrightNotice = embeddedMetadata.copyrightNotice + copyrightOwnerId = embeddedMetadata.copyrightOwnerId.map { it.toMutableList() } + copyrightOwnerName = embeddedMetadata.copyrightOwnerName.map { it.toMutableList() } + country = embeddedMetadata.country + countryCode = embeddedMetadata.countryCode + countryPrimaryLocationCode = embeddedMetadata.countryPrimaryLocationCode + countryPrimaryLocationName = embeddedMetadata.countryPrimaryLocationName + creator = embeddedMetadata.creator + creatorAddress = embeddedMetadata.creatorAddress + creatorCity = embeddedMetadata.creatorCity + creatorCountry = embeddedMetadata.creatorCountry + creatorPostalCode = embeddedMetadata.creatorPostalCode + creatorRegion = embeddedMetadata.creatorRegion + creatorWorkEmail = embeddedMetadata.creatorWorkEmail + creatorWorkTelephone = embeddedMetadata.creatorWorkTelephone + creatorWorkUrl = embeddedMetadata.creatorWorkUrl + credit = embeddedMetadata.credit + dateCreated = embeddedMetadata.dateCreated + dateTimeCreated = embeddedMetadata.dateTimeCreated + dateTimeOriginal = embeddedMetadata.dateTimeOriginal + description = embeddedMetadata.description + digitalImageGuid = embeddedMetadata.digitalImageGuid + digitalSourceType = embeddedMetadata.digitalSourceType + embeddedEncodedRightsExpr = embeddedMetadata.embeddedEncodedRightsExpr + embeddedEncodedRightsExprLangId = embeddedMetadata.embeddedEncodedRightsExprLangId + embeddedEncodedRightsExprType = embeddedMetadata.embeddedEncodedRightsExprType + event = embeddedMetadata.event + exifVersion = embeddedMetadata.exifVersion + flashpixVersion = embeddedMetadata.flashpixVersion + genreCvId = embeddedMetadata.genreCvId + genreCvTermId = embeddedMetadata.genreCvTermId + genreCvTermName = embeddedMetadata.genreCvTermName + genreCvTermRefinedAbout = embeddedMetadata.genreCvTermRefinedAbout + headline = embeddedMetadata.headline + imageCreatorId = embeddedMetadata.imageCreatorId + imageCreatorImageId = embeddedMetadata.imageCreatorImageId + imageCreatorName = embeddedMetadata.imageCreatorName + imageDescription = embeddedMetadata.imageDescription + imageRegionBoundaryH = + embeddedMetadata.imageRegionBoundaryH.map { it.toMutableList() } + imageRegionBoundaryRx = + embeddedMetadata.imageRegionBoundaryRx.map { it.toMutableList() } + imageRegionBoundaryShape = + embeddedMetadata.imageRegionBoundaryShape.map { it.toMutableList() } + imageRegionBoundaryUnit = + embeddedMetadata.imageRegionBoundaryUnit.map { it.toMutableList() } + imageRegionBoundaryVerticesX = + embeddedMetadata.imageRegionBoundaryVerticesX.map { it.toMutableList() } + imageRegionBoundaryVerticesY = + embeddedMetadata.imageRegionBoundaryVerticesY.map { it.toMutableList() } + imageRegionBoundaryW = + embeddedMetadata.imageRegionBoundaryW.map { it.toMutableList() } + imageRegionBoundaryX = + embeddedMetadata.imageRegionBoundaryX.map { it.toMutableList() } + imageRegionBoundaryY = + embeddedMetadata.imageRegionBoundaryY.map { it.toMutableList() } + imageRegionCtypeIdentifier = + embeddedMetadata.imageRegionCtypeIdentifier.map { it.toMutableList() } + imageRegionCtypeName = + embeddedMetadata.imageRegionCtypeName.map { it.toMutableList() } + imageRegionId = embeddedMetadata.imageRegionId.map { it.toMutableList() } + imageRegionName = embeddedMetadata.imageRegionName.map { it.toMutableList() } + imageRegionOrganisationInImageName = + embeddedMetadata.imageRegionOrganisationInImageName.map { it.toMutableList() } + imageRegionPersonInImage = + embeddedMetadata.imageRegionPersonInImage.map { it.toMutableList() } + imageRegionRoleIdentifier = + embeddedMetadata.imageRegionRoleIdentifier.map { it.toMutableList() } + imageRegionRoleName = + embeddedMetadata.imageRegionRoleName.map { it.toMutableList() } + imageSupplierId = embeddedMetadata.imageSupplierId + imageSupplierImageId = embeddedMetadata.imageSupplierImageId + imageSupplierName = embeddedMetadata.imageSupplierName + instructions = embeddedMetadata.instructions + intellectualGenre = embeddedMetadata.intellectualGenre + keywords = embeddedMetadata.keywords.map { it.toMutableList() } + licensorCity = embeddedMetadata.licensorCity.map { it.toMutableList() } + licensorCountry = embeddedMetadata.licensorCountry.map { it.toMutableList() } + licensorEmail = embeddedMetadata.licensorEmail.map { it.toMutableList() } + licensorExtendedAddress = + embeddedMetadata.licensorExtendedAddress.map { it.toMutableList() } + licensorId = embeddedMetadata.licensorId.map { it.toMutableList() } + licensorName = embeddedMetadata.licensorName.map { it.toMutableList() } + licensorPostalCode = embeddedMetadata.licensorPostalCode.map { it.toMutableList() } + licensorRegion = embeddedMetadata.licensorRegion.map { it.toMutableList() } + licensorStreetAddress = + embeddedMetadata.licensorStreetAddress.map { it.toMutableList() } + licensorTelephone1 = embeddedMetadata.licensorTelephone1.map { it.toMutableList() } + licensorTelephone2 = embeddedMetadata.licensorTelephone2.map { it.toMutableList() } + licensorUrl = embeddedMetadata.licensorUrl.map { it.toMutableList() } + linkedEncodedRightsExpr = embeddedMetadata.linkedEncodedRightsExpr + linkedEncodedRightsExprLangId = embeddedMetadata.linkedEncodedRightsExprLangId + linkedEncodedRightsExprType = embeddedMetadata.linkedEncodedRightsExprType + location = embeddedMetadata.location + locationCreatedCity = embeddedMetadata.locationCreatedCity + locationCreatedCountryCode = embeddedMetadata.locationCreatedCountryCode + locationCreatedCountryName = embeddedMetadata.locationCreatedCountryName + locationCreatedGpsAltitude = embeddedMetadata.locationCreatedGpsAltitude + locationCreatedGpsLatitude = embeddedMetadata.locationCreatedGpsLatitude + locationCreatedGpsLongitude = embeddedMetadata.locationCreatedGpsLongitude + locationCreatedLocationId = embeddedMetadata.locationCreatedLocationId + locationCreatedLocationName = embeddedMetadata.locationCreatedLocationName + locationCreatedProvinceState = embeddedMetadata.locationCreatedProvinceState + locationCreatedSublocation = embeddedMetadata.locationCreatedSublocation + locationCreatedWorldRegion = embeddedMetadata.locationCreatedWorldRegion + locationShownCity = embeddedMetadata.locationShownCity.map { it.toMutableList() } + locationShownCountryCode = + embeddedMetadata.locationShownCountryCode.map { it.toMutableList() } + locationShownCountryName = + embeddedMetadata.locationShownCountryName.map { it.toMutableList() } + locationShownGpsAltitude = + embeddedMetadata.locationShownGpsAltitude.map { it.toMutableList() } + locationShownGpsLatitude = + embeddedMetadata.locationShownGpsLatitude.map { it.toMutableList() } + locationShownGpsLongitude = + embeddedMetadata.locationShownGpsLongitude.map { it.toMutableList() } + locationShownLocationId = + embeddedMetadata.locationShownLocationId.map { it.toMutableList() } + locationShownLocationName = + embeddedMetadata.locationShownLocationName.map { it.toMutableList() } + locationShownProvinceState = + embeddedMetadata.locationShownProvinceState.map { it.toMutableList() } + locationShownSublocation = + embeddedMetadata.locationShownSublocation.map { it.toMutableList() } + locationShownWorldRegion = + embeddedMetadata.locationShownWorldRegion.map { it.toMutableList() } + maxAvailHeight = embeddedMetadata.maxAvailHeight + maxAvailWidth = embeddedMetadata.maxAvailWidth + modelAge = embeddedMetadata.modelAge.map { it.toMutableList() } + modelReleaseId = embeddedMetadata.modelReleaseId.map { it.toMutableList() } + objectAttributeReference = embeddedMetadata.objectAttributeReference + objectName = embeddedMetadata.objectName + offsetTimeOriginal = embeddedMetadata.offsetTimeOriginal + organisationInImageCode = + embeddedMetadata.organisationInImageCode.map { it.toMutableList() } + organisationInImageName = + embeddedMetadata.organisationInImageName.map { it.toMutableList() } + orientation = embeddedMetadata.orientation + originalTransmissionReference = embeddedMetadata.originalTransmissionReference + personInImage = embeddedMetadata.personInImage.map { it.toMutableList() } + personInImageCvTermCvId = + embeddedMetadata.personInImageCvTermCvId.map { it.toMutableList() } + personInImageCvTermId = + embeddedMetadata.personInImageCvTermId.map { it.toMutableList() } + personInImageCvTermName = + embeddedMetadata.personInImageCvTermName.map { it.toMutableList() } + personInImageCvTermRefinedAbout = + embeddedMetadata.personInImageCvTermRefinedAbout.map { it.toMutableList() } + personInImageDescription = + embeddedMetadata.personInImageDescription.map { it.toMutableList() } + personInImageId = embeddedMetadata.personInImageId.map { it.toMutableList() } + personInImageName = embeddedMetadata.personInImageName.map { it.toMutableList() } + productInImageDescription = + embeddedMetadata.productInImageDescription.map { it.toMutableList() } + productInImageGtin = embeddedMetadata.productInImageGtin.map { it.toMutableList() } + productInImageName = embeddedMetadata.productInImageName.map { it.toMutableList() } + propertyReleaseId = embeddedMetadata.propertyReleaseId.map { it.toMutableList() } + provinceState = embeddedMetadata.provinceState + rating = embeddedMetadata.rating + registryEntryRole = embeddedMetadata.registryEntryRole.map { it.toMutableList() } + registryItemId = embeddedMetadata.registryItemId.map { it.toMutableList() } + registryOrganisationId = + embeddedMetadata.registryOrganisationId.map { it.toMutableList() } + resolutionUnit = embeddedMetadata.resolutionUnit + rights = embeddedMetadata.rights + scene = embeddedMetadata.scene.map { it.toMutableList() } + source = embeddedMetadata.source + specialInstructions = embeddedMetadata.specialInstructions + state = embeddedMetadata.state + subject = embeddedMetadata.subject.map { it.toMutableList() } + subjectCode = embeddedMetadata.subjectCode.map { it.toMutableList() } + subjectReference = embeddedMetadata.subjectReference.map { it.toMutableList() } + sublocation = embeddedMetadata.sublocation + timeCreated = embeddedMetadata.timeCreated + title = embeddedMetadata.title + transmissionReference = embeddedMetadata.transmissionReference + usageTerms = embeddedMetadata.usageTerms + webStatement = embeddedMetadata.webStatement + writer = embeddedMetadata.writer + writerEditor = embeddedMetadata.writerEditor + xResolution = embeddedMetadata.xResolution + yResolution = embeddedMetadata.yResolution + additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() + } + + fun aboutCvTermCvId(aboutCvTermCvId: String) = + aboutCvTermCvId(JsonField.of(aboutCvTermCvId)) + + /** + * Sets [Builder.aboutCvTermCvId] to an arbitrary JSON value. + * + * You should usually call [Builder.aboutCvTermCvId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aboutCvTermCvId(aboutCvTermCvId: JsonField) = apply { + this.aboutCvTermCvId = aboutCvTermCvId + } + + fun aboutCvTermId(aboutCvTermId: String) = aboutCvTermId(JsonField.of(aboutCvTermId)) + + /** + * Sets [Builder.aboutCvTermId] to an arbitrary JSON value. + * + * You should usually call [Builder.aboutCvTermId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aboutCvTermId(aboutCvTermId: JsonField) = apply { + this.aboutCvTermId = aboutCvTermId + } + + fun aboutCvTermName(aboutCvTermName: String) = + aboutCvTermName(JsonField.of(aboutCvTermName)) + + /** + * Sets [Builder.aboutCvTermName] to an arbitrary JSON value. + * + * You should usually call [Builder.aboutCvTermName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aboutCvTermName(aboutCvTermName: JsonField) = apply { + this.aboutCvTermName = aboutCvTermName + } + + fun aboutCvTermRefinedAbout(aboutCvTermRefinedAbout: String) = + aboutCvTermRefinedAbout(JsonField.of(aboutCvTermRefinedAbout)) + + /** + * Sets [Builder.aboutCvTermRefinedAbout] to an arbitrary JSON value. + * + * You should usually call [Builder.aboutCvTermRefinedAbout] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun aboutCvTermRefinedAbout(aboutCvTermRefinedAbout: JsonField) = apply { + this.aboutCvTermRefinedAbout = aboutCvTermRefinedAbout + } + + fun additionalModelInformation(additionalModelInformation: String) = + additionalModelInformation(JsonField.of(additionalModelInformation)) + + /** + * Sets [Builder.additionalModelInformation] to an arbitrary JSON value. + * + * You should usually call [Builder.additionalModelInformation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun additionalModelInformation(additionalModelInformation: JsonField) = apply { + this.additionalModelInformation = additionalModelInformation + } + + fun applicationRecordVersion(applicationRecordVersion: Long) = + applicationRecordVersion(JsonField.of(applicationRecordVersion)) + + /** + * Sets [Builder.applicationRecordVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.applicationRecordVersion] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun applicationRecordVersion(applicationRecordVersion: JsonField) = apply { + this.applicationRecordVersion = applicationRecordVersion + } + + fun artist(artist: String) = artist(JsonField.of(artist)) + + /** + * Sets [Builder.artist] to an arbitrary JSON value. + * + * You should usually call [Builder.artist] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artist(artist: JsonField) = apply { this.artist = artist } + + fun artworkCircaDateCreated(artworkCircaDateCreated: String) = + artworkCircaDateCreated(JsonField.of(artworkCircaDateCreated)) + + /** + * Sets [Builder.artworkCircaDateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCircaDateCreated] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCircaDateCreated(artworkCircaDateCreated: JsonField) = apply { + this.artworkCircaDateCreated = artworkCircaDateCreated + } + + fun artworkContentDescription(artworkContentDescription: String) = + artworkContentDescription(JsonField.of(artworkContentDescription)) + + /** + * Sets [Builder.artworkContentDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkContentDescription] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkContentDescription(artworkContentDescription: JsonField) = apply { + this.artworkContentDescription = artworkContentDescription + } + + fun artworkContributionDescription(artworkContributionDescription: String) = + artworkContributionDescription(JsonField.of(artworkContributionDescription)) + + /** + * Sets [Builder.artworkContributionDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkContributionDescription] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkContributionDescription(artworkContributionDescription: JsonField) = + apply { + this.artworkContributionDescription = artworkContributionDescription + } + + fun artworkCopyrightNotice(artworkCopyrightNotice: String) = + artworkCopyrightNotice(JsonField.of(artworkCopyrightNotice)) + + /** + * Sets [Builder.artworkCopyrightNotice] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCopyrightNotice] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCopyrightNotice(artworkCopyrightNotice: JsonField) = apply { + this.artworkCopyrightNotice = artworkCopyrightNotice + } + + fun artworkCopyrightOwnerId(artworkCopyrightOwnerId: String) = + artworkCopyrightOwnerId(JsonField.of(artworkCopyrightOwnerId)) + + /** + * Sets [Builder.artworkCopyrightOwnerId] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCopyrightOwnerId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCopyrightOwnerId(artworkCopyrightOwnerId: JsonField) = apply { + this.artworkCopyrightOwnerId = artworkCopyrightOwnerId + } + + fun artworkCopyrightOwnerName(artworkCopyrightOwnerName: String) = + artworkCopyrightOwnerName(JsonField.of(artworkCopyrightOwnerName)) + + /** + * Sets [Builder.artworkCopyrightOwnerName] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCopyrightOwnerName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkCopyrightOwnerName(artworkCopyrightOwnerName: JsonField) = apply { + this.artworkCopyrightOwnerName = artworkCopyrightOwnerName + } + + fun artworkCreator(artworkCreator: List) = + artworkCreator(JsonField.of(artworkCreator)) + + /** + * Sets [Builder.artworkCreator] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCreator] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCreator(artworkCreator: JsonField>) = apply { + this.artworkCreator = artworkCreator.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.artworkCreator]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArtworkCreator(artworkCreator: String) = apply { + this.artworkCreator = + (this.artworkCreator ?: JsonField.of(mutableListOf())).also { + checkKnown("artworkCreator", it).add(artworkCreator) + } + } + + fun artworkCreatorId(artworkCreatorId: List) = + artworkCreatorId(JsonField.of(artworkCreatorId)) + + /** + * Sets [Builder.artworkCreatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkCreatorId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkCreatorId(artworkCreatorId: JsonField>) = apply { + this.artworkCreatorId = artworkCreatorId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.artworkCreatorId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArtworkCreatorId(artworkCreatorId: String) = apply { + this.artworkCreatorId = + (this.artworkCreatorId ?: JsonField.of(mutableListOf())).also { + checkKnown("artworkCreatorId", it).add(artworkCreatorId) + } + } + + fun artworkDateCreated(artworkDateCreated: OffsetDateTime) = + artworkDateCreated(JsonField.of(artworkDateCreated)) + + /** + * Sets [Builder.artworkDateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkDateCreated] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkDateCreated(artworkDateCreated: JsonField) = apply { + this.artworkDateCreated = artworkDateCreated + } + + fun artworkLicensorId(artworkLicensorId: String) = + artworkLicensorId(JsonField.of(artworkLicensorId)) + + /** + * Sets [Builder.artworkLicensorId] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkLicensorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artworkLicensorId(artworkLicensorId: JsonField) = apply { + this.artworkLicensorId = artworkLicensorId + } + + fun artworkLicensorName(artworkLicensorName: String) = + artworkLicensorName(JsonField.of(artworkLicensorName)) + + /** + * Sets [Builder.artworkLicensorName] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkLicensorName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkLicensorName(artworkLicensorName: JsonField) = apply { + this.artworkLicensorName = artworkLicensorName + } + + fun artworkPhysicalDescription(artworkPhysicalDescription: String) = + artworkPhysicalDescription(JsonField.of(artworkPhysicalDescription)) + + /** + * Sets [Builder.artworkPhysicalDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkPhysicalDescription] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun artworkPhysicalDescription(artworkPhysicalDescription: JsonField) = apply { + this.artworkPhysicalDescription = artworkPhysicalDescription + } + + fun artworkSource(artworkSource: String) = artworkSource(JsonField.of(artworkSource)) + + /** + * Sets [Builder.artworkSource] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkSource] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artworkSource(artworkSource: JsonField) = apply { + this.artworkSource = artworkSource + } + + fun artworkSourceInventoryNo(artworkSourceInventoryNo: String) = + artworkSourceInventoryNo(JsonField.of(artworkSourceInventoryNo)) + + /** + * Sets [Builder.artworkSourceInventoryNo] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkSourceInventoryNo] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkSourceInventoryNo(artworkSourceInventoryNo: JsonField) = apply { + this.artworkSourceInventoryNo = artworkSourceInventoryNo + } + + fun artworkSourceInvUrl(artworkSourceInvUrl: String) = + artworkSourceInvUrl(JsonField.of(artworkSourceInvUrl)) + + /** + * Sets [Builder.artworkSourceInvUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkSourceInvUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkSourceInvUrl(artworkSourceInvUrl: JsonField) = apply { + this.artworkSourceInvUrl = artworkSourceInvUrl + } + + fun artworkStylePeriod(artworkStylePeriod: List) = + artworkStylePeriod(JsonField.of(artworkStylePeriod)) + + /** + * Sets [Builder.artworkStylePeriod] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkStylePeriod] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun artworkStylePeriod(artworkStylePeriod: JsonField>) = apply { + this.artworkStylePeriod = artworkStylePeriod.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.artworkStylePeriod]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addArtworkStylePeriod(artworkStylePeriod: String) = apply { + this.artworkStylePeriod = + (this.artworkStylePeriod ?: JsonField.of(mutableListOf())).also { + checkKnown("artworkStylePeriod", it).add(artworkStylePeriod) + } + } + + fun artworkTitle(artworkTitle: String) = artworkTitle(JsonField.of(artworkTitle)) + + /** + * Sets [Builder.artworkTitle] to an arbitrary JSON value. + * + * You should usually call [Builder.artworkTitle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun artworkTitle(artworkTitle: JsonField) = apply { + this.artworkTitle = artworkTitle + } + + fun authorsPosition(authorsPosition: String) = + authorsPosition(JsonField.of(authorsPosition)) + + /** + * Sets [Builder.authorsPosition] to an arbitrary JSON value. + * + * You should usually call [Builder.authorsPosition] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authorsPosition(authorsPosition: JsonField) = apply { + this.authorsPosition = authorsPosition + } + + fun byline(byline: String) = byline(JsonField.of(byline)) + + /** + * Sets [Builder.byline] to an arbitrary JSON value. + * + * You should usually call [Builder.byline] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun byline(byline: JsonField) = apply { this.byline = byline } + + fun bylineTitle(bylineTitle: String) = bylineTitle(JsonField.of(bylineTitle)) + + /** + * Sets [Builder.bylineTitle] to an arbitrary JSON value. + * + * You should usually call [Builder.bylineTitle] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bylineTitle(bylineTitle: JsonField) = apply { + this.bylineTitle = bylineTitle + } + + fun caption(caption: String) = caption(JsonField.of(caption)) + + /** + * Sets [Builder.caption] to an arbitrary JSON value. + * + * You should usually call [Builder.caption] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caption(caption: JsonField) = apply { this.caption = caption } + + fun captionAbstract(captionAbstract: String) = + captionAbstract(JsonField.of(captionAbstract)) + + /** + * Sets [Builder.captionAbstract] to an arbitrary JSON value. + * + * You should usually call [Builder.captionAbstract] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun captionAbstract(captionAbstract: JsonField) = apply { + this.captionAbstract = captionAbstract + } + + fun captionWriter(captionWriter: String) = captionWriter(JsonField.of(captionWriter)) + + /** + * Sets [Builder.captionWriter] to an arbitrary JSON value. + * + * You should usually call [Builder.captionWriter] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun captionWriter(captionWriter: JsonField) = apply { + this.captionWriter = captionWriter + } + + fun city(city: String) = city(JsonField.of(city)) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun city(city: JsonField) = apply { this.city = city } + + fun colorSpace(colorSpace: String) = colorSpace(JsonField.of(colorSpace)) + + /** + * Sets [Builder.colorSpace] to an arbitrary JSON value. + * + * You should usually call [Builder.colorSpace] with a well-typed [String] 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 componentsConfiguration(componentsConfiguration: String) = + componentsConfiguration(JsonField.of(componentsConfiguration)) + + /** + * Sets [Builder.componentsConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.componentsConfiguration] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun componentsConfiguration(componentsConfiguration: JsonField) = apply { + this.componentsConfiguration = componentsConfiguration + } + + fun copyright(copyright: String) = copyright(JsonField.of(copyright)) + + /** + * Sets [Builder.copyright] to an arbitrary JSON value. + * + * You should usually call [Builder.copyright] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun copyright(copyright: JsonField) = apply { this.copyright = copyright } + + fun copyrightNotice(copyrightNotice: String) = + copyrightNotice(JsonField.of(copyrightNotice)) + + /** + * Sets [Builder.copyrightNotice] to an arbitrary JSON value. + * + * You should usually call [Builder.copyrightNotice] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun copyrightNotice(copyrightNotice: JsonField) = apply { + this.copyrightNotice = copyrightNotice + } + + fun copyrightOwnerId(copyrightOwnerId: List) = + copyrightOwnerId(JsonField.of(copyrightOwnerId)) + + /** + * Sets [Builder.copyrightOwnerId] to an arbitrary JSON value. + * + * You should usually call [Builder.copyrightOwnerId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun copyrightOwnerId(copyrightOwnerId: JsonField>) = apply { + this.copyrightOwnerId = copyrightOwnerId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.copyrightOwnerId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCopyrightOwnerId(copyrightOwnerId: String) = apply { + this.copyrightOwnerId = + (this.copyrightOwnerId ?: JsonField.of(mutableListOf())).also { + checkKnown("copyrightOwnerId", it).add(copyrightOwnerId) + } + } + + fun copyrightOwnerName(copyrightOwnerName: List) = + copyrightOwnerName(JsonField.of(copyrightOwnerName)) + + /** + * Sets [Builder.copyrightOwnerName] to an arbitrary JSON value. + * + * You should usually call [Builder.copyrightOwnerName] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun copyrightOwnerName(copyrightOwnerName: JsonField>) = apply { + this.copyrightOwnerName = copyrightOwnerName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.copyrightOwnerName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCopyrightOwnerName(copyrightOwnerName: String) = apply { + this.copyrightOwnerName = + (this.copyrightOwnerName ?: JsonField.of(mutableListOf())).also { + checkKnown("copyrightOwnerName", it).add(copyrightOwnerName) + } + } + + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + fun countryCode(countryCode: String) = countryCode(JsonField.of(countryCode)) + + /** + * Sets [Builder.countryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.countryCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun countryCode(countryCode: JsonField) = apply { + this.countryCode = countryCode + } + + fun countryPrimaryLocationCode(countryPrimaryLocationCode: String) = + countryPrimaryLocationCode(JsonField.of(countryPrimaryLocationCode)) + + /** + * Sets [Builder.countryPrimaryLocationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.countryPrimaryLocationCode] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun countryPrimaryLocationCode(countryPrimaryLocationCode: JsonField) = apply { + this.countryPrimaryLocationCode = countryPrimaryLocationCode + } + + fun countryPrimaryLocationName(countryPrimaryLocationName: String) = + countryPrimaryLocationName(JsonField.of(countryPrimaryLocationName)) + + /** + * Sets [Builder.countryPrimaryLocationName] to an arbitrary JSON value. + * + * You should usually call [Builder.countryPrimaryLocationName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun countryPrimaryLocationName(countryPrimaryLocationName: JsonField) = apply { + this.countryPrimaryLocationName = countryPrimaryLocationName + } + + fun creator(creator: String) = creator(JsonField.of(creator)) + + /** + * Sets [Builder.creator] to an arbitrary JSON value. + * + * You should usually call [Builder.creator] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creator(creator: JsonField) = apply { this.creator = creator } + + fun creatorAddress(creatorAddress: String) = + creatorAddress(JsonField.of(creatorAddress)) + + /** + * Sets [Builder.creatorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorAddress(creatorAddress: JsonField) = apply { + this.creatorAddress = creatorAddress + } + + fun creatorCity(creatorCity: String) = creatorCity(JsonField.of(creatorCity)) + + /** + * Sets [Builder.creatorCity] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorCity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorCity(creatorCity: JsonField) = apply { + this.creatorCity = creatorCity + } + + fun creatorCountry(creatorCountry: String) = + creatorCountry(JsonField.of(creatorCountry)) + + /** + * Sets [Builder.creatorCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorCountry] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorCountry(creatorCountry: JsonField) = apply { + this.creatorCountry = creatorCountry + } + + fun creatorPostalCode(creatorPostalCode: String) = + creatorPostalCode(JsonField.of(creatorPostalCode)) + + /** + * Sets [Builder.creatorPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorPostalCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorPostalCode(creatorPostalCode: JsonField) = apply { + this.creatorPostalCode = creatorPostalCode + } + + fun creatorRegion(creatorRegion: String) = creatorRegion(JsonField.of(creatorRegion)) + + /** + * Sets [Builder.creatorRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorRegion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorRegion(creatorRegion: JsonField) = apply { + this.creatorRegion = creatorRegion + } + + fun creatorWorkEmail(creatorWorkEmail: String) = + creatorWorkEmail(JsonField.of(creatorWorkEmail)) + + /** + * Sets [Builder.creatorWorkEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorWorkEmail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorWorkEmail(creatorWorkEmail: JsonField) = apply { + this.creatorWorkEmail = creatorWorkEmail + } + + fun creatorWorkTelephone(creatorWorkTelephone: String) = + creatorWorkTelephone(JsonField.of(creatorWorkTelephone)) + + /** + * Sets [Builder.creatorWorkTelephone] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorWorkTelephone] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun creatorWorkTelephone(creatorWorkTelephone: JsonField) = apply { + this.creatorWorkTelephone = creatorWorkTelephone + } + + fun creatorWorkUrl(creatorWorkUrl: String) = + creatorWorkUrl(JsonField.of(creatorWorkUrl)) + + /** + * Sets [Builder.creatorWorkUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorWorkUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorWorkUrl(creatorWorkUrl: JsonField) = apply { + this.creatorWorkUrl = creatorWorkUrl + } + + fun credit(credit: String) = credit(JsonField.of(credit)) + + /** + * Sets [Builder.credit] to an arbitrary JSON value. + * + * You should usually call [Builder.credit] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credit(credit: JsonField) = apply { this.credit = credit } + + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + fun dateTimeCreated(dateTimeCreated: OffsetDateTime) = + dateTimeCreated(JsonField.of(dateTimeCreated)) + + /** + * Sets [Builder.dateTimeCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateTimeCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateTimeCreated(dateTimeCreated: JsonField) = apply { + this.dateTimeCreated = dateTimeCreated + } + + fun dateTimeOriginal(dateTimeOriginal: OffsetDateTime) = + dateTimeOriginal(JsonField.of(dateTimeOriginal)) + + /** + * Sets [Builder.dateTimeOriginal] to an arbitrary JSON value. + * + * You should usually call [Builder.dateTimeOriginal] with a well-typed [OffsetDateTime] + * 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 description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun digitalImageGuid(digitalImageGuid: String) = + digitalImageGuid(JsonField.of(digitalImageGuid)) + + /** + * Sets [Builder.digitalImageGuid] to an arbitrary JSON value. + * + * You should usually call [Builder.digitalImageGuid] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun digitalImageGuid(digitalImageGuid: JsonField) = apply { + this.digitalImageGuid = digitalImageGuid + } + + fun digitalSourceType(digitalSourceType: String) = + digitalSourceType(JsonField.of(digitalSourceType)) + + /** + * Sets [Builder.digitalSourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.digitalSourceType] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun digitalSourceType(digitalSourceType: JsonField) = apply { + this.digitalSourceType = digitalSourceType + } + + fun embeddedEncodedRightsExpr(embeddedEncodedRightsExpr: String) = + embeddedEncodedRightsExpr(JsonField.of(embeddedEncodedRightsExpr)) + + /** + * Sets [Builder.embeddedEncodedRightsExpr] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedEncodedRightsExpr] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun embeddedEncodedRightsExpr(embeddedEncodedRightsExpr: JsonField) = apply { + this.embeddedEncodedRightsExpr = embeddedEncodedRightsExpr + } + + fun embeddedEncodedRightsExprLangId(embeddedEncodedRightsExprLangId: String) = + embeddedEncodedRightsExprLangId(JsonField.of(embeddedEncodedRightsExprLangId)) + + /** + * Sets [Builder.embeddedEncodedRightsExprLangId] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedEncodedRightsExprLangId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun embeddedEncodedRightsExprLangId( + embeddedEncodedRightsExprLangId: JsonField + ) = apply { this.embeddedEncodedRightsExprLangId = embeddedEncodedRightsExprLangId } + + fun embeddedEncodedRightsExprType(embeddedEncodedRightsExprType: String) = + embeddedEncodedRightsExprType(JsonField.of(embeddedEncodedRightsExprType)) + + /** + * Sets [Builder.embeddedEncodedRightsExprType] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedEncodedRightsExprType] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun embeddedEncodedRightsExprType(embeddedEncodedRightsExprType: JsonField) = + apply { + this.embeddedEncodedRightsExprType = embeddedEncodedRightsExprType + } + + fun event(event: String) = event(JsonField.of(event)) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + 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 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 genreCvId(genreCvId: String) = genreCvId(JsonField.of(genreCvId)) + + /** + * Sets [Builder.genreCvId] to an arbitrary JSON value. + * + * You should usually call [Builder.genreCvId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun genreCvId(genreCvId: JsonField) = apply { this.genreCvId = genreCvId } + + fun genreCvTermId(genreCvTermId: String) = genreCvTermId(JsonField.of(genreCvTermId)) + + /** + * Sets [Builder.genreCvTermId] to an arbitrary JSON value. + * + * You should usually call [Builder.genreCvTermId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun genreCvTermId(genreCvTermId: JsonField) = apply { + this.genreCvTermId = genreCvTermId + } + + fun genreCvTermName(genreCvTermName: String) = + genreCvTermName(JsonField.of(genreCvTermName)) + + /** + * Sets [Builder.genreCvTermName] to an arbitrary JSON value. + * + * You should usually call [Builder.genreCvTermName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun genreCvTermName(genreCvTermName: JsonField) = apply { + this.genreCvTermName = genreCvTermName + } + + fun genreCvTermRefinedAbout(genreCvTermRefinedAbout: String) = + genreCvTermRefinedAbout(JsonField.of(genreCvTermRefinedAbout)) + + /** + * Sets [Builder.genreCvTermRefinedAbout] to an arbitrary JSON value. + * + * You should usually call [Builder.genreCvTermRefinedAbout] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun genreCvTermRefinedAbout(genreCvTermRefinedAbout: JsonField) = apply { + this.genreCvTermRefinedAbout = genreCvTermRefinedAbout + } + + fun headline(headline: String) = headline(JsonField.of(headline)) + + /** + * Sets [Builder.headline] to an arbitrary JSON value. + * + * You should usually call [Builder.headline] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun headline(headline: JsonField) = apply { this.headline = headline } + + fun imageCreatorId(imageCreatorId: String) = + imageCreatorId(JsonField.of(imageCreatorId)) + + /** + * Sets [Builder.imageCreatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageCreatorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageCreatorId(imageCreatorId: JsonField) = apply { + this.imageCreatorId = imageCreatorId + } + + fun imageCreatorImageId(imageCreatorImageId: String) = + imageCreatorImageId(JsonField.of(imageCreatorImageId)) + + /** + * Sets [Builder.imageCreatorImageId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageCreatorImageId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageCreatorImageId(imageCreatorImageId: JsonField) = apply { + this.imageCreatorImageId = imageCreatorImageId + } + + fun imageCreatorName(imageCreatorName: String) = + imageCreatorName(JsonField.of(imageCreatorName)) + + /** + * Sets [Builder.imageCreatorName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageCreatorName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageCreatorName(imageCreatorName: JsonField) = apply { + this.imageCreatorName = imageCreatorName + } + + fun imageDescription(imageDescription: String) = + imageDescription(JsonField.of(imageDescription)) + + /** + * Sets [Builder.imageDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.imageDescription] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageDescription(imageDescription: JsonField) = apply { + this.imageDescription = imageDescription + } + + fun imageRegionBoundaryH(imageRegionBoundaryH: List) = + imageRegionBoundaryH(JsonField.of(imageRegionBoundaryH)) + + /** + * Sets [Builder.imageRegionBoundaryH] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryH] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryH(imageRegionBoundaryH: JsonField>) = apply { + this.imageRegionBoundaryH = imageRegionBoundaryH.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryH]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryH(imageRegionBoundaryH: Double) = apply { + this.imageRegionBoundaryH = + (this.imageRegionBoundaryH ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryH", it).add(imageRegionBoundaryH) + } + } + + fun imageRegionBoundaryRx(imageRegionBoundaryRx: List) = + imageRegionBoundaryRx(JsonField.of(imageRegionBoundaryRx)) + + /** + * Sets [Builder.imageRegionBoundaryRx] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryRx] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryRx(imageRegionBoundaryRx: JsonField>) = apply { + this.imageRegionBoundaryRx = imageRegionBoundaryRx.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryRx]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryRx(imageRegionBoundaryRx: Double) = apply { + this.imageRegionBoundaryRx = + (this.imageRegionBoundaryRx ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryRx", it).add(imageRegionBoundaryRx) + } + } + + fun imageRegionBoundaryShape(imageRegionBoundaryShape: List) = + imageRegionBoundaryShape(JsonField.of(imageRegionBoundaryShape)) + + /** + * Sets [Builder.imageRegionBoundaryShape] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryShape] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryShape(imageRegionBoundaryShape: JsonField>) = + apply { + this.imageRegionBoundaryShape = + imageRegionBoundaryShape.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionBoundaryShape]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryShape(imageRegionBoundaryShape: String) = apply { + this.imageRegionBoundaryShape = + (this.imageRegionBoundaryShape ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryShape", it).add(imageRegionBoundaryShape) + } + } + + fun imageRegionBoundaryUnit(imageRegionBoundaryUnit: List) = + imageRegionBoundaryUnit(JsonField.of(imageRegionBoundaryUnit)) + + /** + * Sets [Builder.imageRegionBoundaryUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryUnit] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryUnit(imageRegionBoundaryUnit: JsonField>) = apply { + this.imageRegionBoundaryUnit = imageRegionBoundaryUnit.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionBoundaryUnit]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryUnit(imageRegionBoundaryUnit: String) = apply { + this.imageRegionBoundaryUnit = + (this.imageRegionBoundaryUnit ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryUnit", it).add(imageRegionBoundaryUnit) + } + } + + fun imageRegionBoundaryVerticesX(imageRegionBoundaryVerticesX: List) = + imageRegionBoundaryVerticesX(JsonField.of(imageRegionBoundaryVerticesX)) + + /** + * Sets [Builder.imageRegionBoundaryVerticesX] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryVerticesX] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryVerticesX( + imageRegionBoundaryVerticesX: JsonField> + ) = apply { + this.imageRegionBoundaryVerticesX = + imageRegionBoundaryVerticesX.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryVerticesX]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryVerticesX(imageRegionBoundaryVerticesX: Double) = apply { + this.imageRegionBoundaryVerticesX = + (this.imageRegionBoundaryVerticesX ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryVerticesX", it) + .add(imageRegionBoundaryVerticesX) + } + } + + fun imageRegionBoundaryVerticesY(imageRegionBoundaryVerticesY: List) = + imageRegionBoundaryVerticesY(JsonField.of(imageRegionBoundaryVerticesY)) + + /** + * Sets [Builder.imageRegionBoundaryVerticesY] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryVerticesY] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryVerticesY( + imageRegionBoundaryVerticesY: JsonField> + ) = apply { + this.imageRegionBoundaryVerticesY = + imageRegionBoundaryVerticesY.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryVerticesY]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryVerticesY(imageRegionBoundaryVerticesY: Double) = apply { + this.imageRegionBoundaryVerticesY = + (this.imageRegionBoundaryVerticesY ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryVerticesY", it) + .add(imageRegionBoundaryVerticesY) + } + } + + fun imageRegionBoundaryW(imageRegionBoundaryW: List) = + imageRegionBoundaryW(JsonField.of(imageRegionBoundaryW)) + + /** + * Sets [Builder.imageRegionBoundaryW] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryW] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryW(imageRegionBoundaryW: JsonField>) = apply { + this.imageRegionBoundaryW = imageRegionBoundaryW.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryW]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryW(imageRegionBoundaryW: Double) = apply { + this.imageRegionBoundaryW = + (this.imageRegionBoundaryW ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryW", it).add(imageRegionBoundaryW) + } + } + + fun imageRegionBoundaryX(imageRegionBoundaryX: List) = + imageRegionBoundaryX(JsonField.of(imageRegionBoundaryX)) + + /** + * Sets [Builder.imageRegionBoundaryX] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryX] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryX(imageRegionBoundaryX: JsonField>) = apply { + this.imageRegionBoundaryX = imageRegionBoundaryX.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryX]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryX(imageRegionBoundaryX: Double) = apply { + this.imageRegionBoundaryX = + (this.imageRegionBoundaryX ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryX", it).add(imageRegionBoundaryX) + } + } + + fun imageRegionBoundaryY(imageRegionBoundaryY: List) = + imageRegionBoundaryY(JsonField.of(imageRegionBoundaryY)) + + /** + * Sets [Builder.imageRegionBoundaryY] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionBoundaryY] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionBoundaryY(imageRegionBoundaryY: JsonField>) = apply { + this.imageRegionBoundaryY = imageRegionBoundaryY.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.imageRegionBoundaryY]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionBoundaryY(imageRegionBoundaryY: Double) = apply { + this.imageRegionBoundaryY = + (this.imageRegionBoundaryY ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionBoundaryY", it).add(imageRegionBoundaryY) + } + } + + fun imageRegionCtypeIdentifier(imageRegionCtypeIdentifier: List) = + imageRegionCtypeIdentifier(JsonField.of(imageRegionCtypeIdentifier)) + + /** + * Sets [Builder.imageRegionCtypeIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionCtypeIdentifier] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionCtypeIdentifier(imageRegionCtypeIdentifier: JsonField>) = + apply { + this.imageRegionCtypeIdentifier = + imageRegionCtypeIdentifier.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionCtypeIdentifier]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionCtypeIdentifier(imageRegionCtypeIdentifier: String) = apply { + this.imageRegionCtypeIdentifier = + (this.imageRegionCtypeIdentifier ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionCtypeIdentifier", it).add(imageRegionCtypeIdentifier) + } + } + + fun imageRegionCtypeName(imageRegionCtypeName: List) = + imageRegionCtypeName(JsonField.of(imageRegionCtypeName)) + + /** + * Sets [Builder.imageRegionCtypeName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionCtypeName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionCtypeName(imageRegionCtypeName: JsonField>) = apply { + this.imageRegionCtypeName = imageRegionCtypeName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionCtypeName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionCtypeName(imageRegionCtypeName: String) = apply { + this.imageRegionCtypeName = + (this.imageRegionCtypeName ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionCtypeName", it).add(imageRegionCtypeName) + } + } + + fun imageRegionId(imageRegionId: List) = + imageRegionId(JsonField.of(imageRegionId)) + + /** + * Sets [Builder.imageRegionId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageRegionId(imageRegionId: JsonField>) = apply { + this.imageRegionId = imageRegionId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionId(imageRegionId: String) = apply { + this.imageRegionId = + (this.imageRegionId ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionId", it).add(imageRegionId) + } + } + + fun imageRegionName(imageRegionName: List) = + imageRegionName(JsonField.of(imageRegionName)) + + /** + * Sets [Builder.imageRegionName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionName] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageRegionName(imageRegionName: JsonField>) = apply { + this.imageRegionName = imageRegionName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionName(imageRegionName: String) = apply { + this.imageRegionName = + (this.imageRegionName ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionName", it).add(imageRegionName) + } + } + + fun imageRegionOrganisationInImageName( + imageRegionOrganisationInImageName: List + ) = imageRegionOrganisationInImageName(JsonField.of(imageRegionOrganisationInImageName)) + + /** + * Sets [Builder.imageRegionOrganisationInImageName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionOrganisationInImageName] with a + * well-typed `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun imageRegionOrganisationInImageName( + imageRegionOrganisationInImageName: JsonField> + ) = apply { + this.imageRegionOrganisationInImageName = + imageRegionOrganisationInImageName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionOrganisationInImageName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionOrganisationInImageName(imageRegionOrganisationInImageName: String) = + apply { + this.imageRegionOrganisationInImageName = + (this.imageRegionOrganisationInImageName ?: JsonField.of(mutableListOf())) + .also { + checkKnown("imageRegionOrganisationInImageName", it) + .add(imageRegionOrganisationInImageName) + } + } + + fun imageRegionPersonInImage(imageRegionPersonInImage: List) = + imageRegionPersonInImage(JsonField.of(imageRegionPersonInImage)) + + /** + * Sets [Builder.imageRegionPersonInImage] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionPersonInImage] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionPersonInImage(imageRegionPersonInImage: JsonField>) = + apply { + this.imageRegionPersonInImage = + imageRegionPersonInImage.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionPersonInImage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionPersonInImage(imageRegionPersonInImage: String) = apply { + this.imageRegionPersonInImage = + (this.imageRegionPersonInImage ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionPersonInImage", it).add(imageRegionPersonInImage) + } + } + + fun imageRegionRoleIdentifier(imageRegionRoleIdentifier: List) = + imageRegionRoleIdentifier(JsonField.of(imageRegionRoleIdentifier)) + + /** + * Sets [Builder.imageRegionRoleIdentifier] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionRoleIdentifier] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionRoleIdentifier(imageRegionRoleIdentifier: JsonField>) = + apply { + this.imageRegionRoleIdentifier = + imageRegionRoleIdentifier.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionRoleIdentifier]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionRoleIdentifier(imageRegionRoleIdentifier: String) = apply { + this.imageRegionRoleIdentifier = + (this.imageRegionRoleIdentifier ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionRoleIdentifier", it).add(imageRegionRoleIdentifier) + } + } + + fun imageRegionRoleName(imageRegionRoleName: List) = + imageRegionRoleName(JsonField.of(imageRegionRoleName)) + + /** + * Sets [Builder.imageRegionRoleName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageRegionRoleName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun imageRegionRoleName(imageRegionRoleName: JsonField>) = apply { + this.imageRegionRoleName = imageRegionRoleName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.imageRegionRoleName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageRegionRoleName(imageRegionRoleName: String) = apply { + this.imageRegionRoleName = + (this.imageRegionRoleName ?: JsonField.of(mutableListOf())).also { + checkKnown("imageRegionRoleName", it).add(imageRegionRoleName) + } + } + + fun imageSupplierId(imageSupplierId: String) = + imageSupplierId(JsonField.of(imageSupplierId)) + + /** + * Sets [Builder.imageSupplierId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageSupplierId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageSupplierId(imageSupplierId: JsonField) = apply { + this.imageSupplierId = imageSupplierId + } + + fun imageSupplierImageId(imageSupplierImageId: String) = + imageSupplierImageId(JsonField.of(imageSupplierImageId)) + + /** + * Sets [Builder.imageSupplierImageId] to an arbitrary JSON value. + * + * You should usually call [Builder.imageSupplierImageId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun imageSupplierImageId(imageSupplierImageId: JsonField) = apply { + this.imageSupplierImageId = imageSupplierImageId + } + + fun imageSupplierName(imageSupplierName: String) = + imageSupplierName(JsonField.of(imageSupplierName)) + + /** + * Sets [Builder.imageSupplierName] to an arbitrary JSON value. + * + * You should usually call [Builder.imageSupplierName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageSupplierName(imageSupplierName: JsonField) = apply { + this.imageSupplierName = imageSupplierName + } + + fun instructions(instructions: String) = instructions(JsonField.of(instructions)) + + /** + * Sets [Builder.instructions] to an arbitrary JSON value. + * + * You should usually call [Builder.instructions] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun instructions(instructions: JsonField) = apply { + this.instructions = instructions + } + + fun intellectualGenre(intellectualGenre: String) = + intellectualGenre(JsonField.of(intellectualGenre)) + + /** + * Sets [Builder.intellectualGenre] to an arbitrary JSON value. + * + * You should usually call [Builder.intellectualGenre] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun intellectualGenre(intellectualGenre: JsonField) = apply { + this.intellectualGenre = intellectualGenre + } + + fun keywords(keywords: List) = keywords(JsonField.of(keywords)) + + /** + * Sets [Builder.keywords] to an arbitrary JSON value. + * + * You should usually call [Builder.keywords] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun keywords(keywords: JsonField>) = apply { + this.keywords = keywords.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [keywords]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addKeyword(keyword: String) = apply { + keywords = + (keywords ?: JsonField.of(mutableListOf())).also { + checkKnown("keywords", it).add(keyword) + } + } + + fun licensorCity(licensorCity: List) = licensorCity(JsonField.of(licensorCity)) + + /** + * Sets [Builder.licensorCity] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorCity] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licensorCity(licensorCity: JsonField>) = apply { + this.licensorCity = licensorCity.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorCity]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorCity(licensorCity: String) = apply { + this.licensorCity = + (this.licensorCity ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorCity", it).add(licensorCity) + } + } + + fun licensorCountry(licensorCountry: List) = + licensorCountry(JsonField.of(licensorCountry)) + + /** + * Sets [Builder.licensorCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorCountry] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorCountry(licensorCountry: JsonField>) = apply { + this.licensorCountry = licensorCountry.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorCountry]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorCountry(licensorCountry: String) = apply { + this.licensorCountry = + (this.licensorCountry ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorCountry", it).add(licensorCountry) + } + } + + fun licensorEmail(licensorEmail: List) = + licensorEmail(JsonField.of(licensorEmail)) + + /** + * Sets [Builder.licensorEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorEmail] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorEmail(licensorEmail: JsonField>) = apply { + this.licensorEmail = licensorEmail.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorEmail]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorEmail(licensorEmail: String) = apply { + this.licensorEmail = + (this.licensorEmail ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorEmail", it).add(licensorEmail) + } + } + + fun licensorExtendedAddress(licensorExtendedAddress: List) = + licensorExtendedAddress(JsonField.of(licensorExtendedAddress)) + + /** + * Sets [Builder.licensorExtendedAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorExtendedAddress] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licensorExtendedAddress(licensorExtendedAddress: JsonField>) = apply { + this.licensorExtendedAddress = licensorExtendedAddress.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorExtendedAddress]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorExtendedAddress(licensorExtendedAddress: String) = apply { + this.licensorExtendedAddress = + (this.licensorExtendedAddress ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorExtendedAddress", it).add(licensorExtendedAddress) + } + } + + fun licensorId(licensorId: List) = licensorId(JsonField.of(licensorId)) + + /** + * Sets [Builder.licensorId] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorId] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licensorId(licensorId: JsonField>) = apply { + this.licensorId = licensorId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorId(licensorId: String) = apply { + this.licensorId = + (this.licensorId ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorId", it).add(licensorId) + } + } + + fun licensorName(licensorName: List) = licensorName(JsonField.of(licensorName)) + + /** + * Sets [Builder.licensorName] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorName] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licensorName(licensorName: JsonField>) = apply { + this.licensorName = licensorName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorName(licensorName: String) = apply { + this.licensorName = + (this.licensorName ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorName", it).add(licensorName) + } + } + + fun licensorPostalCode(licensorPostalCode: List) = + licensorPostalCode(JsonField.of(licensorPostalCode)) + + /** + * Sets [Builder.licensorPostalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorPostalCode] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorPostalCode(licensorPostalCode: JsonField>) = apply { + this.licensorPostalCode = licensorPostalCode.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorPostalCode]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorPostalCode(licensorPostalCode: String) = apply { + this.licensorPostalCode = + (this.licensorPostalCode ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorPostalCode", it).add(licensorPostalCode) + } + } + + fun licensorRegion(licensorRegion: List) = + licensorRegion(JsonField.of(licensorRegion)) + + /** + * Sets [Builder.licensorRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorRegion] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorRegion(licensorRegion: JsonField>) = apply { + this.licensorRegion = licensorRegion.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorRegion]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorRegion(licensorRegion: String) = apply { + this.licensorRegion = + (this.licensorRegion ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorRegion", it).add(licensorRegion) + } + } + + fun licensorStreetAddress(licensorStreetAddress: List) = + licensorStreetAddress(JsonField.of(licensorStreetAddress)) + + /** + * Sets [Builder.licensorStreetAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorStreetAddress] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun licensorStreetAddress(licensorStreetAddress: JsonField>) = apply { + this.licensorStreetAddress = licensorStreetAddress.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorStreetAddress]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorStreetAddress(licensorStreetAddress: String) = apply { + this.licensorStreetAddress = + (this.licensorStreetAddress ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorStreetAddress", it).add(licensorStreetAddress) + } + } + + fun licensorTelephone1(licensorTelephone1: List) = + licensorTelephone1(JsonField.of(licensorTelephone1)) + + /** + * Sets [Builder.licensorTelephone1] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorTelephone1] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorTelephone1(licensorTelephone1: JsonField>) = apply { + this.licensorTelephone1 = licensorTelephone1.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorTelephone1]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorTelephone1(licensorTelephone1: String) = apply { + this.licensorTelephone1 = + (this.licensorTelephone1 ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorTelephone1", it).add(licensorTelephone1) + } + } + + fun licensorTelephone2(licensorTelephone2: List) = + licensorTelephone2(JsonField.of(licensorTelephone2)) + + /** + * Sets [Builder.licensorTelephone2] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorTelephone2] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun licensorTelephone2(licensorTelephone2: JsonField>) = apply { + this.licensorTelephone2 = licensorTelephone2.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorTelephone2]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorTelephone2(licensorTelephone2: String) = apply { + this.licensorTelephone2 = + (this.licensorTelephone2 ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorTelephone2", it).add(licensorTelephone2) + } + } + + fun licensorUrl(licensorUrl: List) = licensorUrl(JsonField.of(licensorUrl)) + + /** + * Sets [Builder.licensorUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.licensorUrl] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun licensorUrl(licensorUrl: JsonField>) = apply { + this.licensorUrl = licensorUrl.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.licensorUrl]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLicensorUrl(licensorUrl: String) = apply { + this.licensorUrl = + (this.licensorUrl ?: JsonField.of(mutableListOf())).also { + checkKnown("licensorUrl", it).add(licensorUrl) + } + } + + fun linkedEncodedRightsExpr(linkedEncodedRightsExpr: String) = + linkedEncodedRightsExpr(JsonField.of(linkedEncodedRightsExpr)) + + /** + * Sets [Builder.linkedEncodedRightsExpr] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedEncodedRightsExpr] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun linkedEncodedRightsExpr(linkedEncodedRightsExpr: JsonField) = apply { + this.linkedEncodedRightsExpr = linkedEncodedRightsExpr + } + + fun linkedEncodedRightsExprLangId(linkedEncodedRightsExprLangId: String) = + linkedEncodedRightsExprLangId(JsonField.of(linkedEncodedRightsExprLangId)) + + /** + * Sets [Builder.linkedEncodedRightsExprLangId] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedEncodedRightsExprLangId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun linkedEncodedRightsExprLangId(linkedEncodedRightsExprLangId: JsonField) = + apply { + this.linkedEncodedRightsExprLangId = linkedEncodedRightsExprLangId + } + + fun linkedEncodedRightsExprType(linkedEncodedRightsExprType: String) = + linkedEncodedRightsExprType(JsonField.of(linkedEncodedRightsExprType)) + + /** + * Sets [Builder.linkedEncodedRightsExprType] to an arbitrary JSON value. + * + * You should usually call [Builder.linkedEncodedRightsExprType] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun linkedEncodedRightsExprType(linkedEncodedRightsExprType: JsonField) = + apply { + this.linkedEncodedRightsExprType = linkedEncodedRightsExprType + } + + fun location(location: String) = location(JsonField.of(location)) + + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun location(location: JsonField) = apply { this.location = location } + + fun locationCreatedCity(locationCreatedCity: String) = + locationCreatedCity(JsonField.of(locationCreatedCity)) + + /** + * Sets [Builder.locationCreatedCity] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedCity] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun locationCreatedCity(locationCreatedCity: JsonField) = apply { + this.locationCreatedCity = locationCreatedCity + } + + fun locationCreatedCountryCode(locationCreatedCountryCode: String) = + locationCreatedCountryCode(JsonField.of(locationCreatedCountryCode)) + + /** + * Sets [Builder.locationCreatedCountryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedCountryCode] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedCountryCode(locationCreatedCountryCode: JsonField) = apply { + this.locationCreatedCountryCode = locationCreatedCountryCode + } + + fun locationCreatedCountryName(locationCreatedCountryName: String) = + locationCreatedCountryName(JsonField.of(locationCreatedCountryName)) + + /** + * Sets [Builder.locationCreatedCountryName] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedCountryName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedCountryName(locationCreatedCountryName: JsonField) = apply { + this.locationCreatedCountryName = locationCreatedCountryName + } + + fun locationCreatedGpsAltitude(locationCreatedGpsAltitude: String) = + locationCreatedGpsAltitude(JsonField.of(locationCreatedGpsAltitude)) + + /** + * Sets [Builder.locationCreatedGpsAltitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedGpsAltitude] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedGpsAltitude(locationCreatedGpsAltitude: JsonField) = apply { + this.locationCreatedGpsAltitude = locationCreatedGpsAltitude + } + + fun locationCreatedGpsLatitude(locationCreatedGpsLatitude: String) = + locationCreatedGpsLatitude(JsonField.of(locationCreatedGpsLatitude)) + + /** + * Sets [Builder.locationCreatedGpsLatitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedGpsLatitude] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedGpsLatitude(locationCreatedGpsLatitude: JsonField) = apply { + this.locationCreatedGpsLatitude = locationCreatedGpsLatitude + } + + fun locationCreatedGpsLongitude(locationCreatedGpsLongitude: String) = + locationCreatedGpsLongitude(JsonField.of(locationCreatedGpsLongitude)) + + /** + * Sets [Builder.locationCreatedGpsLongitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedGpsLongitude] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedGpsLongitude(locationCreatedGpsLongitude: JsonField) = + apply { + this.locationCreatedGpsLongitude = locationCreatedGpsLongitude + } + + fun locationCreatedLocationId(locationCreatedLocationId: String) = + locationCreatedLocationId(JsonField.of(locationCreatedLocationId)) + + /** + * Sets [Builder.locationCreatedLocationId] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedLocationId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedLocationId(locationCreatedLocationId: JsonField) = apply { + this.locationCreatedLocationId = locationCreatedLocationId + } + + fun locationCreatedLocationName(locationCreatedLocationName: String) = + locationCreatedLocationName(JsonField.of(locationCreatedLocationName)) + + /** + * Sets [Builder.locationCreatedLocationName] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedLocationName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedLocationName(locationCreatedLocationName: JsonField) = + apply { + this.locationCreatedLocationName = locationCreatedLocationName + } + + fun locationCreatedProvinceState(locationCreatedProvinceState: String) = + locationCreatedProvinceState(JsonField.of(locationCreatedProvinceState)) + + /** + * Sets [Builder.locationCreatedProvinceState] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedProvinceState] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedProvinceState(locationCreatedProvinceState: JsonField) = + apply { + this.locationCreatedProvinceState = locationCreatedProvinceState + } + + fun locationCreatedSublocation(locationCreatedSublocation: String) = + locationCreatedSublocation(JsonField.of(locationCreatedSublocation)) + + /** + * Sets [Builder.locationCreatedSublocation] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedSublocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedSublocation(locationCreatedSublocation: JsonField) = apply { + this.locationCreatedSublocation = locationCreatedSublocation + } + + fun locationCreatedWorldRegion(locationCreatedWorldRegion: String) = + locationCreatedWorldRegion(JsonField.of(locationCreatedWorldRegion)) + + /** + * Sets [Builder.locationCreatedWorldRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.locationCreatedWorldRegion] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationCreatedWorldRegion(locationCreatedWorldRegion: JsonField) = apply { + this.locationCreatedWorldRegion = locationCreatedWorldRegion + } + + fun locationShownCity(locationShownCity: List) = + locationShownCity(JsonField.of(locationShownCity)) + + /** + * Sets [Builder.locationShownCity] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownCity] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun locationShownCity(locationShownCity: JsonField>) = apply { + this.locationShownCity = locationShownCity.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownCity]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownCity(locationShownCity: String) = apply { + this.locationShownCity = + (this.locationShownCity ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownCity", it).add(locationShownCity) + } + } + + fun locationShownCountryCode(locationShownCountryCode: List) = + locationShownCountryCode(JsonField.of(locationShownCountryCode)) + + /** + * Sets [Builder.locationShownCountryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownCountryCode] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownCountryCode(locationShownCountryCode: JsonField>) = + apply { + this.locationShownCountryCode = + locationShownCountryCode.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownCountryCode]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownCountryCode(locationShownCountryCode: String) = apply { + this.locationShownCountryCode = + (this.locationShownCountryCode ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownCountryCode", it).add(locationShownCountryCode) + } + } + + fun locationShownCountryName(locationShownCountryName: List) = + locationShownCountryName(JsonField.of(locationShownCountryName)) + + /** + * Sets [Builder.locationShownCountryName] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownCountryName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownCountryName(locationShownCountryName: JsonField>) = + apply { + this.locationShownCountryName = + locationShownCountryName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownCountryName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownCountryName(locationShownCountryName: String) = apply { + this.locationShownCountryName = + (this.locationShownCountryName ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownCountryName", it).add(locationShownCountryName) + } + } + + fun locationShownGpsAltitude(locationShownGpsAltitude: List) = + locationShownGpsAltitude(JsonField.of(locationShownGpsAltitude)) + + /** + * Sets [Builder.locationShownGpsAltitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownGpsAltitude] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownGpsAltitude(locationShownGpsAltitude: JsonField>) = + apply { + this.locationShownGpsAltitude = + locationShownGpsAltitude.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownGpsAltitude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownGpsAltitude(locationShownGpsAltitude: String) = apply { + this.locationShownGpsAltitude = + (this.locationShownGpsAltitude ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownGpsAltitude", it).add(locationShownGpsAltitude) + } + } + + fun locationShownGpsLatitude(locationShownGpsLatitude: List) = + locationShownGpsLatitude(JsonField.of(locationShownGpsLatitude)) + + /** + * Sets [Builder.locationShownGpsLatitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownGpsLatitude] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownGpsLatitude(locationShownGpsLatitude: JsonField>) = + apply { + this.locationShownGpsLatitude = + locationShownGpsLatitude.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownGpsLatitude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownGpsLatitude(locationShownGpsLatitude: String) = apply { + this.locationShownGpsLatitude = + (this.locationShownGpsLatitude ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownGpsLatitude", it).add(locationShownGpsLatitude) + } + } + + fun locationShownGpsLongitude(locationShownGpsLongitude: List) = + locationShownGpsLongitude(JsonField.of(locationShownGpsLongitude)) + + /** + * Sets [Builder.locationShownGpsLongitude] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownGpsLongitude] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownGpsLongitude(locationShownGpsLongitude: JsonField>) = + apply { + this.locationShownGpsLongitude = + locationShownGpsLongitude.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownGpsLongitude]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownGpsLongitude(locationShownGpsLongitude: String) = apply { + this.locationShownGpsLongitude = + (this.locationShownGpsLongitude ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownGpsLongitude", it).add(locationShownGpsLongitude) + } + } + + fun locationShownLocationId(locationShownLocationId: List) = + locationShownLocationId(JsonField.of(locationShownLocationId)) + + /** + * Sets [Builder.locationShownLocationId] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownLocationId] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownLocationId(locationShownLocationId: JsonField>) = apply { + this.locationShownLocationId = locationShownLocationId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownLocationId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownLocationId(locationShownLocationId: String) = apply { + this.locationShownLocationId = + (this.locationShownLocationId ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownLocationId", it).add(locationShownLocationId) + } + } + + fun locationShownLocationName(locationShownLocationName: List) = + locationShownLocationName(JsonField.of(locationShownLocationName)) + + /** + * Sets [Builder.locationShownLocationName] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownLocationName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownLocationName(locationShownLocationName: JsonField>) = + apply { + this.locationShownLocationName = + locationShownLocationName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownLocationName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownLocationName(locationShownLocationName: String) = apply { + this.locationShownLocationName = + (this.locationShownLocationName ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownLocationName", it).add(locationShownLocationName) + } + } + + fun locationShownProvinceState(locationShownProvinceState: List) = + locationShownProvinceState(JsonField.of(locationShownProvinceState)) + + /** + * Sets [Builder.locationShownProvinceState] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownProvinceState] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownProvinceState(locationShownProvinceState: JsonField>) = + apply { + this.locationShownProvinceState = + locationShownProvinceState.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownProvinceState]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownProvinceState(locationShownProvinceState: String) = apply { + this.locationShownProvinceState = + (this.locationShownProvinceState ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownProvinceState", it).add(locationShownProvinceState) + } + } + + fun locationShownSublocation(locationShownSublocation: List) = + locationShownSublocation(JsonField.of(locationShownSublocation)) + + /** + * Sets [Builder.locationShownSublocation] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownSublocation] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownSublocation(locationShownSublocation: JsonField>) = + apply { + this.locationShownSublocation = + locationShownSublocation.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownSublocation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownSublocation(locationShownSublocation: String) = apply { + this.locationShownSublocation = + (this.locationShownSublocation ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownSublocation", it).add(locationShownSublocation) + } + } + + fun locationShownWorldRegion(locationShownWorldRegion: List) = + locationShownWorldRegion(JsonField.of(locationShownWorldRegion)) + + /** + * Sets [Builder.locationShownWorldRegion] to an arbitrary JSON value. + * + * You should usually call [Builder.locationShownWorldRegion] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun locationShownWorldRegion(locationShownWorldRegion: JsonField>) = + apply { + this.locationShownWorldRegion = + locationShownWorldRegion.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.locationShownWorldRegion]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLocationShownWorldRegion(locationShownWorldRegion: String) = apply { + this.locationShownWorldRegion = + (this.locationShownWorldRegion ?: JsonField.of(mutableListOf())).also { + checkKnown("locationShownWorldRegion", it).add(locationShownWorldRegion) + } + } + + fun maxAvailHeight(maxAvailHeight: Double) = + maxAvailHeight(JsonField.of(maxAvailHeight)) + + /** + * Sets [Builder.maxAvailHeight] to an arbitrary JSON value. + * + * You should usually call [Builder.maxAvailHeight] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxAvailHeight(maxAvailHeight: JsonField) = apply { + this.maxAvailHeight = maxAvailHeight + } + + fun maxAvailWidth(maxAvailWidth: Double) = maxAvailWidth(JsonField.of(maxAvailWidth)) + + /** + * Sets [Builder.maxAvailWidth] to an arbitrary JSON value. + * + * You should usually call [Builder.maxAvailWidth] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxAvailWidth(maxAvailWidth: JsonField) = apply { + this.maxAvailWidth = maxAvailWidth + } + + fun modelAge(modelAge: List) = modelAge(JsonField.of(modelAge)) + + /** + * Sets [Builder.modelAge] to an arbitrary JSON value. + * + * You should usually call [Builder.modelAge] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun modelAge(modelAge: JsonField>) = apply { + this.modelAge = modelAge.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.modelAge]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addModelAge(modelAge: Double) = apply { + this.modelAge = + (this.modelAge ?: JsonField.of(mutableListOf())).also { + checkKnown("modelAge", it).add(modelAge) + } + } + + fun modelReleaseId(modelReleaseId: List) = + modelReleaseId(JsonField.of(modelReleaseId)) + + /** + * Sets [Builder.modelReleaseId] to an arbitrary JSON value. + * + * You should usually call [Builder.modelReleaseId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun modelReleaseId(modelReleaseId: JsonField>) = apply { + this.modelReleaseId = modelReleaseId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.modelReleaseId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addModelReleaseId(modelReleaseId: String) = apply { + this.modelReleaseId = + (this.modelReleaseId ?: JsonField.of(mutableListOf())).also { + checkKnown("modelReleaseId", it).add(modelReleaseId) + } + } + + fun objectAttributeReference(objectAttributeReference: String) = + objectAttributeReference(JsonField.of(objectAttributeReference)) + + /** + * Sets [Builder.objectAttributeReference] to an arbitrary JSON value. + * + * You should usually call [Builder.objectAttributeReference] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun objectAttributeReference(objectAttributeReference: JsonField) = apply { + this.objectAttributeReference = objectAttributeReference + } + + fun objectName(objectName: String) = objectName(JsonField.of(objectName)) + + /** + * Sets [Builder.objectName] to an arbitrary JSON value. + * + * You should usually call [Builder.objectName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun objectName(objectName: JsonField) = apply { this.objectName = objectName } + + fun offsetTimeOriginal(offsetTimeOriginal: String) = + offsetTimeOriginal(JsonField.of(offsetTimeOriginal)) + + /** + * Sets [Builder.offsetTimeOriginal] to an arbitrary JSON value. + * + * You should usually call [Builder.offsetTimeOriginal] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun offsetTimeOriginal(offsetTimeOriginal: JsonField) = apply { + this.offsetTimeOriginal = offsetTimeOriginal + } + + fun organisationInImageCode(organisationInImageCode: List) = + organisationInImageCode(JsonField.of(organisationInImageCode)) + + /** + * Sets [Builder.organisationInImageCode] to an arbitrary JSON value. + * + * You should usually call [Builder.organisationInImageCode] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun organisationInImageCode(organisationInImageCode: JsonField>) = apply { + this.organisationInImageCode = organisationInImageCode.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.organisationInImageCode]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOrganisationInImageCode(organisationInImageCode: String) = apply { + this.organisationInImageCode = + (this.organisationInImageCode ?: JsonField.of(mutableListOf())).also { + checkKnown("organisationInImageCode", it).add(organisationInImageCode) + } + } + + fun organisationInImageName(organisationInImageName: List) = + organisationInImageName(JsonField.of(organisationInImageName)) + + /** + * Sets [Builder.organisationInImageName] to an arbitrary JSON value. + * + * You should usually call [Builder.organisationInImageName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun organisationInImageName(organisationInImageName: JsonField>) = apply { + this.organisationInImageName = organisationInImageName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.organisationInImageName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOrganisationInImageName(organisationInImageName: String) = apply { + this.organisationInImageName = + (this.organisationInImageName ?: JsonField.of(mutableListOf())).also { + checkKnown("organisationInImageName", it).add(organisationInImageName) + } + } + + fun orientation(orientation: String) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [String] 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 originalTransmissionReference(originalTransmissionReference: String) = + originalTransmissionReference(JsonField.of(originalTransmissionReference)) + + /** + * Sets [Builder.originalTransmissionReference] to an arbitrary JSON value. + * + * You should usually call [Builder.originalTransmissionReference] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun originalTransmissionReference(originalTransmissionReference: JsonField) = + apply { + this.originalTransmissionReference = originalTransmissionReference + } + + fun personInImage(personInImage: List) = + personInImage(JsonField.of(personInImage)) + + /** + * Sets [Builder.personInImage] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImage] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun personInImage(personInImage: JsonField>) = apply { + this.personInImage = personInImage.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImage(personInImage: String) = apply { + this.personInImage = + (this.personInImage ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImage", it).add(personInImage) + } + } + + fun personInImageCvTermCvId(personInImageCvTermCvId: List) = + personInImageCvTermCvId(JsonField.of(personInImageCvTermCvId)) + + /** + * Sets [Builder.personInImageCvTermCvId] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageCvTermCvId] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageCvTermCvId(personInImageCvTermCvId: JsonField>) = apply { + this.personInImageCvTermCvId = personInImageCvTermCvId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageCvTermCvId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageCvTermCvId(personInImageCvTermCvId: String) = apply { + this.personInImageCvTermCvId = + (this.personInImageCvTermCvId ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageCvTermCvId", it).add(personInImageCvTermCvId) + } + } + + fun personInImageCvTermId(personInImageCvTermId: List) = + personInImageCvTermId(JsonField.of(personInImageCvTermId)) + + /** + * Sets [Builder.personInImageCvTermId] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageCvTermId] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageCvTermId(personInImageCvTermId: JsonField>) = apply { + this.personInImageCvTermId = personInImageCvTermId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageCvTermId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageCvTermId(personInImageCvTermId: String) = apply { + this.personInImageCvTermId = + (this.personInImageCvTermId ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageCvTermId", it).add(personInImageCvTermId) + } + } + + fun personInImageCvTermName(personInImageCvTermName: List) = + personInImageCvTermName(JsonField.of(personInImageCvTermName)) + + /** + * Sets [Builder.personInImageCvTermName] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageCvTermName] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageCvTermName(personInImageCvTermName: JsonField>) = apply { + this.personInImageCvTermName = personInImageCvTermName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageCvTermName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageCvTermName(personInImageCvTermName: String) = apply { + this.personInImageCvTermName = + (this.personInImageCvTermName ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageCvTermName", it).add(personInImageCvTermName) + } + } + + fun personInImageCvTermRefinedAbout(personInImageCvTermRefinedAbout: List) = + personInImageCvTermRefinedAbout(JsonField.of(personInImageCvTermRefinedAbout)) + + /** + * Sets [Builder.personInImageCvTermRefinedAbout] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageCvTermRefinedAbout] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageCvTermRefinedAbout( + personInImageCvTermRefinedAbout: JsonField> + ) = apply { + this.personInImageCvTermRefinedAbout = + personInImageCvTermRefinedAbout.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageCvTermRefinedAbout]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageCvTermRefinedAbout(personInImageCvTermRefinedAbout: String) = + apply { + this.personInImageCvTermRefinedAbout = + (this.personInImageCvTermRefinedAbout ?: JsonField.of(mutableListOf())) + .also { + checkKnown("personInImageCvTermRefinedAbout", it) + .add(personInImageCvTermRefinedAbout) + } + } + + fun personInImageDescription(personInImageDescription: List) = + personInImageDescription(JsonField.of(personInImageDescription)) + + /** + * Sets [Builder.personInImageDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageDescription] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun personInImageDescription(personInImageDescription: JsonField>) = + apply { + this.personInImageDescription = + personInImageDescription.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageDescription]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageDescription(personInImageDescription: String) = apply { + this.personInImageDescription = + (this.personInImageDescription ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageDescription", it).add(personInImageDescription) + } + } + + fun personInImageId(personInImageId: List) = + personInImageId(JsonField.of(personInImageId)) + + /** + * Sets [Builder.personInImageId] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun personInImageId(personInImageId: JsonField>) = apply { + this.personInImageId = personInImageId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageId(personInImageId: String) = apply { + this.personInImageId = + (this.personInImageId ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageId", it).add(personInImageId) + } + } + + fun personInImageName(personInImageName: List) = + personInImageName(JsonField.of(personInImageName)) + + /** + * Sets [Builder.personInImageName] to an arbitrary JSON value. + * + * You should usually call [Builder.personInImageName] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun personInImageName(personInImageName: JsonField>) = apply { + this.personInImageName = personInImageName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.personInImageName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPersonInImageName(personInImageName: String) = apply { + this.personInImageName = + (this.personInImageName ?: JsonField.of(mutableListOf())).also { + checkKnown("personInImageName", it).add(personInImageName) + } + } + + fun productInImageDescription(productInImageDescription: List) = + productInImageDescription(JsonField.of(productInImageDescription)) + + /** + * Sets [Builder.productInImageDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.productInImageDescription] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun productInImageDescription(productInImageDescription: JsonField>) = + apply { + this.productInImageDescription = + productInImageDescription.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.productInImageDescription]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProductInImageDescription(productInImageDescription: String) = apply { + this.productInImageDescription = + (this.productInImageDescription ?: JsonField.of(mutableListOf())).also { + checkKnown("productInImageDescription", it).add(productInImageDescription) + } + } + + fun productInImageGtin(productInImageGtin: List) = + productInImageGtin(JsonField.of(productInImageGtin)) + + /** + * Sets [Builder.productInImageGtin] to an arbitrary JSON value. + * + * You should usually call [Builder.productInImageGtin] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun productInImageGtin(productInImageGtin: JsonField>) = apply { + this.productInImageGtin = productInImageGtin.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [Builder.productInImageGtin]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProductInImageGtin(productInImageGtin: Double) = apply { + this.productInImageGtin = + (this.productInImageGtin ?: JsonField.of(mutableListOf())).also { + checkKnown("productInImageGtin", it).add(productInImageGtin) + } + } + + fun productInImageName(productInImageName: List) = + productInImageName(JsonField.of(productInImageName)) + + /** + * Sets [Builder.productInImageName] to an arbitrary JSON value. + * + * You should usually call [Builder.productInImageName] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun productInImageName(productInImageName: JsonField>) = apply { + this.productInImageName = productInImageName.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.productInImageName]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProductInImageName(productInImageName: String) = apply { + this.productInImageName = + (this.productInImageName ?: JsonField.of(mutableListOf())).also { + checkKnown("productInImageName", it).add(productInImageName) + } + } + + fun propertyReleaseId(propertyReleaseId: List) = + propertyReleaseId(JsonField.of(propertyReleaseId)) + + /** + * Sets [Builder.propertyReleaseId] to an arbitrary JSON value. + * + * You should usually call [Builder.propertyReleaseId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun propertyReleaseId(propertyReleaseId: JsonField>) = apply { + this.propertyReleaseId = propertyReleaseId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.propertyReleaseId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPropertyReleaseId(propertyReleaseId: String) = apply { + this.propertyReleaseId = + (this.propertyReleaseId ?: JsonField.of(mutableListOf())).also { + checkKnown("propertyReleaseId", it).add(propertyReleaseId) + } + } + + fun provinceState(provinceState: String) = provinceState(JsonField.of(provinceState)) + + /** + * Sets [Builder.provinceState] to an arbitrary JSON value. + * + * You should usually call [Builder.provinceState] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provinceState(provinceState: JsonField) = apply { + this.provinceState = provinceState + } + + fun rating(rating: Long) = rating(JsonField.of(rating)) + + /** + * Sets [Builder.rating] to an arbitrary JSON value. + * + * You should usually call [Builder.rating] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rating(rating: JsonField) = apply { this.rating = rating } + + fun registryEntryRole(registryEntryRole: List) = + registryEntryRole(JsonField.of(registryEntryRole)) + + /** + * Sets [Builder.registryEntryRole] to an arbitrary JSON value. + * + * You should usually call [Builder.registryEntryRole] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun registryEntryRole(registryEntryRole: JsonField>) = apply { + this.registryEntryRole = registryEntryRole.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.registryEntryRole]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegistryEntryRole(registryEntryRole: String) = apply { + this.registryEntryRole = + (this.registryEntryRole ?: JsonField.of(mutableListOf())).also { + checkKnown("registryEntryRole", it).add(registryEntryRole) + } + } + + fun registryItemId(registryItemId: List) = + registryItemId(JsonField.of(registryItemId)) + + /** + * Sets [Builder.registryItemId] to an arbitrary JSON value. + * + * You should usually call [Builder.registryItemId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun registryItemId(registryItemId: JsonField>) = apply { + this.registryItemId = registryItemId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.registryItemId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegistryItemId(registryItemId: String) = apply { + this.registryItemId = + (this.registryItemId ?: JsonField.of(mutableListOf())).also { + checkKnown("registryItemId", it).add(registryItemId) + } + } + + fun registryOrganisationId(registryOrganisationId: List) = + registryOrganisationId(JsonField.of(registryOrganisationId)) + + /** + * Sets [Builder.registryOrganisationId] to an arbitrary JSON value. + * + * You should usually call [Builder.registryOrganisationId] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun registryOrganisationId(registryOrganisationId: JsonField>) = apply { + this.registryOrganisationId = registryOrganisationId.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.registryOrganisationId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegistryOrganisationId(registryOrganisationId: String) = apply { + this.registryOrganisationId = + (this.registryOrganisationId ?: JsonField.of(mutableListOf())).also { + checkKnown("registryOrganisationId", it).add(registryOrganisationId) + } + } + + fun resolutionUnit(resolutionUnit: String) = + resolutionUnit(JsonField.of(resolutionUnit)) + + /** + * Sets [Builder.resolutionUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.resolutionUnit] with a well-typed [String] 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 rights(rights: String) = rights(JsonField.of(rights)) + + /** + * Sets [Builder.rights] to an arbitrary JSON value. + * + * You should usually call [Builder.rights] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rights(rights: JsonField) = apply { this.rights = rights } + + fun scene(scene: List) = scene(JsonField.of(scene)) + + /** + * Sets [Builder.scene] to an arbitrary JSON value. + * + * You should usually call [Builder.scene] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun scene(scene: JsonField>) = apply { + this.scene = scene.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.scene]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addScene(scene: String) = apply { + this.scene = + (this.scene ?: JsonField.of(mutableListOf())).also { + checkKnown("scene", it).add(scene) + } + } + + 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 specialInstructions(specialInstructions: String) = + specialInstructions(JsonField.of(specialInstructions)) + + /** + * Sets [Builder.specialInstructions] to an arbitrary JSON value. + * + * You should usually call [Builder.specialInstructions] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun specialInstructions(specialInstructions: JsonField) = apply { + this.specialInstructions = specialInstructions + } + + fun state(state: String) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + fun subject(subject: List) = subject(JsonField.of(subject)) + + /** + * Sets [Builder.subject] to an arbitrary JSON value. + * + * You should usually call [Builder.subject] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subject(subject: JsonField>) = apply { + this.subject = subject.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.subject]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubject(subject: String) = apply { + this.subject = + (this.subject ?: JsonField.of(mutableListOf())).also { + checkKnown("subject", it).add(subject) + } + } + + fun subjectCode(subjectCode: List) = subjectCode(JsonField.of(subjectCode)) + + /** + * Sets [Builder.subjectCode] to an arbitrary JSON value. + * + * You should usually call [Builder.subjectCode] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun subjectCode(subjectCode: JsonField>) = apply { + this.subjectCode = subjectCode.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.subjectCode]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubjectCode(subjectCode: String) = apply { + this.subjectCode = + (this.subjectCode ?: JsonField.of(mutableListOf())).also { + checkKnown("subjectCode", it).add(subjectCode) + } + } + + fun subjectReference(subjectReference: List) = + subjectReference(JsonField.of(subjectReference)) + + /** + * Sets [Builder.subjectReference] to an arbitrary JSON value. + * + * You should usually call [Builder.subjectReference] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun subjectReference(subjectReference: JsonField>) = apply { + this.subjectReference = subjectReference.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.subjectReference]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSubjectReference(subjectReference: String) = apply { + this.subjectReference = + (this.subjectReference ?: JsonField.of(mutableListOf())).also { + checkKnown("subjectReference", it).add(subjectReference) + } + } + + fun sublocation(sublocation: String) = sublocation(JsonField.of(sublocation)) + + /** + * Sets [Builder.sublocation] to an arbitrary JSON value. + * + * You should usually call [Builder.sublocation] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sublocation(sublocation: JsonField) = apply { + this.sublocation = sublocation + } + + fun timeCreated(timeCreated: String) = timeCreated(JsonField.of(timeCreated)) + + /** + * Sets [Builder.timeCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.timeCreated] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeCreated(timeCreated: JsonField) = apply { + this.timeCreated = timeCreated + } + + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun transmissionReference(transmissionReference: String) = + transmissionReference(JsonField.of(transmissionReference)) + + /** + * Sets [Builder.transmissionReference] to an arbitrary JSON value. + * + * You should usually call [Builder.transmissionReference] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun transmissionReference(transmissionReference: JsonField) = apply { + this.transmissionReference = transmissionReference + } + + fun usageTerms(usageTerms: String) = usageTerms(JsonField.of(usageTerms)) + + /** + * Sets [Builder.usageTerms] to an arbitrary JSON value. + * + * You should usually call [Builder.usageTerms] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun usageTerms(usageTerms: JsonField) = apply { this.usageTerms = usageTerms } + + fun webStatement(webStatement: String) = webStatement(JsonField.of(webStatement)) + + /** + * Sets [Builder.webStatement] to an arbitrary JSON value. + * + * You should usually call [Builder.webStatement] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webStatement(webStatement: JsonField) = apply { + this.webStatement = webStatement + } + + fun writer(writer: String) = writer(JsonField.of(writer)) + + /** + * Sets [Builder.writer] to an arbitrary JSON value. + * + * You should usually call [Builder.writer] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun writer(writer: JsonField) = apply { this.writer = writer } + + fun writerEditor(writerEditor: String) = writerEditor(JsonField.of(writerEditor)) + + /** + * Sets [Builder.writerEditor] to an arbitrary JSON value. + * + * You should usually call [Builder.writerEditor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun writerEditor(writerEditor: JsonField) = apply { + this.writerEditor = writerEditor + } + + fun xResolution(xResolution: Double) = xResolution(JsonField.of(xResolution)) + + /** + * Sets [Builder.xResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.xResolution] with a well-typed [Double] 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: Double) = yResolution(JsonField.of(yResolution)) + + /** + * Sets [Builder.yResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.yResolution] with a well-typed [Double] 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 [EmbeddedMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmbeddedMetadata = + EmbeddedMetadata( + aboutCvTermCvId, + aboutCvTermId, + aboutCvTermName, + aboutCvTermRefinedAbout, + additionalModelInformation, + applicationRecordVersion, + artist, + artworkCircaDateCreated, + artworkContentDescription, + artworkContributionDescription, + artworkCopyrightNotice, + artworkCopyrightOwnerId, + artworkCopyrightOwnerName, + (artworkCreator ?: JsonMissing.of()).map { it.toImmutable() }, + (artworkCreatorId ?: JsonMissing.of()).map { it.toImmutable() }, + artworkDateCreated, + artworkLicensorId, + artworkLicensorName, + artworkPhysicalDescription, + artworkSource, + artworkSourceInventoryNo, + artworkSourceInvUrl, + (artworkStylePeriod ?: JsonMissing.of()).map { it.toImmutable() }, + artworkTitle, + authorsPosition, + byline, + bylineTitle, + caption, + captionAbstract, + captionWriter, + city, + colorSpace, + componentsConfiguration, + copyright, + copyrightNotice, + (copyrightOwnerId ?: JsonMissing.of()).map { it.toImmutable() }, + (copyrightOwnerName ?: JsonMissing.of()).map { it.toImmutable() }, + country, + countryCode, + countryPrimaryLocationCode, + countryPrimaryLocationName, + creator, + creatorAddress, + creatorCity, + creatorCountry, + creatorPostalCode, + creatorRegion, + creatorWorkEmail, + creatorWorkTelephone, + creatorWorkUrl, + credit, + dateCreated, + dateTimeCreated, + dateTimeOriginal, + description, + digitalImageGuid, + digitalSourceType, + embeddedEncodedRightsExpr, + embeddedEncodedRightsExprLangId, + embeddedEncodedRightsExprType, + event, + exifVersion, + flashpixVersion, + genreCvId, + genreCvTermId, + genreCvTermName, + genreCvTermRefinedAbout, + headline, + imageCreatorId, + imageCreatorImageId, + imageCreatorName, + imageDescription, + (imageRegionBoundaryH ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryRx ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryShape ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryUnit ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryVerticesX ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryVerticesY ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryW ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryX ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionBoundaryY ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionCtypeIdentifier ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionCtypeName ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionId ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionName ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionOrganisationInImageName ?: JsonMissing.of()).map { + it.toImmutable() + }, + (imageRegionPersonInImage ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionRoleIdentifier ?: JsonMissing.of()).map { it.toImmutable() }, + (imageRegionRoleName ?: JsonMissing.of()).map { it.toImmutable() }, + imageSupplierId, + imageSupplierImageId, + imageSupplierName, + instructions, + intellectualGenre, + (keywords ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorCity ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorCountry ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorEmail ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorExtendedAddress ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorId ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorName ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorPostalCode ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorRegion ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorStreetAddress ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorTelephone1 ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorTelephone2 ?: JsonMissing.of()).map { it.toImmutable() }, + (licensorUrl ?: JsonMissing.of()).map { it.toImmutable() }, + linkedEncodedRightsExpr, + linkedEncodedRightsExprLangId, + linkedEncodedRightsExprType, + location, + locationCreatedCity, + locationCreatedCountryCode, + locationCreatedCountryName, + locationCreatedGpsAltitude, + locationCreatedGpsLatitude, + locationCreatedGpsLongitude, + locationCreatedLocationId, + locationCreatedLocationName, + locationCreatedProvinceState, + locationCreatedSublocation, + locationCreatedWorldRegion, + (locationShownCity ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownCountryCode ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownCountryName ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownGpsAltitude ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownGpsLatitude ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownGpsLongitude ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownLocationId ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownLocationName ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownProvinceState ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownSublocation ?: JsonMissing.of()).map { it.toImmutable() }, + (locationShownWorldRegion ?: JsonMissing.of()).map { it.toImmutable() }, + maxAvailHeight, + maxAvailWidth, + (modelAge ?: JsonMissing.of()).map { it.toImmutable() }, + (modelReleaseId ?: JsonMissing.of()).map { it.toImmutable() }, + objectAttributeReference, + objectName, + offsetTimeOriginal, + (organisationInImageCode ?: JsonMissing.of()).map { it.toImmutable() }, + (organisationInImageName ?: JsonMissing.of()).map { it.toImmutable() }, + orientation, + originalTransmissionReference, + (personInImage ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageCvTermCvId ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageCvTermId ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageCvTermName ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageCvTermRefinedAbout ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageDescription ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageId ?: JsonMissing.of()).map { it.toImmutable() }, + (personInImageName ?: JsonMissing.of()).map { it.toImmutable() }, + (productInImageDescription ?: JsonMissing.of()).map { it.toImmutable() }, + (productInImageGtin ?: JsonMissing.of()).map { it.toImmutable() }, + (productInImageName ?: JsonMissing.of()).map { it.toImmutable() }, + (propertyReleaseId ?: JsonMissing.of()).map { it.toImmutable() }, + provinceState, + rating, + (registryEntryRole ?: JsonMissing.of()).map { it.toImmutable() }, + (registryItemId ?: JsonMissing.of()).map { it.toImmutable() }, + (registryOrganisationId ?: JsonMissing.of()).map { it.toImmutable() }, + resolutionUnit, + rights, + (scene ?: JsonMissing.of()).map { it.toImmutable() }, + source, + specialInstructions, + state, + (subject ?: JsonMissing.of()).map { it.toImmutable() }, + (subjectCode ?: JsonMissing.of()).map { it.toImmutable() }, + (subjectReference ?: JsonMissing.of()).map { it.toImmutable() }, + sublocation, + timeCreated, + title, + transmissionReference, + usageTerms, + webStatement, + writer, + writerEditor, + xResolution, + yResolution, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EmbeddedMetadata = apply { + if (validated) { + return@apply + } + + aboutCvTermCvId() + aboutCvTermId() + aboutCvTermName() + aboutCvTermRefinedAbout() + additionalModelInformation() + applicationRecordVersion() + artist() + artworkCircaDateCreated() + artworkContentDescription() + artworkContributionDescription() + artworkCopyrightNotice() + artworkCopyrightOwnerId() + artworkCopyrightOwnerName() + artworkCreator() + artworkCreatorId() + artworkDateCreated() + artworkLicensorId() + artworkLicensorName() + artworkPhysicalDescription() + artworkSource() + artworkSourceInventoryNo() + artworkSourceInvUrl() + artworkStylePeriod() + artworkTitle() + authorsPosition() + byline() + bylineTitle() + caption() + captionAbstract() + captionWriter() + city() + colorSpace() + componentsConfiguration() + copyright() + copyrightNotice() + copyrightOwnerId() + copyrightOwnerName() + country() + countryCode() + countryPrimaryLocationCode() + countryPrimaryLocationName() + creator() + creatorAddress() + creatorCity() + creatorCountry() + creatorPostalCode() + creatorRegion() + creatorWorkEmail() + creatorWorkTelephone() + creatorWorkUrl() + credit() + dateCreated() + dateTimeCreated() + dateTimeOriginal() + description() + digitalImageGuid() + digitalSourceType() + embeddedEncodedRightsExpr() + embeddedEncodedRightsExprLangId() + embeddedEncodedRightsExprType() + event() + exifVersion() + flashpixVersion() + genreCvId() + genreCvTermId() + genreCvTermName() + genreCvTermRefinedAbout() + headline() + imageCreatorId() + imageCreatorImageId() + imageCreatorName() + imageDescription() + imageRegionBoundaryH() + imageRegionBoundaryRx() + imageRegionBoundaryShape() + imageRegionBoundaryUnit() + imageRegionBoundaryVerticesX() + imageRegionBoundaryVerticesY() + imageRegionBoundaryW() + imageRegionBoundaryX() + imageRegionBoundaryY() + imageRegionCtypeIdentifier() + imageRegionCtypeName() + imageRegionId() + imageRegionName() + imageRegionOrganisationInImageName() + imageRegionPersonInImage() + imageRegionRoleIdentifier() + imageRegionRoleName() + imageSupplierId() + imageSupplierImageId() + imageSupplierName() + instructions() + intellectualGenre() + keywords() + licensorCity() + licensorCountry() + licensorEmail() + licensorExtendedAddress() + licensorId() + licensorName() + licensorPostalCode() + licensorRegion() + licensorStreetAddress() + licensorTelephone1() + licensorTelephone2() + licensorUrl() + linkedEncodedRightsExpr() + linkedEncodedRightsExprLangId() + linkedEncodedRightsExprType() + location() + locationCreatedCity() + locationCreatedCountryCode() + locationCreatedCountryName() + locationCreatedGpsAltitude() + locationCreatedGpsLatitude() + locationCreatedGpsLongitude() + locationCreatedLocationId() + locationCreatedLocationName() + locationCreatedProvinceState() + locationCreatedSublocation() + locationCreatedWorldRegion() + locationShownCity() + locationShownCountryCode() + locationShownCountryName() + locationShownGpsAltitude() + locationShownGpsLatitude() + locationShownGpsLongitude() + locationShownLocationId() + locationShownLocationName() + locationShownProvinceState() + locationShownSublocation() + locationShownWorldRegion() + maxAvailHeight() + maxAvailWidth() + modelAge() + modelReleaseId() + objectAttributeReference() + objectName() + offsetTimeOriginal() + organisationInImageCode() + organisationInImageName() + orientation() + originalTransmissionReference() + personInImage() + personInImageCvTermCvId() + personInImageCvTermId() + personInImageCvTermName() + personInImageCvTermRefinedAbout() + personInImageDescription() + personInImageId() + personInImageName() + productInImageDescription() + productInImageGtin() + productInImageName() + propertyReleaseId() + provinceState() + rating() + registryEntryRole() + registryItemId() + registryOrganisationId() + resolutionUnit() + rights() + scene() + source() + specialInstructions() + state() + subject() + subjectCode() + subjectReference() + sublocation() + timeCreated() + title() + transmissionReference() + usageTerms() + webStatement() + writer() + writerEditor() + 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 (aboutCvTermCvId.asKnown().isPresent) 1 else 0) + + (if (aboutCvTermId.asKnown().isPresent) 1 else 0) + + (if (aboutCvTermName.asKnown().isPresent) 1 else 0) + + (if (aboutCvTermRefinedAbout.asKnown().isPresent) 1 else 0) + + (if (additionalModelInformation.asKnown().isPresent) 1 else 0) + + (if (applicationRecordVersion.asKnown().isPresent) 1 else 0) + + (if (artist.asKnown().isPresent) 1 else 0) + + (if (artworkCircaDateCreated.asKnown().isPresent) 1 else 0) + + (if (artworkContentDescription.asKnown().isPresent) 1 else 0) + + (if (artworkContributionDescription.asKnown().isPresent) 1 else 0) + + (if (artworkCopyrightNotice.asKnown().isPresent) 1 else 0) + + (if (artworkCopyrightOwnerId.asKnown().isPresent) 1 else 0) + + (if (artworkCopyrightOwnerName.asKnown().isPresent) 1 else 0) + + (artworkCreator.asKnown().getOrNull()?.size ?: 0) + + (artworkCreatorId.asKnown().getOrNull()?.size ?: 0) + + (if (artworkDateCreated.asKnown().isPresent) 1 else 0) + + (if (artworkLicensorId.asKnown().isPresent) 1 else 0) + + (if (artworkLicensorName.asKnown().isPresent) 1 else 0) + + (if (artworkPhysicalDescription.asKnown().isPresent) 1 else 0) + + (if (artworkSource.asKnown().isPresent) 1 else 0) + + (if (artworkSourceInventoryNo.asKnown().isPresent) 1 else 0) + + (if (artworkSourceInvUrl.asKnown().isPresent) 1 else 0) + + (artworkStylePeriod.asKnown().getOrNull()?.size ?: 0) + + (if (artworkTitle.asKnown().isPresent) 1 else 0) + + (if (authorsPosition.asKnown().isPresent) 1 else 0) + + (if (byline.asKnown().isPresent) 1 else 0) + + (if (bylineTitle.asKnown().isPresent) 1 else 0) + + (if (caption.asKnown().isPresent) 1 else 0) + + (if (captionAbstract.asKnown().isPresent) 1 else 0) + + (if (captionWriter.asKnown().isPresent) 1 else 0) + + (if (city.asKnown().isPresent) 1 else 0) + + (if (colorSpace.asKnown().isPresent) 1 else 0) + + (if (componentsConfiguration.asKnown().isPresent) 1 else 0) + + (if (copyright.asKnown().isPresent) 1 else 0) + + (if (copyrightNotice.asKnown().isPresent) 1 else 0) + + (copyrightOwnerId.asKnown().getOrNull()?.size ?: 0) + + (copyrightOwnerName.asKnown().getOrNull()?.size ?: 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (countryCode.asKnown().isPresent) 1 else 0) + + (if (countryPrimaryLocationCode.asKnown().isPresent) 1 else 0) + + (if (countryPrimaryLocationName.asKnown().isPresent) 1 else 0) + + (if (creator.asKnown().isPresent) 1 else 0) + + (if (creatorAddress.asKnown().isPresent) 1 else 0) + + (if (creatorCity.asKnown().isPresent) 1 else 0) + + (if (creatorCountry.asKnown().isPresent) 1 else 0) + + (if (creatorPostalCode.asKnown().isPresent) 1 else 0) + + (if (creatorRegion.asKnown().isPresent) 1 else 0) + + (if (creatorWorkEmail.asKnown().isPresent) 1 else 0) + + (if (creatorWorkTelephone.asKnown().isPresent) 1 else 0) + + (if (creatorWorkUrl.asKnown().isPresent) 1 else 0) + + (if (credit.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateTimeCreated.asKnown().isPresent) 1 else 0) + + (if (dateTimeOriginal.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (digitalImageGuid.asKnown().isPresent) 1 else 0) + + (if (digitalSourceType.asKnown().isPresent) 1 else 0) + + (if (embeddedEncodedRightsExpr.asKnown().isPresent) 1 else 0) + + (if (embeddedEncodedRightsExprLangId.asKnown().isPresent) 1 else 0) + + (if (embeddedEncodedRightsExprType.asKnown().isPresent) 1 else 0) + + (if (event.asKnown().isPresent) 1 else 0) + + (if (exifVersion.asKnown().isPresent) 1 else 0) + + (if (flashpixVersion.asKnown().isPresent) 1 else 0) + + (if (genreCvId.asKnown().isPresent) 1 else 0) + + (if (genreCvTermId.asKnown().isPresent) 1 else 0) + + (if (genreCvTermName.asKnown().isPresent) 1 else 0) + + (if (genreCvTermRefinedAbout.asKnown().isPresent) 1 else 0) + + (if (headline.asKnown().isPresent) 1 else 0) + + (if (imageCreatorId.asKnown().isPresent) 1 else 0) + + (if (imageCreatorImageId.asKnown().isPresent) 1 else 0) + + (if (imageCreatorName.asKnown().isPresent) 1 else 0) + + (if (imageDescription.asKnown().isPresent) 1 else 0) + + (imageRegionBoundaryH.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryRx.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryShape.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryUnit.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryVerticesX.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryVerticesY.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryW.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryX.asKnown().getOrNull()?.size ?: 0) + + (imageRegionBoundaryY.asKnown().getOrNull()?.size ?: 0) + + (imageRegionCtypeIdentifier.asKnown().getOrNull()?.size ?: 0) + + (imageRegionCtypeName.asKnown().getOrNull()?.size ?: 0) + + (imageRegionId.asKnown().getOrNull()?.size ?: 0) + + (imageRegionName.asKnown().getOrNull()?.size ?: 0) + + (imageRegionOrganisationInImageName.asKnown().getOrNull()?.size ?: 0) + + (imageRegionPersonInImage.asKnown().getOrNull()?.size ?: 0) + + (imageRegionRoleIdentifier.asKnown().getOrNull()?.size ?: 0) + + (imageRegionRoleName.asKnown().getOrNull()?.size ?: 0) + + (if (imageSupplierId.asKnown().isPresent) 1 else 0) + + (if (imageSupplierImageId.asKnown().isPresent) 1 else 0) + + (if (imageSupplierName.asKnown().isPresent) 1 else 0) + + (if (instructions.asKnown().isPresent) 1 else 0) + + (if (intellectualGenre.asKnown().isPresent) 1 else 0) + + (keywords.asKnown().getOrNull()?.size ?: 0) + + (licensorCity.asKnown().getOrNull()?.size ?: 0) + + (licensorCountry.asKnown().getOrNull()?.size ?: 0) + + (licensorEmail.asKnown().getOrNull()?.size ?: 0) + + (licensorExtendedAddress.asKnown().getOrNull()?.size ?: 0) + + (licensorId.asKnown().getOrNull()?.size ?: 0) + + (licensorName.asKnown().getOrNull()?.size ?: 0) + + (licensorPostalCode.asKnown().getOrNull()?.size ?: 0) + + (licensorRegion.asKnown().getOrNull()?.size ?: 0) + + (licensorStreetAddress.asKnown().getOrNull()?.size ?: 0) + + (licensorTelephone1.asKnown().getOrNull()?.size ?: 0) + + (licensorTelephone2.asKnown().getOrNull()?.size ?: 0) + + (licensorUrl.asKnown().getOrNull()?.size ?: 0) + + (if (linkedEncodedRightsExpr.asKnown().isPresent) 1 else 0) + + (if (linkedEncodedRightsExprLangId.asKnown().isPresent) 1 else 0) + + (if (linkedEncodedRightsExprType.asKnown().isPresent) 1 else 0) + + (if (location.asKnown().isPresent) 1 else 0) + + (if (locationCreatedCity.asKnown().isPresent) 1 else 0) + + (if (locationCreatedCountryCode.asKnown().isPresent) 1 else 0) + + (if (locationCreatedCountryName.asKnown().isPresent) 1 else 0) + + (if (locationCreatedGpsAltitude.asKnown().isPresent) 1 else 0) + + (if (locationCreatedGpsLatitude.asKnown().isPresent) 1 else 0) + + (if (locationCreatedGpsLongitude.asKnown().isPresent) 1 else 0) + + (if (locationCreatedLocationId.asKnown().isPresent) 1 else 0) + + (if (locationCreatedLocationName.asKnown().isPresent) 1 else 0) + + (if (locationCreatedProvinceState.asKnown().isPresent) 1 else 0) + + (if (locationCreatedSublocation.asKnown().isPresent) 1 else 0) + + (if (locationCreatedWorldRegion.asKnown().isPresent) 1 else 0) + + (locationShownCity.asKnown().getOrNull()?.size ?: 0) + + (locationShownCountryCode.asKnown().getOrNull()?.size ?: 0) + + (locationShownCountryName.asKnown().getOrNull()?.size ?: 0) + + (locationShownGpsAltitude.asKnown().getOrNull()?.size ?: 0) + + (locationShownGpsLatitude.asKnown().getOrNull()?.size ?: 0) + + (locationShownGpsLongitude.asKnown().getOrNull()?.size ?: 0) + + (locationShownLocationId.asKnown().getOrNull()?.size ?: 0) + + (locationShownLocationName.asKnown().getOrNull()?.size ?: 0) + + (locationShownProvinceState.asKnown().getOrNull()?.size ?: 0) + + (locationShownSublocation.asKnown().getOrNull()?.size ?: 0) + + (locationShownWorldRegion.asKnown().getOrNull()?.size ?: 0) + + (if (maxAvailHeight.asKnown().isPresent) 1 else 0) + + (if (maxAvailWidth.asKnown().isPresent) 1 else 0) + + (modelAge.asKnown().getOrNull()?.size ?: 0) + + (modelReleaseId.asKnown().getOrNull()?.size ?: 0) + + (if (objectAttributeReference.asKnown().isPresent) 1 else 0) + + (if (objectName.asKnown().isPresent) 1 else 0) + + (if (offsetTimeOriginal.asKnown().isPresent) 1 else 0) + + (organisationInImageCode.asKnown().getOrNull()?.size ?: 0) + + (organisationInImageName.asKnown().getOrNull()?.size ?: 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (if (originalTransmissionReference.asKnown().isPresent) 1 else 0) + + (personInImage.asKnown().getOrNull()?.size ?: 0) + + (personInImageCvTermCvId.asKnown().getOrNull()?.size ?: 0) + + (personInImageCvTermId.asKnown().getOrNull()?.size ?: 0) + + (personInImageCvTermName.asKnown().getOrNull()?.size ?: 0) + + (personInImageCvTermRefinedAbout.asKnown().getOrNull()?.size ?: 0) + + (personInImageDescription.asKnown().getOrNull()?.size ?: 0) + + (personInImageId.asKnown().getOrNull()?.size ?: 0) + + (personInImageName.asKnown().getOrNull()?.size ?: 0) + + (productInImageDescription.asKnown().getOrNull()?.size ?: 0) + + (productInImageGtin.asKnown().getOrNull()?.size ?: 0) + + (productInImageName.asKnown().getOrNull()?.size ?: 0) + + (propertyReleaseId.asKnown().getOrNull()?.size ?: 0) + + (if (provinceState.asKnown().isPresent) 1 else 0) + + (if (rating.asKnown().isPresent) 1 else 0) + + (registryEntryRole.asKnown().getOrNull()?.size ?: 0) + + (registryItemId.asKnown().getOrNull()?.size ?: 0) + + (registryOrganisationId.asKnown().getOrNull()?.size ?: 0) + + (if (resolutionUnit.asKnown().isPresent) 1 else 0) + + (if (rights.asKnown().isPresent) 1 else 0) + + (scene.asKnown().getOrNull()?.size ?: 0) + + (if (source.asKnown().isPresent) 1 else 0) + + (if (specialInstructions.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + (subject.asKnown().getOrNull()?.size ?: 0) + + (subjectCode.asKnown().getOrNull()?.size ?: 0) + + (subjectReference.asKnown().getOrNull()?.size ?: 0) + + (if (sublocation.asKnown().isPresent) 1 else 0) + + (if (timeCreated.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (if (transmissionReference.asKnown().isPresent) 1 else 0) + + (if (usageTerms.asKnown().isPresent) 1 else 0) + + (if (webStatement.asKnown().isPresent) 1 else 0) + + (if (writer.asKnown().isPresent) 1 else 0) + + (if (writerEditor.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 EmbeddedMetadata && + aboutCvTermCvId == other.aboutCvTermCvId && + aboutCvTermId == other.aboutCvTermId && + aboutCvTermName == other.aboutCvTermName && + aboutCvTermRefinedAbout == other.aboutCvTermRefinedAbout && + additionalModelInformation == other.additionalModelInformation && + applicationRecordVersion == other.applicationRecordVersion && + artist == other.artist && + artworkCircaDateCreated == other.artworkCircaDateCreated && + artworkContentDescription == other.artworkContentDescription && + artworkContributionDescription == other.artworkContributionDescription && + artworkCopyrightNotice == other.artworkCopyrightNotice && + artworkCopyrightOwnerId == other.artworkCopyrightOwnerId && + artworkCopyrightOwnerName == other.artworkCopyrightOwnerName && + artworkCreator == other.artworkCreator && + artworkCreatorId == other.artworkCreatorId && + artworkDateCreated == other.artworkDateCreated && + artworkLicensorId == other.artworkLicensorId && + artworkLicensorName == other.artworkLicensorName && + artworkPhysicalDescription == other.artworkPhysicalDescription && + artworkSource == other.artworkSource && + artworkSourceInventoryNo == other.artworkSourceInventoryNo && + artworkSourceInvUrl == other.artworkSourceInvUrl && + artworkStylePeriod == other.artworkStylePeriod && + artworkTitle == other.artworkTitle && + authorsPosition == other.authorsPosition && + byline == other.byline && + bylineTitle == other.bylineTitle && + caption == other.caption && + captionAbstract == other.captionAbstract && + captionWriter == other.captionWriter && + city == other.city && + colorSpace == other.colorSpace && + componentsConfiguration == other.componentsConfiguration && + copyright == other.copyright && + copyrightNotice == other.copyrightNotice && + copyrightOwnerId == other.copyrightOwnerId && + copyrightOwnerName == other.copyrightOwnerName && + country == other.country && + countryCode == other.countryCode && + countryPrimaryLocationCode == other.countryPrimaryLocationCode && + countryPrimaryLocationName == other.countryPrimaryLocationName && + creator == other.creator && + creatorAddress == other.creatorAddress && + creatorCity == other.creatorCity && + creatorCountry == other.creatorCountry && + creatorPostalCode == other.creatorPostalCode && + creatorRegion == other.creatorRegion && + creatorWorkEmail == other.creatorWorkEmail && + creatorWorkTelephone == other.creatorWorkTelephone && + creatorWorkUrl == other.creatorWorkUrl && + credit == other.credit && + dateCreated == other.dateCreated && + dateTimeCreated == other.dateTimeCreated && + dateTimeOriginal == other.dateTimeOriginal && + description == other.description && + digitalImageGuid == other.digitalImageGuid && + digitalSourceType == other.digitalSourceType && + embeddedEncodedRightsExpr == other.embeddedEncodedRightsExpr && + embeddedEncodedRightsExprLangId == other.embeddedEncodedRightsExprLangId && + embeddedEncodedRightsExprType == other.embeddedEncodedRightsExprType && + event == other.event && + exifVersion == other.exifVersion && + flashpixVersion == other.flashpixVersion && + genreCvId == other.genreCvId && + genreCvTermId == other.genreCvTermId && + genreCvTermName == other.genreCvTermName && + genreCvTermRefinedAbout == other.genreCvTermRefinedAbout && + headline == other.headline && + imageCreatorId == other.imageCreatorId && + imageCreatorImageId == other.imageCreatorImageId && + imageCreatorName == other.imageCreatorName && + imageDescription == other.imageDescription && + imageRegionBoundaryH == other.imageRegionBoundaryH && + imageRegionBoundaryRx == other.imageRegionBoundaryRx && + imageRegionBoundaryShape == other.imageRegionBoundaryShape && + imageRegionBoundaryUnit == other.imageRegionBoundaryUnit && + imageRegionBoundaryVerticesX == other.imageRegionBoundaryVerticesX && + imageRegionBoundaryVerticesY == other.imageRegionBoundaryVerticesY && + imageRegionBoundaryW == other.imageRegionBoundaryW && + imageRegionBoundaryX == other.imageRegionBoundaryX && + imageRegionBoundaryY == other.imageRegionBoundaryY && + imageRegionCtypeIdentifier == other.imageRegionCtypeIdentifier && + imageRegionCtypeName == other.imageRegionCtypeName && + imageRegionId == other.imageRegionId && + imageRegionName == other.imageRegionName && + imageRegionOrganisationInImageName == other.imageRegionOrganisationInImageName && + imageRegionPersonInImage == other.imageRegionPersonInImage && + imageRegionRoleIdentifier == other.imageRegionRoleIdentifier && + imageRegionRoleName == other.imageRegionRoleName && + imageSupplierId == other.imageSupplierId && + imageSupplierImageId == other.imageSupplierImageId && + imageSupplierName == other.imageSupplierName && + instructions == other.instructions && + intellectualGenre == other.intellectualGenre && + keywords == other.keywords && + licensorCity == other.licensorCity && + licensorCountry == other.licensorCountry && + licensorEmail == other.licensorEmail && + licensorExtendedAddress == other.licensorExtendedAddress && + licensorId == other.licensorId && + licensorName == other.licensorName && + licensorPostalCode == other.licensorPostalCode && + licensorRegion == other.licensorRegion && + licensorStreetAddress == other.licensorStreetAddress && + licensorTelephone1 == other.licensorTelephone1 && + licensorTelephone2 == other.licensorTelephone2 && + licensorUrl == other.licensorUrl && + linkedEncodedRightsExpr == other.linkedEncodedRightsExpr && + linkedEncodedRightsExprLangId == other.linkedEncodedRightsExprLangId && + linkedEncodedRightsExprType == other.linkedEncodedRightsExprType && + location == other.location && + locationCreatedCity == other.locationCreatedCity && + locationCreatedCountryCode == other.locationCreatedCountryCode && + locationCreatedCountryName == other.locationCreatedCountryName && + locationCreatedGpsAltitude == other.locationCreatedGpsAltitude && + locationCreatedGpsLatitude == other.locationCreatedGpsLatitude && + locationCreatedGpsLongitude == other.locationCreatedGpsLongitude && + locationCreatedLocationId == other.locationCreatedLocationId && + locationCreatedLocationName == other.locationCreatedLocationName && + locationCreatedProvinceState == other.locationCreatedProvinceState && + locationCreatedSublocation == other.locationCreatedSublocation && + locationCreatedWorldRegion == other.locationCreatedWorldRegion && + locationShownCity == other.locationShownCity && + locationShownCountryCode == other.locationShownCountryCode && + locationShownCountryName == other.locationShownCountryName && + locationShownGpsAltitude == other.locationShownGpsAltitude && + locationShownGpsLatitude == other.locationShownGpsLatitude && + locationShownGpsLongitude == other.locationShownGpsLongitude && + locationShownLocationId == other.locationShownLocationId && + locationShownLocationName == other.locationShownLocationName && + locationShownProvinceState == other.locationShownProvinceState && + locationShownSublocation == other.locationShownSublocation && + locationShownWorldRegion == other.locationShownWorldRegion && + maxAvailHeight == other.maxAvailHeight && + maxAvailWidth == other.maxAvailWidth && + modelAge == other.modelAge && + modelReleaseId == other.modelReleaseId && + objectAttributeReference == other.objectAttributeReference && + objectName == other.objectName && + offsetTimeOriginal == other.offsetTimeOriginal && + organisationInImageCode == other.organisationInImageCode && + organisationInImageName == other.organisationInImageName && + orientation == other.orientation && + originalTransmissionReference == other.originalTransmissionReference && + personInImage == other.personInImage && + personInImageCvTermCvId == other.personInImageCvTermCvId && + personInImageCvTermId == other.personInImageCvTermId && + personInImageCvTermName == other.personInImageCvTermName && + personInImageCvTermRefinedAbout == other.personInImageCvTermRefinedAbout && + personInImageDescription == other.personInImageDescription && + personInImageId == other.personInImageId && + personInImageName == other.personInImageName && + productInImageDescription == other.productInImageDescription && + productInImageGtin == other.productInImageGtin && + productInImageName == other.productInImageName && + propertyReleaseId == other.propertyReleaseId && + provinceState == other.provinceState && + rating == other.rating && + registryEntryRole == other.registryEntryRole && + registryItemId == other.registryItemId && + registryOrganisationId == other.registryOrganisationId && + resolutionUnit == other.resolutionUnit && + rights == other.rights && + scene == other.scene && + source == other.source && + specialInstructions == other.specialInstructions && + state == other.state && + subject == other.subject && + subjectCode == other.subjectCode && + subjectReference == other.subjectReference && + sublocation == other.sublocation && + timeCreated == other.timeCreated && + title == other.title && + transmissionReference == other.transmissionReference && + usageTerms == other.usageTerms && + webStatement == other.webStatement && + writer == other.writer && + writerEditor == other.writerEditor && + xResolution == other.xResolution && + yResolution == other.yResolution && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aboutCvTermCvId, + aboutCvTermId, + aboutCvTermName, + aboutCvTermRefinedAbout, + additionalModelInformation, + applicationRecordVersion, + artist, + artworkCircaDateCreated, + artworkContentDescription, + artworkContributionDescription, + artworkCopyrightNotice, + artworkCopyrightOwnerId, + artworkCopyrightOwnerName, + artworkCreator, + artworkCreatorId, + artworkDateCreated, + artworkLicensorId, + artworkLicensorName, + artworkPhysicalDescription, + artworkSource, + artworkSourceInventoryNo, + artworkSourceInvUrl, + artworkStylePeriod, + artworkTitle, + authorsPosition, + byline, + bylineTitle, + caption, + captionAbstract, + captionWriter, + city, + colorSpace, + componentsConfiguration, + copyright, + copyrightNotice, + copyrightOwnerId, + copyrightOwnerName, + country, + countryCode, + countryPrimaryLocationCode, + countryPrimaryLocationName, + creator, + creatorAddress, + creatorCity, + creatorCountry, + creatorPostalCode, + creatorRegion, + creatorWorkEmail, + creatorWorkTelephone, + creatorWorkUrl, + credit, + dateCreated, + dateTimeCreated, + dateTimeOriginal, + description, + digitalImageGuid, + digitalSourceType, + embeddedEncodedRightsExpr, + embeddedEncodedRightsExprLangId, + embeddedEncodedRightsExprType, + event, + exifVersion, + flashpixVersion, + genreCvId, + genreCvTermId, + genreCvTermName, + genreCvTermRefinedAbout, + headline, + imageCreatorId, + imageCreatorImageId, + imageCreatorName, + imageDescription, + imageRegionBoundaryH, + imageRegionBoundaryRx, + imageRegionBoundaryShape, + imageRegionBoundaryUnit, + imageRegionBoundaryVerticesX, + imageRegionBoundaryVerticesY, + imageRegionBoundaryW, + imageRegionBoundaryX, + imageRegionBoundaryY, + imageRegionCtypeIdentifier, + imageRegionCtypeName, + imageRegionId, + imageRegionName, + imageRegionOrganisationInImageName, + imageRegionPersonInImage, + imageRegionRoleIdentifier, + imageRegionRoleName, + imageSupplierId, + imageSupplierImageId, + imageSupplierName, + instructions, + intellectualGenre, + keywords, + licensorCity, + licensorCountry, + licensorEmail, + licensorExtendedAddress, + licensorId, + licensorName, + licensorPostalCode, + licensorRegion, + licensorStreetAddress, + licensorTelephone1, + licensorTelephone2, + licensorUrl, + linkedEncodedRightsExpr, + linkedEncodedRightsExprLangId, + linkedEncodedRightsExprType, + location, + locationCreatedCity, + locationCreatedCountryCode, + locationCreatedCountryName, + locationCreatedGpsAltitude, + locationCreatedGpsLatitude, + locationCreatedGpsLongitude, + locationCreatedLocationId, + locationCreatedLocationName, + locationCreatedProvinceState, + locationCreatedSublocation, + locationCreatedWorldRegion, + locationShownCity, + locationShownCountryCode, + locationShownCountryName, + locationShownGpsAltitude, + locationShownGpsLatitude, + locationShownGpsLongitude, + locationShownLocationId, + locationShownLocationName, + locationShownProvinceState, + locationShownSublocation, + locationShownWorldRegion, + maxAvailHeight, + maxAvailWidth, + modelAge, + modelReleaseId, + objectAttributeReference, + objectName, + offsetTimeOriginal, + organisationInImageCode, + organisationInImageName, + orientation, + originalTransmissionReference, + personInImage, + personInImageCvTermCvId, + personInImageCvTermId, + personInImageCvTermName, + personInImageCvTermRefinedAbout, + personInImageDescription, + personInImageId, + personInImageName, + productInImageDescription, + productInImageGtin, + productInImageName, + propertyReleaseId, + provinceState, + rating, + registryEntryRole, + registryItemId, + registryOrganisationId, + resolutionUnit, + rights, + scene, + source, + specialInstructions, + state, + subject, + subjectCode, + subjectReference, + sublocation, + timeCreated, + title, + transmissionReference, + usageTerms, + webStatement, + writer, + writerEditor, + xResolution, + yResolution, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmbeddedMetadata{aboutCvTermCvId=$aboutCvTermCvId, aboutCvTermId=$aboutCvTermId, aboutCvTermName=$aboutCvTermName, aboutCvTermRefinedAbout=$aboutCvTermRefinedAbout, additionalModelInformation=$additionalModelInformation, applicationRecordVersion=$applicationRecordVersion, artist=$artist, artworkCircaDateCreated=$artworkCircaDateCreated, artworkContentDescription=$artworkContentDescription, artworkContributionDescription=$artworkContributionDescription, artworkCopyrightNotice=$artworkCopyrightNotice, artworkCopyrightOwnerId=$artworkCopyrightOwnerId, artworkCopyrightOwnerName=$artworkCopyrightOwnerName, artworkCreator=$artworkCreator, artworkCreatorId=$artworkCreatorId, artworkDateCreated=$artworkDateCreated, artworkLicensorId=$artworkLicensorId, artworkLicensorName=$artworkLicensorName, artworkPhysicalDescription=$artworkPhysicalDescription, artworkSource=$artworkSource, artworkSourceInventoryNo=$artworkSourceInventoryNo, artworkSourceInvUrl=$artworkSourceInvUrl, artworkStylePeriod=$artworkStylePeriod, artworkTitle=$artworkTitle, authorsPosition=$authorsPosition, byline=$byline, bylineTitle=$bylineTitle, caption=$caption, captionAbstract=$captionAbstract, captionWriter=$captionWriter, city=$city, colorSpace=$colorSpace, componentsConfiguration=$componentsConfiguration, copyright=$copyright, copyrightNotice=$copyrightNotice, copyrightOwnerId=$copyrightOwnerId, copyrightOwnerName=$copyrightOwnerName, country=$country, countryCode=$countryCode, countryPrimaryLocationCode=$countryPrimaryLocationCode, countryPrimaryLocationName=$countryPrimaryLocationName, creator=$creator, creatorAddress=$creatorAddress, creatorCity=$creatorCity, creatorCountry=$creatorCountry, creatorPostalCode=$creatorPostalCode, creatorRegion=$creatorRegion, creatorWorkEmail=$creatorWorkEmail, creatorWorkTelephone=$creatorWorkTelephone, creatorWorkUrl=$creatorWorkUrl, credit=$credit, dateCreated=$dateCreated, dateTimeCreated=$dateTimeCreated, dateTimeOriginal=$dateTimeOriginal, description=$description, digitalImageGuid=$digitalImageGuid, digitalSourceType=$digitalSourceType, embeddedEncodedRightsExpr=$embeddedEncodedRightsExpr, embeddedEncodedRightsExprLangId=$embeddedEncodedRightsExprLangId, embeddedEncodedRightsExprType=$embeddedEncodedRightsExprType, event=$event, exifVersion=$exifVersion, flashpixVersion=$flashpixVersion, genreCvId=$genreCvId, genreCvTermId=$genreCvTermId, genreCvTermName=$genreCvTermName, genreCvTermRefinedAbout=$genreCvTermRefinedAbout, headline=$headline, imageCreatorId=$imageCreatorId, imageCreatorImageId=$imageCreatorImageId, imageCreatorName=$imageCreatorName, imageDescription=$imageDescription, imageRegionBoundaryH=$imageRegionBoundaryH, imageRegionBoundaryRx=$imageRegionBoundaryRx, imageRegionBoundaryShape=$imageRegionBoundaryShape, imageRegionBoundaryUnit=$imageRegionBoundaryUnit, imageRegionBoundaryVerticesX=$imageRegionBoundaryVerticesX, imageRegionBoundaryVerticesY=$imageRegionBoundaryVerticesY, imageRegionBoundaryW=$imageRegionBoundaryW, imageRegionBoundaryX=$imageRegionBoundaryX, imageRegionBoundaryY=$imageRegionBoundaryY, imageRegionCtypeIdentifier=$imageRegionCtypeIdentifier, imageRegionCtypeName=$imageRegionCtypeName, imageRegionId=$imageRegionId, imageRegionName=$imageRegionName, imageRegionOrganisationInImageName=$imageRegionOrganisationInImageName, imageRegionPersonInImage=$imageRegionPersonInImage, imageRegionRoleIdentifier=$imageRegionRoleIdentifier, imageRegionRoleName=$imageRegionRoleName, imageSupplierId=$imageSupplierId, imageSupplierImageId=$imageSupplierImageId, imageSupplierName=$imageSupplierName, instructions=$instructions, intellectualGenre=$intellectualGenre, keywords=$keywords, licensorCity=$licensorCity, licensorCountry=$licensorCountry, licensorEmail=$licensorEmail, licensorExtendedAddress=$licensorExtendedAddress, licensorId=$licensorId, licensorName=$licensorName, licensorPostalCode=$licensorPostalCode, licensorRegion=$licensorRegion, licensorStreetAddress=$licensorStreetAddress, licensorTelephone1=$licensorTelephone1, licensorTelephone2=$licensorTelephone2, licensorUrl=$licensorUrl, linkedEncodedRightsExpr=$linkedEncodedRightsExpr, linkedEncodedRightsExprLangId=$linkedEncodedRightsExprLangId, linkedEncodedRightsExprType=$linkedEncodedRightsExprType, location=$location, locationCreatedCity=$locationCreatedCity, locationCreatedCountryCode=$locationCreatedCountryCode, locationCreatedCountryName=$locationCreatedCountryName, locationCreatedGpsAltitude=$locationCreatedGpsAltitude, locationCreatedGpsLatitude=$locationCreatedGpsLatitude, locationCreatedGpsLongitude=$locationCreatedGpsLongitude, locationCreatedLocationId=$locationCreatedLocationId, locationCreatedLocationName=$locationCreatedLocationName, locationCreatedProvinceState=$locationCreatedProvinceState, locationCreatedSublocation=$locationCreatedSublocation, locationCreatedWorldRegion=$locationCreatedWorldRegion, locationShownCity=$locationShownCity, locationShownCountryCode=$locationShownCountryCode, locationShownCountryName=$locationShownCountryName, locationShownGpsAltitude=$locationShownGpsAltitude, locationShownGpsLatitude=$locationShownGpsLatitude, locationShownGpsLongitude=$locationShownGpsLongitude, locationShownLocationId=$locationShownLocationId, locationShownLocationName=$locationShownLocationName, locationShownProvinceState=$locationShownProvinceState, locationShownSublocation=$locationShownSublocation, locationShownWorldRegion=$locationShownWorldRegion, maxAvailHeight=$maxAvailHeight, maxAvailWidth=$maxAvailWidth, modelAge=$modelAge, modelReleaseId=$modelReleaseId, objectAttributeReference=$objectAttributeReference, objectName=$objectName, offsetTimeOriginal=$offsetTimeOriginal, organisationInImageCode=$organisationInImageCode, organisationInImageName=$organisationInImageName, orientation=$orientation, originalTransmissionReference=$originalTransmissionReference, personInImage=$personInImage, personInImageCvTermCvId=$personInImageCvTermCvId, personInImageCvTermId=$personInImageCvTermId, personInImageCvTermName=$personInImageCvTermName, personInImageCvTermRefinedAbout=$personInImageCvTermRefinedAbout, personInImageDescription=$personInImageDescription, personInImageId=$personInImageId, personInImageName=$personInImageName, productInImageDescription=$productInImageDescription, productInImageGtin=$productInImageGtin, productInImageName=$productInImageName, propertyReleaseId=$propertyReleaseId, provinceState=$provinceState, rating=$rating, registryEntryRole=$registryEntryRole, registryItemId=$registryItemId, registryOrganisationId=$registryOrganisationId, resolutionUnit=$resolutionUnit, rights=$rights, scene=$scene, source=$source, specialInstructions=$specialInstructions, state=$state, subject=$subject, subjectCode=$subjectCode, subjectReference=$subjectReference, sublocation=$sublocation, timeCreated=$timeCreated, title=$title, transmissionReference=$transmissionReference, usageTerms=$usageTerms, webStatement=$webStatement, writer=$writer, writerEditor=$writerEditor, xResolution=$xResolution, yResolution=$yResolution, 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 awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @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(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 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 [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 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 { + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + 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( + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + 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 = + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + 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 && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the + * upload API response. + */ + 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: ExifDetails) = exif(JsonField.of(exif)) + + /** + * Sets [Builder.exif] to an arbitrary JSON value. + * + * 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 } + + /** 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: ExifImage) = image(JsonField.of(image)) + + /** + * Sets [Builder.image] to an arbitrary JSON value. + * + * You should usually call [Builder.image] with a well-typed [ExifImage] 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) + + 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}" + } + + 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}" + } + + /** 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 FileUploadV2Response && + aiTags == other.aiTags && + audioCodec == other.audioCodec && + bitRate == other.bitRate && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + 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() = + "FileUploadV2Response{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/Gps.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Gps.kt new file mode 100644 index 00000000..462174ea --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Gps.kt @@ -0,0 +1,178 @@ +// 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 + +/** 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}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Interoperability.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Interoperability.kt new file mode 100644 index 00000000..8f0420c5 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Interoperability.kt @@ -0,0 +1,201 @@ +// 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 + +/** 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}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Thumbnail.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Thumbnail.kt new file mode 100644 index 00000000..cd375b63 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Thumbnail.kt @@ -0,0 +1,359 @@ +// 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 + +/** 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}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParams.kt new file mode 100644 index 00000000..0c89f9e1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParams.kt @@ -0,0 +1,451 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.batch + +import 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 BatchDeleteParams +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 [BatchDeleteParams]. + * + * The following fields are required: + * ```java + * .fileIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchDeleteParams]. */ + 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(batchDeleteParams: BatchDeleteParams) = apply { + body = batchDeleteParams.body.toBuilder() + additionalHeaders = batchDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = batchDeleteParams.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 [BatchDeleteParams]. + * + * 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(): BatchDeleteParams = + BatchDeleteParams( + 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 BatchDeleteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BatchDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponse.kt new file mode 100644 index 00000000..6cf1084c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponse.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.batch + +import 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 BatchDeleteResponse +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 [BatchDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchDeleteResponse]. */ + class Builder internal constructor() { + + private var successfullyDeletedFileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(batchDeleteResponse: BatchDeleteResponse) = apply { + successfullyDeletedFileIds = + batchDeleteResponse.successfullyDeletedFileIds.map { it.toMutableList() } + additionalProperties = batchDeleteResponse.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 [BatchDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BatchDeleteResponse = + BatchDeleteResponse( + (successfullyDeletedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BatchDeleteResponse = 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 BatchDeleteResponse && + successfullyDeletedFileIds == other.successfullyDeletedFileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(successfullyDeletedFileIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchDeleteResponse{successfullyDeletedFileIds=$successfullyDeletedFileIds, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParams.kt new file mode 100644 index 00000000..e95066a3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.details + +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 DetailRetrieveParams +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(): DetailRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DetailRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DetailRetrieveParams]. */ + 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(detailRetrieveParams: DetailRetrieveParams) = apply { + fileId = detailRetrieveParams.fileId + additionalHeaders = detailRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = detailRetrieveParams.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 [DetailRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DetailRetrieveParams = + DetailRetrieveParams(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 DetailRetrieveParams && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(fileId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DetailRetrieveParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponse.kt new file mode 100644 index 00000000..78ed3f2e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponse.kt @@ -0,0 +1,1353 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.details + +import 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 + +/** Object containing details of a file or file version. */ +class DetailRetrieveResponse +private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + 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: JsonValue = 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, + 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. */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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 [DetailRetrieveResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DetailRetrieveResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonValue = 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(detailRetrieveResponse: DetailRetrieveResponse) = apply { + aiTags = detailRetrieveResponse.aiTags.map { it.toMutableList() } + createdAt = detailRetrieveResponse.createdAt + customCoordinates = detailRetrieveResponse.customCoordinates + customMetadata = detailRetrieveResponse.customMetadata + fileId = detailRetrieveResponse.fileId + filePath = detailRetrieveResponse.filePath + fileType = detailRetrieveResponse.fileType + hasAlpha = detailRetrieveResponse.hasAlpha + height = detailRetrieveResponse.height + isPrivateFile = detailRetrieveResponse.isPrivateFile + isPublished = detailRetrieveResponse.isPublished + mime = detailRetrieveResponse.mime + name = detailRetrieveResponse.name + size = detailRetrieveResponse.size + tags = detailRetrieveResponse.tags.map { it.toMutableList() } + thumbnail = detailRetrieveResponse.thumbnail + type = detailRetrieveResponse.type + updatedAt = detailRetrieveResponse.updatedAt + url = detailRetrieveResponse.url + versionInfo = detailRetrieveResponse.versionInfo + width = detailRetrieveResponse.width + additionalProperties = detailRetrieveResponse.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: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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: 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 } + + /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [DetailRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DetailRetrieveResponse = + DetailRetrieveResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + 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(): DetailRetrieveResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type() + 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) + + (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) + + (if (type.asKnown().isPresent) 1 else 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 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 DetailRetrieveResponse && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + 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() = + "DetailRetrieveResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/details/DetailUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateParams.kt new file mode 100644 index 00000000..240f2ebd --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateParams.kt @@ -0,0 +1,2818 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.details + +import 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 DetailUpdateParams +private constructor( + private val fileId: String?, + private val body: Body?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun fileId(): Optional = Optional.ofNullable(fileId) + + fun body(): Optional = Optional.ofNullable(body) + + /** 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(): DetailUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DetailUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DetailUpdateParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var body: Body? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(detailUpdateParams: DetailUpdateParams) = apply { + fileId = detailUpdateParams.fileId + body = detailUpdateParams.body + additionalHeaders = detailUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = detailUpdateParams.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 body(body: Body?) = apply { this.body = body } + + /** Alias for calling [Builder.body] with `body.orElse(null)`. */ + fun body(body: Optional) = body(body.getOrNull()) + + /** Alias for calling [body] with `Body.ofUpdateFileDetails(updateFileDetails)`. */ + fun body(updateFileDetails: Body.UpdateFileDetails) = + body(Body.ofUpdateFileDetails(updateFileDetails)) + + /** + * Alias for calling [body] with `Body.ofChangePublicationStatus(changePublicationStatus)`. + */ + fun body(changePublicationStatus: Body.ChangePublicationStatus) = + body(Body.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 [DetailUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DetailUpdateParams = + DetailUpdateParams( + fileId, + body, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Optional = Optional.ofNullable(body) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + 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: JsonValue, + 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: JsonValue = 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, + 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. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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: JsonValue = 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 + 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** + * 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.ofRemovedotBg(removedotBg)`. */ + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = + addExtension(Extension.ofRemovedotBg(removedotBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** + * 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.ofUnionMember1(unionMember1)`. + */ + fun removeAiTags(unionMember1: RemoveAiTags.UnionMember1) = + removeAiTags(RemoveAiTags.ofUnionMember1(unionMember1)) + + /** + * 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, + (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() + 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) + + (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) + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removedotBg: RemovedotBgExtension? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val _json: JsonValue? = null, + ) { + + fun removedotBg(): Optional = Optional.ofNullable(removedotBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun isRemovedotBg(): Boolean = removedotBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun asRemovedotBg(): RemovedotBgExtension = removedotBg.getOrThrow("removedotBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removedotBg != null -> visitor.visitRemovedotBg(removedotBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) { + removedotBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.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 visitRemovedotBg(removedotBg: RemovedotBgExtension) = + removedotBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removedotBg == other.removedotBg && + autoTagging == other.autoTagging + } + + override fun hashCode(): Int = Objects.hash(removedotBg, autoTagging) + + override fun toString(): String = + when { + removedotBg != null -> "Extension{removedotBg=$removedotBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic + fun ofRemovedotBg(removedotBg: RemovedotBgExtension) = + Extension(removedotBg = removedotBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of + * type [T]. + */ + interface Visitor { + + fun visitRemovedotBg(removedotBg: RemovedotBgExtension): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(removedotBg = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(autoTagging = 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 -> Extension(_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(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removedotBg != null -> generator.writeObject(value.removedotBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } + + class RemovedotBgExtension + private constructor( + private val name: JsonField, + private val options: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + + /** + * Specifies the background removal 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(): Name = name.getRequired("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 [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 [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 + * [RemovedotBgExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovedotBgExtension]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { + name = removedotBgExtension.name + options = removedotBgExtension.options + additionalProperties = + removedotBgExtension.additionalProperties.toMutableMap() + } + + /** Specifies the background removal extension. */ + 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 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 [RemovedotBgExtension]. + * + * 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(): RemovedotBgExtension = + RemovedotBgExtension( + checkRequired("name", name), + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovedotBgExtension = apply { + if (validated) { + return@apply + } + + name().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 = + (name.asKnown().getOrNull()?.validity() ?: 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the background removal extension. */ + 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 REMOVE_BG = of("remove-bg") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + REMOVE_BG + } + + /** + * 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 { + REMOVE_BG, + /** + * 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) { + REMOVE_BG -> Value.REMOVE_BG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + REMOVE_BG -> Known.REMOVE_BG + 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() + } + + 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 RemovedotBgExtension && + 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() = + "RemovedotBgExtension{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 unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isStrings(): Boolean = strings != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asStrings(): List = strings.getOrThrow("strings") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + strings != null -> visitor.visitStrings(strings) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + 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 visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.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 visitStrings(strings: List) = strings.size + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAiTags && + strings == other.strings && + unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(strings, unionMember1) + + override fun toString(): String = + when { + strings != null -> "RemoveAiTags{strings=$strings}" + unionMember1 != null -> "RemoveAiTags{unionMember1=$unionMember1}" + _json != null -> "RemoveAiTags{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RemoveAiTags") + } + + companion object { + + @JvmStatic + fun ofStrings(strings: List) = + RemoveAiTags(strings = strings.toImmutable()) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + RemoveAiTags(unionMember1 = unionMember1) + } + + /** + * 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 visitUnionMember1(unionMember1: UnionMember1): 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(unionMember1 = it, _json = json) + }, + 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.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RemoveAiTags") + } + } + } + + class UnionMember1 + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API 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") + + @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + } + + /** An enum containing [UnionMember1]'s known values. */ + enum class Known { + ALL + } + + /** + * An enum containing [UnionMember1]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [UnionMember1] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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, + /** + * An enum member indicating that [UnionMember1] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + else -> + throw ImageKitInvalidDataException("Unknown UnionMember1: $value") + } + + /** + * Returns this class 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(): UnionMember1 = 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 UnionMember1 && 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 UpdateFileDetails && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + extensions, + removeAiTags, + tags, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateFileDetails{customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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 DetailUpdateParams && + fileId == other.fileId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(fileId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DetailUpdateParams{fileId=$fileId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponse.kt new file mode 100644 index 00000000..9c18cc9e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponse.kt @@ -0,0 +1,2037 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.details + +import 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 + +class DetailUpdateResponse +private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + private val extensionStatus: 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: JsonValue = 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("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, + extensionStatus, + 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. */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * @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 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 [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 [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 [DetailUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DetailUpdateResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonValue = 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 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(detailUpdateResponse: DetailUpdateResponse) = apply { + aiTags = detailUpdateResponse.aiTags.map { it.toMutableList() } + createdAt = detailUpdateResponse.createdAt + customCoordinates = detailUpdateResponse.customCoordinates + customMetadata = detailUpdateResponse.customMetadata + extensionStatus = detailUpdateResponse.extensionStatus + fileId = detailUpdateResponse.fileId + filePath = detailUpdateResponse.filePath + fileType = detailUpdateResponse.fileType + hasAlpha = detailUpdateResponse.hasAlpha + height = detailUpdateResponse.height + isPrivateFile = detailUpdateResponse.isPrivateFile + isPublished = detailUpdateResponse.isPublished + mime = detailUpdateResponse.mime + name = detailUpdateResponse.name + size = detailUpdateResponse.size + tags = detailUpdateResponse.tags.map { it.toMutableList() } + thumbnail = detailUpdateResponse.thumbnail + type = detailUpdateResponse.type + updatedAt = detailUpdateResponse.updatedAt + url = detailUpdateResponse.url + versionInfo = detailUpdateResponse.versionInfo + width = detailUpdateResponse.width + additionalProperties = detailUpdateResponse.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: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + 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 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: 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 } + + /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [DetailUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DetailUpdateResponse = + DetailUpdateResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + extensionStatus, + 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(): DetailUpdateResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + extensionStatus().ifPresent { it.validate() } + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type() + 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) + + (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 (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) + + (if (type.asKnown().isPresent) 1 else 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}" + } + + class ExtensionStatus + private constructor( + private val awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @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(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 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 [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 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 { + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + 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( + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + 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 = + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + 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 && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + /** 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 DetailUpdateResponse && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + extensionStatus == other.extensionStatus && + 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, + extensionStatus, + 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() = + "DetailUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, extensionStatus=$extensionStatus, 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/metadata/MetadataFromUrlParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParams.kt new file mode 100644 index 00000000..64019c0f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParams.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 MetadataFromUrlParams +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 [MetadataFromUrlParams]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetadataFromUrlParams]. */ + 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(metadataFromUrlParams: MetadataFromUrlParams) = apply { + url = metadataFromUrlParams.url + additionalHeaders = metadataFromUrlParams.additionalHeaders.toBuilder() + additionalQueryParams = metadataFromUrlParams.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 [MetadataFromUrlParams]. + * + * 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(): MetadataFromUrlParams = + MetadataFromUrlParams( + 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 MetadataFromUrlParams && + url == other.url && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(url, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MetadataFromUrlParams{url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponse.kt new file mode 100644 index 00000000..e6b758de --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponse.kt @@ -0,0 +1,1110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +import 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.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.ExifDetails +import com.imagekit.api.models.files.ExifImage +import com.imagekit.api.models.files.Gps +import com.imagekit.api.models.files.Interoperability +import com.imagekit.api.models.files.Thumbnail +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** JSON object containing metadata. */ +class MetadataFromUrlResponse +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 [MetadataFromUrlResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetadataFromUrlResponse]. */ + 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(metadataFromUrlResponse: MetadataFromUrlResponse) = apply { + audioCodec = metadataFromUrlResponse.audioCodec + bitRate = metadataFromUrlResponse.bitRate + density = metadataFromUrlResponse.density + duration = metadataFromUrlResponse.duration + exif = metadataFromUrlResponse.exif + format = metadataFromUrlResponse.format + hasColorProfile = metadataFromUrlResponse.hasColorProfile + hasTransparency = metadataFromUrlResponse.hasTransparency + height = metadataFromUrlResponse.height + pHash = metadataFromUrlResponse.pHash + quality = metadataFromUrlResponse.quality + size = metadataFromUrlResponse.size + videoCodec = metadataFromUrlResponse.videoCodec + width = metadataFromUrlResponse.width + additionalProperties = metadataFromUrlResponse.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 [MetadataFromUrlResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetadataFromUrlResponse = + MetadataFromUrlResponse( + audioCodec, + bitRate, + density, + duration, + exif, + format, + hasColorProfile, + hasTransparency, + height, + pHash, + quality, + size, + videoCodec, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MetadataFromUrlResponse = 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: ExifDetails) = exif(JsonField.of(exif)) + + /** + * Sets [Builder.exif] to an arbitrary JSON value. + * + * 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 } + + /** 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: ExifImage) = image(JsonField.of(image)) + + /** + * Sets [Builder.image] to an arbitrary JSON value. + * + * You should usually call [Builder.image] with a well-typed [ExifImage] 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) + + 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}" + } + + 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 MetadataFromUrlResponse && + 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() = + "MetadataFromUrlResponse{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/metadata/MetadataRetrieveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParams.kt new file mode 100644 index 00000000..1fa9cdcc --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParams.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 MetadataRetrieveParams +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(): MetadataRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MetadataRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetadataRetrieveParams]. */ + 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(metadataRetrieveParams: MetadataRetrieveParams) = apply { + fileId = metadataRetrieveParams.fileId + additionalHeaders = metadataRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = metadataRetrieveParams.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 [MetadataRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetadataRetrieveParams = + MetadataRetrieveParams(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 MetadataRetrieveParams && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(fileId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MetadataRetrieveParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponse.kt new file mode 100644 index 00000000..9f565b16 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponse.kt @@ -0,0 +1,1110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +import 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.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.ExifDetails +import com.imagekit.api.models.files.ExifImage +import com.imagekit.api.models.files.Gps +import com.imagekit.api.models.files.Interoperability +import com.imagekit.api.models.files.Thumbnail +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** JSON object containing metadata. */ +class MetadataRetrieveResponse +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 [MetadataRetrieveResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetadataRetrieveResponse]. */ + 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(metadataRetrieveResponse: MetadataRetrieveResponse) = apply { + audioCodec = metadataRetrieveResponse.audioCodec + bitRate = metadataRetrieveResponse.bitRate + density = metadataRetrieveResponse.density + duration = metadataRetrieveResponse.duration + exif = metadataRetrieveResponse.exif + format = metadataRetrieveResponse.format + hasColorProfile = metadataRetrieveResponse.hasColorProfile + hasTransparency = metadataRetrieveResponse.hasTransparency + height = metadataRetrieveResponse.height + pHash = metadataRetrieveResponse.pHash + quality = metadataRetrieveResponse.quality + size = metadataRetrieveResponse.size + videoCodec = metadataRetrieveResponse.videoCodec + width = metadataRetrieveResponse.width + additionalProperties = metadataRetrieveResponse.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 [MetadataRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetadataRetrieveResponse = + MetadataRetrieveResponse( + audioCodec, + bitRate, + density, + duration, + exif, + format, + hasColorProfile, + hasTransparency, + height, + pHash, + quality, + size, + videoCodec, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MetadataRetrieveResponse = 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: ExifDetails) = exif(JsonField.of(exif)) + + /** + * Sets [Builder.exif] to an arbitrary JSON value. + * + * 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 } + + /** 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: ExifImage) = image(JsonField.of(image)) + + /** + * Sets [Builder.image] to an arbitrary JSON value. + * + * You should usually call [Builder.image] with a well-typed [ExifImage] 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) + + 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}" + } + + 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 MetadataRetrieveResponse && + 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() = + "MetadataRetrieveResponse{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/purge/PurgeExecuteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParams.kt new file mode 100644 index 00000000..afca8f49 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParams.kt @@ -0,0 +1,415 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.purge + +import 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 PurgeExecuteParams +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 [PurgeExecuteParams]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PurgeExecuteParams]. */ + 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(purgeExecuteParams: PurgeExecuteParams) = apply { + body = purgeExecuteParams.body.toBuilder() + additionalHeaders = purgeExecuteParams.additionalHeaders.toBuilder() + additionalQueryParams = purgeExecuteParams.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 [PurgeExecuteParams]. + * + * 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(): PurgeExecuteParams = + PurgeExecuteParams( + 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 PurgeExecuteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PurgeExecuteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponse.kt new file mode 100644 index 00000000..e38f0dc4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponse.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.purge + +import 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 PurgeExecuteResponse +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 [PurgeExecuteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PurgeExecuteResponse]. */ + class Builder internal constructor() { + + private var requestId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(purgeExecuteResponse: PurgeExecuteResponse) = apply { + requestId = purgeExecuteResponse.requestId + additionalProperties = purgeExecuteResponse.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 [PurgeExecuteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PurgeExecuteResponse = + PurgeExecuteResponse(requestId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PurgeExecuteResponse = 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 PurgeExecuteResponse && + requestId == other.requestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(requestId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PurgeExecuteResponse{requestId=$requestId, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParams.kt new file mode 100644 index 00000000..16dc7bf7 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.purge + +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 PurgeStatusParams +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(): PurgeStatusParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PurgeStatusParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PurgeStatusParams]. */ + 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(purgeStatusParams: PurgeStatusParams) = apply { + requestId = purgeStatusParams.requestId + additionalHeaders = purgeStatusParams.additionalHeaders.toBuilder() + additionalQueryParams = purgeStatusParams.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 [PurgeStatusParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PurgeStatusParams = + PurgeStatusParams(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 PurgeStatusParams && + requestId == other.requestId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(requestId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PurgeStatusParams{requestId=$requestId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponse.kt new file mode 100644 index 00000000..515e3f10 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponse.kt @@ -0,0 +1,285 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.purge + +import 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 PurgeStatusResponse +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 [PurgeStatusResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PurgeStatusResponse]. */ + class Builder internal constructor() { + + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(purgeStatusResponse: PurgeStatusResponse) = apply { + status = purgeStatusResponse.status + additionalProperties = purgeStatusResponse.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 [PurgeStatusResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PurgeStatusResponse = + PurgeStatusResponse(status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PurgeStatusResponse = 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 PurgeStatusResponse && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PurgeStatusResponse{status=$status, additionalProperties=$additionalProperties}" +} 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/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/VersionListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt new file mode 100644 index 00000000..9b231d38 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt @@ -0,0 +1,1353 @@ +// 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.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 + +/** Object containing details of a file or file version. */ +class VersionListResponse +private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + 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: JsonValue = 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, + 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. */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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 [VersionListResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionListResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonValue = 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(versionListResponse: VersionListResponse) = apply { + aiTags = versionListResponse.aiTags.map { it.toMutableList() } + createdAt = versionListResponse.createdAt + customCoordinates = versionListResponse.customCoordinates + customMetadata = versionListResponse.customMetadata + fileId = versionListResponse.fileId + filePath = versionListResponse.filePath + fileType = versionListResponse.fileType + hasAlpha = versionListResponse.hasAlpha + height = versionListResponse.height + isPrivateFile = versionListResponse.isPrivateFile + isPublished = versionListResponse.isPublished + mime = versionListResponse.mime + name = versionListResponse.name + size = versionListResponse.size + tags = versionListResponse.tags.map { it.toMutableList() } + thumbnail = versionListResponse.thumbnail + type = versionListResponse.type + updatedAt = versionListResponse.updatedAt + url = versionListResponse.url + versionInfo = versionListResponse.versionInfo + width = versionListResponse.width + additionalProperties = versionListResponse.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: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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: 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 } + + /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [VersionListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionListResponse = + VersionListResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + 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(): VersionListResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type() + 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) + + (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) + + (if (type.asKnown().isPresent) 1 else 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 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 VersionListResponse && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + 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() = + "VersionListResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/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/files/versions/VersionRestoreResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt new file mode 100644 index 00000000..56355d25 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt @@ -0,0 +1,1353 @@ +// 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.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 + +/** Object containing details of a file or file version. */ +class VersionRestoreResponse +private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + 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: JsonValue = 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, + 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. */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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 [VersionRestoreResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionRestoreResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonValue = 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(versionRestoreResponse: VersionRestoreResponse) = apply { + aiTags = versionRestoreResponse.aiTags.map { it.toMutableList() } + createdAt = versionRestoreResponse.createdAt + customCoordinates = versionRestoreResponse.customCoordinates + customMetadata = versionRestoreResponse.customMetadata + fileId = versionRestoreResponse.fileId + filePath = versionRestoreResponse.filePath + fileType = versionRestoreResponse.fileType + hasAlpha = versionRestoreResponse.hasAlpha + height = versionRestoreResponse.height + isPrivateFile = versionRestoreResponse.isPrivateFile + isPublished = versionRestoreResponse.isPublished + mime = versionRestoreResponse.mime + name = versionRestoreResponse.name + size = versionRestoreResponse.size + tags = versionRestoreResponse.tags.map { it.toMutableList() } + thumbnail = versionRestoreResponse.thumbnail + type = versionRestoreResponse.type + updatedAt = versionRestoreResponse.updatedAt + url = versionRestoreResponse.url + versionInfo = versionRestoreResponse.versionInfo + width = versionRestoreResponse.width + additionalProperties = versionRestoreResponse.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: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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: 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 } + + /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [VersionRestoreResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionRestoreResponse = + VersionRestoreResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + 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(): VersionRestoreResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type() + 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) + + (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) + + (if (type.asKnown().isPresent) 1 else 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 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 VersionRestoreResponse && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + 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() = + "VersionRestoreResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/versions/VersionRetrieveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParams.kt new file mode 100644 index 00000000..15c717fe --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParams.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 VersionRetrieveParams +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 [VersionRetrieveParams]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionRetrieveParams]. */ + 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(versionRetrieveParams: VersionRetrieveParams) = apply { + fileId = versionRetrieveParams.fileId + versionId = versionRetrieveParams.versionId + additionalHeaders = versionRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = versionRetrieveParams.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 [VersionRetrieveParams]. + * + * 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(): VersionRetrieveParams = + VersionRetrieveParams( + 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 VersionRetrieveParams && + 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() = + "VersionRetrieveParams{fileId=$fileId, versionId=$versionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponse.kt new file mode 100644 index 00000000..2335105b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponse.kt @@ -0,0 +1,1353 @@ +// 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.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 + +/** Object containing details of a file or file version. */ +class VersionRetrieveResponse +private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + 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: JsonValue = 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, + 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. */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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 [VersionRetrieveResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionRetrieveResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonValue = 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(versionRetrieveResponse: VersionRetrieveResponse) = apply { + aiTags = versionRetrieveResponse.aiTags.map { it.toMutableList() } + createdAt = versionRetrieveResponse.createdAt + customCoordinates = versionRetrieveResponse.customCoordinates + customMetadata = versionRetrieveResponse.customMetadata + fileId = versionRetrieveResponse.fileId + filePath = versionRetrieveResponse.filePath + fileType = versionRetrieveResponse.fileType + hasAlpha = versionRetrieveResponse.hasAlpha + height = versionRetrieveResponse.height + isPrivateFile = versionRetrieveResponse.isPrivateFile + isPublished = versionRetrieveResponse.isPublished + mime = versionRetrieveResponse.mime + name = versionRetrieveResponse.name + size = versionRetrieveResponse.size + tags = versionRetrieveResponse.tags.map { it.toMutableList() } + thumbnail = versionRetrieveResponse.thumbnail + type = versionRetrieveResponse.type + updatedAt = versionRetrieveResponse.updatedAt + url = versionRetrieveResponse.url + versionInfo = versionRetrieveResponse.versionInfo + width = versionRetrieveResponse.width + additionalProperties = versionRetrieveResponse.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: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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: 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 } + + /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [VersionRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionRetrieveResponse = + VersionRetrieveResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + 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(): VersionRetrieveResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type() + 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) + + (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) + + (if (type.asKnown().isPresent) 1 else 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 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 VersionRetrieveResponse && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + 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() = + "VersionRetrieveResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/folder/FolderCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateParams.kt new file mode 100644 index 00000000..50a36457 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateParams.kt @@ -0,0 +1,550 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folder + +import 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/folder/FolderCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateResponse.kt new file mode 100644 index 00000000..7d95b6de --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folder + +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/folder/FolderDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteParams.kt new file mode 100644 index 00000000..fbfff16b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteParams.kt @@ -0,0 +1,421 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folder + +import 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/folder/FolderDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteResponse.kt new file mode 100644 index 00000000..77fe1825 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folder + +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/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..3bc65d76 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsync.kt @@ -0,0 +1,70 @@ +// 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.accounts.AccountGetUsageParams +import com.imagekit.api.models.accounts.AccountGetUsageResponse +import java.util.concurrent.CompletableFuture +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 + + /** + * 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 getUsage(params: AccountGetUsageParams): CompletableFuture = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: AccountGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * 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 + + /** + * Returns a raw HTTP response for `get /v1/accounts/usage`, but is otherwise the same as + * [AccountServiceAsync.getUsage]. + */ + fun getUsage( + params: AccountGetUsageParams + ): CompletableFuture> = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: AccountGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} 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..f6234c97 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsyncImpl.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.accounts.AccountGetUsageParams +import com.imagekit.api.models.accounts.AccountGetUsageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AccountServiceAsync { + + private val withRawResponse: AccountServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AccountServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AccountServiceAsync = + AccountServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getUsage( + params: AccountGetUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/accounts/usage + withRawResponse().getUsage(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccountServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse = + AccountServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: AccountGetUsageParams, + 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 { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsync.kt new file mode 100644 index 00000000..17061158 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsync.kt @@ -0,0 +1,186 @@ +// 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.bulkjobs.BulkJobCopyFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobCopyFolderResponse +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderResponse +import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusParams +import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BulkJobServiceAsync { + + /** + * 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): BulkJobServiceAsync + + /** + * 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 copyFolder(params: BulkJobCopyFolderParams): CompletableFuture = + copyFolder(params, RequestOptions.none()) + + /** @see copyFolder */ + fun copyFolder( + params: BulkJobCopyFolderParams, + 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 moveFolder(params: BulkJobMoveFolderParams): CompletableFuture = + moveFolder(params, RequestOptions.none()) + + /** @see moveFolder */ + fun moveFolder( + params: BulkJobMoveFolderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This API returns the status of a bulk job like copy and move folder operations. */ + fun retrieveStatus(jobId: String): CompletableFuture = + retrieveStatus(jobId, BulkJobRetrieveStatusParams.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveStatus(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), + ): CompletableFuture = + retrieveStatus(jobId, params, RequestOptions.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + params: BulkJobRetrieveStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieveStatus */ + fun retrieveStatus( + params: BulkJobRetrieveStatusParams + ): CompletableFuture = + retrieveStatus(params, RequestOptions.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieveStatus(jobId, BulkJobRetrieveStatusParams.none(), requestOptions) + + /** + * A view of [BulkJobServiceAsync] 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 + ): BulkJobServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same + * as [BulkJobServiceAsync.copyFolder]. + */ + fun copyFolder( + params: BulkJobCopyFolderParams + ): CompletableFuture> = + copyFolder(params, RequestOptions.none()) + + /** @see copyFolder */ + fun copyFolder( + params: BulkJobCopyFolderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same + * as [BulkJobServiceAsync.moveFolder]. + */ + fun moveFolder( + params: BulkJobMoveFolderParams + ): CompletableFuture> = + moveFolder(params, RequestOptions.none()) + + /** @see moveFolder */ + fun moveFolder( + params: BulkJobMoveFolderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/bulkJobs/{jobId}`, but is otherwise the same as + * [BulkJobServiceAsync.retrieveStatus]. + */ + fun retrieveStatus( + jobId: String + ): CompletableFuture> = + retrieveStatus(jobId, BulkJobRetrieveStatusParams.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveStatus(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), + ): CompletableFuture> = + retrieveStatus(jobId, params, RequestOptions.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + params: BulkJobRetrieveStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieveStatus */ + fun retrieveStatus( + params: BulkJobRetrieveStatusParams + ): CompletableFuture> = + retrieveStatus(params, RequestOptions.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieveStatus(jobId, BulkJobRetrieveStatusParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncImpl.kt new file mode 100644 index 00000000..dd5389cb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncImpl.kt @@ -0,0 +1,170 @@ +// 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.bulkjobs.BulkJobCopyFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobCopyFolderResponse +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderResponse +import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusParams +import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BulkJobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BulkJobServiceAsync { + + private val withRawResponse: BulkJobServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BulkJobServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BulkJobServiceAsync = + BulkJobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun copyFolder( + params: BulkJobCopyFolderParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/bulkJobs/copyFolder + withRawResponse().copyFolder(params, requestOptions).thenApply { it.parse() } + + override fun moveFolder( + params: BulkJobMoveFolderParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/bulkJobs/moveFolder + withRawResponse().moveFolder(params, requestOptions).thenApply { it.parse() } + + override fun retrieveStatus( + params: BulkJobRetrieveStatusParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/bulkJobs/{jobId} + withRawResponse().retrieveStatus(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkJobServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BulkJobServiceAsync.WithRawResponse = + BulkJobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val copyFolderHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun copyFolder( + params: BulkJobCopyFolderParams, + 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 { copyFolderHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val moveFolderHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun moveFolder( + params: BulkJobMoveFolderParams, + 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 { moveFolderHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveStatusHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveStatus( + params: BulkJobRetrieveStatusParams, + 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 { retrieveStatusHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} 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..58153e22 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt @@ -0,0 +1,293 @@ +// 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.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateResponse +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.CustomMetadataFieldListResponse +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateResponse +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..c6e6494f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt @@ -0,0 +1,218 @@ +// 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.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateResponse +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.CustomMetadataFieldListResponse +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateResponse +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..3a5df469 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt @@ -0,0 +1,467 @@ +// 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.FileAddTagsParams +import com.imagekit.api.models.files.FileAddTagsResponse +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.FileListParams +import com.imagekit.api.models.files.FileListResponse +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileMoveResponse +import com.imagekit.api.models.files.FileRemoveAiTagsParams +import com.imagekit.api.models.files.FileRemoveAiTagsResponse +import com.imagekit.api.models.files.FileRemoveTagsParams +import com.imagekit.api.models.files.FileRemoveTagsResponse +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileRenameResponse +import com.imagekit.api.models.files.FileUploadV1Params +import com.imagekit.api.models.files.FileUploadV1Response +import com.imagekit.api.models.files.FileUploadV2Params +import com.imagekit.api.models.files.FileUploadV2Response +import com.imagekit.api.services.async.files.BatchServiceAsync +import com.imagekit.api.services.async.files.DetailServiceAsync +import com.imagekit.api.services.async.files.MetadataServiceAsync +import com.imagekit.api.services.async.files.PurgeServiceAsync +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 details(): DetailServiceAsync + + fun batch(): BatchServiceAsync + + fun versions(): VersionServiceAsync + + fun purge(): PurgeServiceAsync + + fun metadata(): MetadataServiceAsync + + /** + * 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(FileListParams.none()) + + /** @see list */ + fun list( + params: FileListParams = FileListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: FileListParams = FileListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture> = + list(FileListParams.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 API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a + * time. + */ + fun addTags(params: FileAddTagsParams): CompletableFuture = + addTags(params, RequestOptions.none()) + + /** @see addTags */ + fun addTags( + params: FileAddTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * 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 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 + + /** + * This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified + * at a time. + */ + fun removeAiTags(params: FileRemoveAiTagsParams): CompletableFuture = + removeAiTags(params, RequestOptions.none()) + + /** @see removeAiTags */ + fun removeAiTags( + params: FileRemoveAiTagsParams, + 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: FileRemoveTagsParams): CompletableFuture = + removeTags(params, RequestOptions.none()) + + /** @see removeTags */ + fun removeTags( + params: FileRemoveTagsParams, + 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 `expiration` 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 uploadV1(params: FileUploadV1Params): CompletableFuture = + uploadV1(params, RequestOptions.none()) + + /** @see uploadV1 */ + fun uploadV1( + params: FileUploadV1Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * 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 uploadV2(params: FileUploadV2Params): CompletableFuture = + uploadV2(params, RequestOptions.none()) + + /** @see uploadV2 */ + fun uploadV2( + params: FileUploadV2Params, + 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 details(): DetailServiceAsync.WithRawResponse + + fun batch(): BatchServiceAsync.WithRawResponse + + fun versions(): VersionServiceAsync.WithRawResponse + + fun purge(): PurgeServiceAsync.WithRawResponse + + fun metadata(): MetadataServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files`, but is otherwise the same as + * [FileServiceAsync.list]. + */ + fun list(): CompletableFuture>> = + list(FileListParams.none()) + + /** @see list */ + fun list( + params: FileListParams = FileListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list( + params: FileListParams = FileListParams.none() + ): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = + list(FileListParams.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/addTags`, but is otherwise the same as + * [FileServiceAsync.addTags]. + */ + fun addTags( + params: FileAddTagsParams + ): CompletableFuture> = + addTags(params, RequestOptions.none()) + + /** @see addTags */ + fun addTags( + params: FileAddTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * 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 `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 `post /v1/files/removeAITags`, but is otherwise the same + * as [FileServiceAsync.removeAiTags]. + */ + fun removeAiTags( + params: FileRemoveAiTagsParams + ): CompletableFuture> = + removeAiTags(params, RequestOptions.none()) + + /** @see removeAiTags */ + fun removeAiTags( + params: FileRemoveAiTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/files/removeTags`, but is otherwise the same as + * [FileServiceAsync.removeTags]. + */ + fun removeTags( + params: FileRemoveTagsParams + ): CompletableFuture> = + removeTags(params, RequestOptions.none()) + + /** @see removeTags */ + fun removeTags( + params: FileRemoveTagsParams, + 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.uploadV1]. + */ + fun uploadV1( + params: FileUploadV1Params + ): CompletableFuture> = + uploadV1(params, RequestOptions.none()) + + /** @see uploadV1 */ + fun uploadV1( + params: FileUploadV1Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /api/v2/files/upload`, but is otherwise the same as + * [FileServiceAsync.uploadV2]. + */ + fun uploadV2( + params: FileUploadV2Params + ): CompletableFuture> = + uploadV2(params, RequestOptions.none()) + + /** @see uploadV2 */ + fun uploadV2( + params: FileUploadV2Params, + 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..a800c132 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt @@ -0,0 +1,510 @@ +// 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.FileAddTagsParams +import com.imagekit.api.models.files.FileAddTagsResponse +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.FileListParams +import com.imagekit.api.models.files.FileListResponse +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileMoveResponse +import com.imagekit.api.models.files.FileRemoveAiTagsParams +import com.imagekit.api.models.files.FileRemoveAiTagsResponse +import com.imagekit.api.models.files.FileRemoveTagsParams +import com.imagekit.api.models.files.FileRemoveTagsResponse +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileRenameResponse +import com.imagekit.api.models.files.FileUploadV1Params +import com.imagekit.api.models.files.FileUploadV1Response +import com.imagekit.api.models.files.FileUploadV2Params +import com.imagekit.api.models.files.FileUploadV2Response +import com.imagekit.api.services.async.files.BatchServiceAsync +import com.imagekit.api.services.async.files.BatchServiceAsyncImpl +import com.imagekit.api.services.async.files.DetailServiceAsync +import com.imagekit.api.services.async.files.DetailServiceAsyncImpl +import com.imagekit.api.services.async.files.MetadataServiceAsync +import com.imagekit.api.services.async.files.MetadataServiceAsyncImpl +import com.imagekit.api.services.async.files.PurgeServiceAsync +import com.imagekit.api.services.async.files.PurgeServiceAsyncImpl +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 details: DetailServiceAsync by lazy { DetailServiceAsyncImpl(clientOptions) } + + private val batch: BatchServiceAsync by lazy { BatchServiceAsyncImpl(clientOptions) } + + private val versions: VersionServiceAsync by lazy { VersionServiceAsyncImpl(clientOptions) } + + private val purge: PurgeServiceAsync by lazy { PurgeServiceAsyncImpl(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 details(): DetailServiceAsync = details + + override fun batch(): BatchServiceAsync = batch + + override fun versions(): VersionServiceAsync = versions + + override fun purge(): PurgeServiceAsync = purge + + override fun metadata(): MetadataServiceAsync = metadata + + override fun list( + params: FileListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /v1/files + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: FileDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/files/{fileId} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun addTags( + params: FileAddTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/addTags + withRawResponse().addTags(params, requestOptions).thenApply { it.parse() } + + override fun copy( + params: FileCopyParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/copy + withRawResponse().copy(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 removeAiTags( + params: FileRemoveAiTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/removeAITags + withRawResponse().removeAiTags(params, requestOptions).thenApply { it.parse() } + + override fun removeTags( + params: FileRemoveTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/removeTags + withRawResponse().removeTags(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 uploadV1( + params: FileUploadV1Params, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/files/upload + withRawResponse().uploadV1(params, requestOptions).thenApply { it.parse() } + + override fun uploadV2( + params: FileUploadV2Params, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v2/files/upload + withRawResponse().uploadV2(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 details: DetailServiceAsync.WithRawResponse by lazy { + DetailServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val batch: BatchServiceAsync.WithRawResponse by lazy { + BatchServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val versions: VersionServiceAsync.WithRawResponse by lazy { + VersionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val purge: PurgeServiceAsync.WithRawResponse by lazy { + PurgeServiceAsyncImpl.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 details(): DetailServiceAsync.WithRawResponse = details + + override fun batch(): BatchServiceAsync.WithRawResponse = batch + + override fun versions(): VersionServiceAsync.WithRawResponse = versions + + override fun purge(): PurgeServiceAsync.WithRawResponse = purge + + override fun metadata(): MetadataServiceAsync.WithRawResponse = metadata + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: FileListParams, + 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() } + } + } + } + } + } + + 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 addTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun addTags( + params: FileAddTagsParams, + 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 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 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 removeAiTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun removeAiTags( + params: FileRemoveAiTagsParams, + 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: FileRemoveTagsParams, + 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() + } + } + } + } + } + + 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 uploadV1Handler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun uploadV1( + params: FileUploadV1Params, + 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 { uploadV1Handler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val uploadV2Handler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun uploadV2( + params: FileUploadV2Params, + 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 { uploadV2Handler.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..dadf76b9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt @@ -0,0 +1,99 @@ +// 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.folder.FolderCreateParams +import com.imagekit.api.models.folder.FolderCreateResponse +import com.imagekit.api.models.folder.FolderDeleteParams +import com.imagekit.api.models.folder.FolderDeleteResponse +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 + + /** + * 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 + + /** + * 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 + + /** + * 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> + } +} 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..db754058 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsyncImpl.kt @@ -0,0 +1,126 @@ +// 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.folder.FolderCreateParams +import com.imagekit.api.models.folder.FolderCreateResponse +import com.imagekit.api.models.folder.FolderDeleteParams +import com.imagekit.api.models.folder.FolderDeleteResponse +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) + } + + override fun withRawResponse(): FolderServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FolderServiceAsync = + FolderServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + 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() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FolderServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): FolderServiceAsync.WithRawResponse = + FolderServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + 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() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsync.kt new file mode 100644 index 00000000..50308eae --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsync.kt @@ -0,0 +1,72 @@ +// 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.batch.BatchDeleteParams +import com.imagekit.api.models.files.batch.BatchDeleteResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BatchServiceAsync { + + /** + * 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): BatchServiceAsync + + /** + * 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: BatchDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: BatchDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [BatchServiceAsync] 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 + ): BatchServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/files/batch/deleteByFileIds`, but is otherwise + * the same as [BatchServiceAsync.delete]. + */ + fun delete( + params: BatchDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: BatchDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncImpl.kt new file mode 100644 index 00000000..617ae04b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// 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.batch.BatchDeleteParams +import com.imagekit.api.models.files.batch.BatchDeleteResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class BatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BatchServiceAsync { + + private val withRawResponse: BatchServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BatchServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BatchServiceAsync = + BatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: BatchDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/batch/deleteByFileIds + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BatchServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BatchServiceAsync.WithRawResponse = + BatchServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: BatchDeleteParams, + 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() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsync.kt new file mode 100644 index 00000000..a1be570f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsync.kt @@ -0,0 +1,201 @@ +// 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.details.DetailRetrieveParams +import com.imagekit.api.models.files.details.DetailRetrieveResponse +import com.imagekit.api.models.files.details.DetailUpdateParams +import com.imagekit.api.models.files.details.DetailUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface DetailServiceAsync { + + /** + * 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): DetailServiceAsync + + /** + * This API returns an object with details or attributes about the current version of the file. + */ + fun retrieve(fileId: String): CompletableFuture = + retrieve(fileId, DetailRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: DetailRetrieveParams = DetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: DetailRetrieveParams = DetailRetrieveParams.none(), + ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DetailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: DetailRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(fileId, DetailRetrieveParams.none(), requestOptions) + + /** + * 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, DetailUpdateParams.none()) + + /** @see update */ + fun update( + fileId: String, + params: DetailUpdateParams = DetailUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see update */ + fun update( + fileId: String, + params: DetailUpdateParams = DetailUpdateParams.none(), + ): CompletableFuture = update(fileId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DetailUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: DetailUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(fileId, DetailUpdateParams.none(), requestOptions) + + /** + * A view of [DetailServiceAsync] 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 + ): DetailServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the + * same as [DetailServiceAsync.retrieve]. + */ + fun retrieve(fileId: String): CompletableFuture> = + retrieve(fileId, DetailRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: DetailRetrieveParams = DetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: DetailRetrieveParams = DetailRetrieveParams.none(), + ): CompletableFuture> = + retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DetailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: DetailRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(fileId, DetailRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the + * same as [DetailServiceAsync.update]. + */ + fun update(fileId: String): CompletableFuture> = + update(fileId, DetailUpdateParams.none()) + + /** @see update */ + fun update( + fileId: String, + params: DetailUpdateParams = DetailUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see update */ + fun update( + fileId: String, + params: DetailUpdateParams = DetailUpdateParams.none(), + ): CompletableFuture> = + update(fileId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DetailUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: DetailUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(fileId, DetailUpdateParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncImpl.kt new file mode 100644 index 00000000..26de7ad0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncImpl.kt @@ -0,0 +1,133 @@ +// 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.details.DetailRetrieveParams +import com.imagekit.api.models.files.details.DetailRetrieveResponse +import com.imagekit.api.models.files.details.DetailUpdateParams +import com.imagekit.api.models.files.details.DetailUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DetailServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DetailServiceAsync { + + private val withRawResponse: DetailServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DetailServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DetailServiceAsync = + DetailServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: DetailRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/{fileId}/details + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: DetailUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /v1/files/{fileId}/details + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DetailServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): DetailServiceAsync.WithRawResponse = + DetailServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: DetailRetrieveParams, + 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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: DetailUpdateParams, + 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() + } + } + } + } + } + } +} 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..112ab2d5 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt @@ -0,0 +1,152 @@ +// 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.MetadataFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataFromUrlResponse +import com.imagekit.api.models.files.metadata.MetadataRetrieveParams +import com.imagekit.api.models.files.metadata.MetadataRetrieveResponse +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 retrieve(fileId: String): CompletableFuture = + retrieve(fileId, MetadataRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: MetadataRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: MetadataRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(fileId, MetadataRetrieveParams.none(), requestOptions) + + /** + * Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. + */ + fun fromUrl(params: MetadataFromUrlParams): CompletableFuture = + fromUrl(params, RequestOptions.none()) + + /** @see fromUrl */ + fun fromUrl( + params: MetadataFromUrlParams, + 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.retrieve]. + */ + fun retrieve(fileId: String): CompletableFuture> = + retrieve(fileId, MetadataRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + ): CompletableFuture> = + retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: MetadataRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: MetadataRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(fileId, MetadataRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/files/metadata`, but is otherwise the same as + * [MetadataServiceAsync.fromUrl]. + */ + fun fromUrl( + params: MetadataFromUrlParams + ): CompletableFuture> = + fromUrl(params, RequestOptions.none()) + + /** @see fromUrl */ + fun fromUrl( + params: MetadataFromUrlParams, + 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..df8ec9d0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt @@ -0,0 +1,128 @@ +// 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.MetadataFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataFromUrlResponse +import com.imagekit.api.models.files.metadata.MetadataRetrieveParams +import com.imagekit.api.models.files.metadata.MetadataRetrieveResponse +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 retrieve( + params: MetadataRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/{fileId}/metadata + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun fromUrl( + params: MetadataFromUrlParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/metadata + withRawResponse().fromUrl(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 retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: MetadataRetrieveParams, + 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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fromUrlHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun fromUrl( + params: MetadataFromUrlParams, + 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 { fromUrlHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsync.kt new file mode 100644 index 00000000..15657738 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsync.kt @@ -0,0 +1,145 @@ +// 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.purge.PurgeExecuteParams +import com.imagekit.api.models.files.purge.PurgeExecuteResponse +import com.imagekit.api.models.files.purge.PurgeStatusParams +import com.imagekit.api.models.files.purge.PurgeStatusResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PurgeServiceAsync { + + /** + * 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): PurgeServiceAsync + + /** + * 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 execute(params: PurgeExecuteParams): CompletableFuture = + execute(params, RequestOptions.none()) + + /** @see execute */ + fun execute( + params: PurgeExecuteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This API returns the status of a purge cache request. */ + fun status(requestId: String): CompletableFuture = + status(requestId, PurgeStatusParams.none()) + + /** @see status */ + fun status( + requestId: String, + params: PurgeStatusParams = PurgeStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + status(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see status */ + fun status( + requestId: String, + params: PurgeStatusParams = PurgeStatusParams.none(), + ): CompletableFuture = status(requestId, params, RequestOptions.none()) + + /** @see status */ + fun status( + params: PurgeStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see status */ + fun status(params: PurgeStatusParams): CompletableFuture = + status(params, RequestOptions.none()) + + /** @see status */ + fun status( + requestId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + status(requestId, PurgeStatusParams.none(), requestOptions) + + /** A view of [PurgeServiceAsync] 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 + ): PurgeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/files/purge`, but is otherwise the same as + * [PurgeServiceAsync.execute]. + */ + fun execute( + params: PurgeExecuteParams + ): CompletableFuture> = + execute(params, RequestOptions.none()) + + /** @see execute */ + fun execute( + params: PurgeExecuteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/files/purge/{requestId}`, but is otherwise the + * same as [PurgeServiceAsync.status]. + */ + fun status(requestId: String): CompletableFuture> = + status(requestId, PurgeStatusParams.none()) + + /** @see status */ + fun status( + requestId: String, + params: PurgeStatusParams = PurgeStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + status(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see status */ + fun status( + requestId: String, + params: PurgeStatusParams = PurgeStatusParams.none(), + ): CompletableFuture> = + status(requestId, params, RequestOptions.none()) + + /** @see status */ + fun status( + params: PurgeStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see status */ + fun status( + params: PurgeStatusParams + ): CompletableFuture> = + status(params, RequestOptions.none()) + + /** @see status */ + fun status( + requestId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + status(requestId, PurgeStatusParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncImpl.kt new file mode 100644 index 00000000..6f66dba8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncImpl.kt @@ -0,0 +1,130 @@ +// 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.purge.PurgeExecuteParams +import com.imagekit.api.models.files.purge.PurgeExecuteResponse +import com.imagekit.api.models.files.purge.PurgeStatusParams +import com.imagekit.api.models.files.purge.PurgeStatusResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PurgeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PurgeServiceAsync { + + private val withRawResponse: PurgeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PurgeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): PurgeServiceAsync = + PurgeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun execute( + params: PurgeExecuteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/purge + withRawResponse().execute(params, requestOptions).thenApply { it.parse() } + + override fun status( + params: PurgeStatusParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/purge/{requestId} + withRawResponse().status(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PurgeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): PurgeServiceAsync.WithRawResponse = + PurgeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val executeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun execute( + params: PurgeExecuteParams, + 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 { executeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val statusHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun status( + params: PurgeStatusParams, + 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 { statusHandler.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..00c43988 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -0,0 +1,290 @@ +// 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.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionDeleteResponse +import com.imagekit.api.models.files.versions.VersionListParams +import com.imagekit.api.models.files.versions.VersionListResponse +import com.imagekit.api.models.files.versions.VersionRestoreParams +import com.imagekit.api.models.files.versions.VersionRestoreResponse +import com.imagekit.api.models.files.versions.VersionRetrieveParams +import com.imagekit.api.models.files.versions.VersionRetrieveResponse +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 an object with details or attributes of a file version. */ + fun retrieve( + versionId: String, + params: VersionRetrieveParams, + ): CompletableFuture = + retrieve(versionId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + versionId: String, + params: VersionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: VersionRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VersionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** 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 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/{versionId}`, but is + * otherwise the same as [VersionServiceAsync.retrieve]. + */ + fun retrieve( + versionId: String, + params: VersionRetrieveParams, + ): CompletableFuture> = + retrieve(versionId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + versionId: String, + params: VersionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: VersionRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VersionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * 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 `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..228092a7 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -0,0 +1,237 @@ +// 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.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionDeleteResponse +import com.imagekit.api.models.files.versions.VersionListParams +import com.imagekit.api.models.files.versions.VersionListResponse +import com.imagekit.api.models.files.versions.VersionRestoreParams +import com.imagekit.api.models.files.versions.VersionRestoreResponse +import com.imagekit.api.models.files.versions.VersionRetrieveParams +import com.imagekit.api.models.files.versions.VersionRetrieveResponse +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 retrieve( + params: VersionRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/{fileId}/versions/{versionId} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + 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 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 retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: VersionRetrieveParams, + 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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + 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 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/blocking/AccountService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountService.kt new file mode 100644 index 00000000..31727751 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountService.kt @@ -0,0 +1,66 @@ +// 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.accounts.AccountGetUsageParams +import com.imagekit.api.models.accounts.AccountGetUsageResponse +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 + + /** + * 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 getUsage(params: AccountGetUsageParams): AccountGetUsageResponse = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + fun getUsage( + params: AccountGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AccountGetUsageResponse + + /** 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 + + /** + * Returns a raw HTTP response for `get /v1/accounts/usage`, but is otherwise the same as + * [AccountService.getUsage]. + */ + @MustBeClosed + fun getUsage(params: AccountGetUsageParams): HttpResponseFor = + getUsage(params, RequestOptions.none()) + + /** @see getUsage */ + @MustBeClosed + fun getUsage( + params: AccountGetUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} 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..b2130ffd --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountServiceImpl.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.accounts.AccountGetUsageParams +import com.imagekit.api.models.accounts.AccountGetUsageResponse +import java.util.function.Consumer + +class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AccountService { + + private val withRawResponse: AccountService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AccountService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AccountService = + AccountServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun getUsage( + params: AccountGetUsageParams, + requestOptions: RequestOptions, + ): AccountGetUsageResponse = + // get /v1/accounts/usage + withRawResponse().getUsage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccountService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AccountService.WithRawResponse = + AccountServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getUsage( + params: AccountGetUsageParams, + 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 { getUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobService.kt new file mode 100644 index 00000000..318adbb7 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobService.kt @@ -0,0 +1,185 @@ +// 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.bulkjobs.BulkJobCopyFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobCopyFolderResponse +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderResponse +import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusParams +import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusResponse +import java.util.function.Consumer + +interface BulkJobService { + + /** + * 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): BulkJobService + + /** + * 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 copyFolder(params: BulkJobCopyFolderParams): BulkJobCopyFolderResponse = + copyFolder(params, RequestOptions.none()) + + /** @see copyFolder */ + fun copyFolder( + params: BulkJobCopyFolderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkJobCopyFolderResponse + + /** + * 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 moveFolder(params: BulkJobMoveFolderParams): BulkJobMoveFolderResponse = + moveFolder(params, RequestOptions.none()) + + /** @see moveFolder */ + fun moveFolder( + params: BulkJobMoveFolderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkJobMoveFolderResponse + + /** This API returns the status of a bulk job like copy and move folder operations. */ + fun retrieveStatus(jobId: String): BulkJobRetrieveStatusResponse = + retrieveStatus(jobId, BulkJobRetrieveStatusParams.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkJobRetrieveStatusResponse = + retrieveStatus(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), + ): BulkJobRetrieveStatusResponse = retrieveStatus(jobId, params, RequestOptions.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + params: BulkJobRetrieveStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkJobRetrieveStatusResponse + + /** @see retrieveStatus */ + fun retrieveStatus(params: BulkJobRetrieveStatusParams): BulkJobRetrieveStatusResponse = + retrieveStatus(params, RequestOptions.none()) + + /** @see retrieveStatus */ + fun retrieveStatus( + jobId: String, + requestOptions: RequestOptions, + ): BulkJobRetrieveStatusResponse = + retrieveStatus(jobId, BulkJobRetrieveStatusParams.none(), requestOptions) + + /** A view of [BulkJobService] 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): BulkJobService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same + * as [BulkJobService.copyFolder]. + */ + @MustBeClosed + fun copyFolder( + params: BulkJobCopyFolderParams + ): HttpResponseFor = copyFolder(params, RequestOptions.none()) + + /** @see copyFolder */ + @MustBeClosed + fun copyFolder( + params: BulkJobCopyFolderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same + * as [BulkJobService.moveFolder]. + */ + @MustBeClosed + fun moveFolder( + params: BulkJobMoveFolderParams + ): HttpResponseFor = moveFolder(params, RequestOptions.none()) + + /** @see moveFolder */ + @MustBeClosed + fun moveFolder( + params: BulkJobMoveFolderParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/bulkJobs/{jobId}`, but is otherwise the same as + * [BulkJobService.retrieveStatus]. + */ + @MustBeClosed + fun retrieveStatus(jobId: String): HttpResponseFor = + retrieveStatus(jobId, BulkJobRetrieveStatusParams.none()) + + /** @see retrieveStatus */ + @MustBeClosed + fun retrieveStatus( + jobId: String, + params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveStatus(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveStatus */ + @MustBeClosed + fun retrieveStatus( + jobId: String, + params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), + ): HttpResponseFor = + retrieveStatus(jobId, params, RequestOptions.none()) + + /** @see retrieveStatus */ + @MustBeClosed + fun retrieveStatus( + params: BulkJobRetrieveStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieveStatus */ + @MustBeClosed + fun retrieveStatus( + params: BulkJobRetrieveStatusParams + ): HttpResponseFor = + retrieveStatus(params, RequestOptions.none()) + + /** @see retrieveStatus */ + @MustBeClosed + fun retrieveStatus( + jobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieveStatus(jobId, BulkJobRetrieveStatusParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobServiceImpl.kt new file mode 100644 index 00000000..6e8575f1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobServiceImpl.kt @@ -0,0 +1,160 @@ +// 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.bulkjobs.BulkJobCopyFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobCopyFolderResponse +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderResponse +import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusParams +import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BulkJobServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BulkJobService { + + private val withRawResponse: BulkJobService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BulkJobService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BulkJobService = + BulkJobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun copyFolder( + params: BulkJobCopyFolderParams, + requestOptions: RequestOptions, + ): BulkJobCopyFolderResponse = + // post /v1/bulkJobs/copyFolder + withRawResponse().copyFolder(params, requestOptions).parse() + + override fun moveFolder( + params: BulkJobMoveFolderParams, + requestOptions: RequestOptions, + ): BulkJobMoveFolderResponse = + // post /v1/bulkJobs/moveFolder + withRawResponse().moveFolder(params, requestOptions).parse() + + override fun retrieveStatus( + params: BulkJobRetrieveStatusParams, + requestOptions: RequestOptions, + ): BulkJobRetrieveStatusResponse = + // get /v1/bulkJobs/{jobId} + withRawResponse().retrieveStatus(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkJobService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BulkJobService.WithRawResponse = + BulkJobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val copyFolderHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun copyFolder( + params: BulkJobCopyFolderParams, + 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 { copyFolderHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val moveFolderHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun moveFolder( + params: BulkJobMoveFolderParams, + 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 { moveFolderHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveStatusHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveStatus( + params: BulkJobRetrieveStatusParams, + 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 { retrieveStatusHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} 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..c672e78b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt @@ -0,0 +1,290 @@ +// 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.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateResponse +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.CustomMetadataFieldListResponse +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateResponse +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): CustomMetadataFieldCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomMetadataFieldCreateResponse + + /** This API updates the label or schema of an existing custom metadata field. */ + fun update(id: String): CustomMetadataFieldUpdateResponse = + update(id, CustomMetadataFieldUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomMetadataFieldUpdateResponse = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + ): CustomMetadataFieldUpdateResponse = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CustomMetadataFieldUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomMetadataFieldUpdateResponse + + /** @see update */ + fun update(params: CustomMetadataFieldUpdateParams): CustomMetadataFieldUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): CustomMetadataFieldUpdateResponse = + 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..a5a307ad --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt @@ -0,0 +1,202 @@ +// 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.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateResponse +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.CustomMetadataFieldListResponse +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateResponse +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, + ): CustomMetadataFieldCreateResponse = + // post /v1/customMetadataFields + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: CustomMetadataFieldUpdateParams, + requestOptions: RequestOptions, + ): CustomMetadataFieldUpdateResponse = + // 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..f9ec8ef0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt @@ -0,0 +1,463 @@ +// 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.FileAddTagsParams +import com.imagekit.api.models.files.FileAddTagsResponse +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.FileListParams +import com.imagekit.api.models.files.FileListResponse +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileMoveResponse +import com.imagekit.api.models.files.FileRemoveAiTagsParams +import com.imagekit.api.models.files.FileRemoveAiTagsResponse +import com.imagekit.api.models.files.FileRemoveTagsParams +import com.imagekit.api.models.files.FileRemoveTagsResponse +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileRenameResponse +import com.imagekit.api.models.files.FileUploadV1Params +import com.imagekit.api.models.files.FileUploadV1Response +import com.imagekit.api.models.files.FileUploadV2Params +import com.imagekit.api.models.files.FileUploadV2Response +import com.imagekit.api.services.blocking.files.BatchService +import com.imagekit.api.services.blocking.files.DetailService +import com.imagekit.api.services.blocking.files.MetadataService +import com.imagekit.api.services.blocking.files.PurgeService +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 details(): DetailService + + fun batch(): BatchService + + fun versions(): VersionService + + fun purge(): PurgeService + + fun metadata(): MetadataService + + /** + * 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(FileListParams.none()) + + /** @see list */ + fun list( + params: FileListParams = FileListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list(params: FileListParams = FileListParams.none()): List = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List = + list(FileListParams.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 API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a + * time. + */ + fun addTags(params: FileAddTagsParams): FileAddTagsResponse = + addTags(params, RequestOptions.none()) + + /** @see addTags */ + fun addTags( + params: FileAddTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileAddTagsResponse + + /** + * 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 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 + + /** + * This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified + * at a time. + */ + fun removeAiTags(params: FileRemoveAiTagsParams): FileRemoveAiTagsResponse = + removeAiTags(params, RequestOptions.none()) + + /** @see removeAiTags */ + fun removeAiTags( + params: FileRemoveAiTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileRemoveAiTagsResponse + + /** + * This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at + * a time. + */ + fun removeTags(params: FileRemoveTagsParams): FileRemoveTagsResponse = + removeTags(params, RequestOptions.none()) + + /** @see removeTags */ + fun removeTags( + params: FileRemoveTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileRemoveTagsResponse + + /** + * 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 `expiration` 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 uploadV1(params: FileUploadV1Params): FileUploadV1Response = + uploadV1(params, RequestOptions.none()) + + /** @see uploadV1 */ + fun uploadV1( + params: FileUploadV1Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileUploadV1Response + + /** + * 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 uploadV2(params: FileUploadV2Params): FileUploadV2Response = + uploadV2(params, RequestOptions.none()) + + /** @see uploadV2 */ + fun uploadV2( + params: FileUploadV2Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileUploadV2Response + + /** 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 details(): DetailService.WithRawResponse + + fun batch(): BatchService.WithRawResponse + + fun versions(): VersionService.WithRawResponse + + fun purge(): PurgeService.WithRawResponse + + fun metadata(): MetadataService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files`, but is otherwise the same as + * [FileService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor> = list(FileListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: FileListParams = FileListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list( + params: FileListParams = FileListParams.none() + ): HttpResponseFor> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor> = + list(FileListParams.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/addTags`, but is otherwise the same as + * [FileService.addTags]. + */ + @MustBeClosed + fun addTags(params: FileAddTagsParams): HttpResponseFor = + addTags(params, RequestOptions.none()) + + /** @see addTags */ + @MustBeClosed + fun addTags( + params: FileAddTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * 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 `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 `post /v1/files/removeAITags`, but is otherwise the same + * as [FileService.removeAiTags]. + */ + @MustBeClosed + fun removeAiTags( + params: FileRemoveAiTagsParams + ): HttpResponseFor = removeAiTags(params, RequestOptions.none()) + + /** @see removeAiTags */ + @MustBeClosed + fun removeAiTags( + params: FileRemoveAiTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/files/removeTags`, but is otherwise the same as + * [FileService.removeTags]. + */ + @MustBeClosed + fun removeTags(params: FileRemoveTagsParams): HttpResponseFor = + removeTags(params, RequestOptions.none()) + + /** @see removeTags */ + @MustBeClosed + fun removeTags( + params: FileRemoveTagsParams, + 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.uploadV1]. + */ + @MustBeClosed + fun uploadV1(params: FileUploadV1Params): HttpResponseFor = + uploadV1(params, RequestOptions.none()) + + /** @see uploadV1 */ + @MustBeClosed + fun uploadV1( + params: FileUploadV1Params, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /api/v2/files/upload`, but is otherwise the same as + * [FileService.uploadV2]. + */ + @MustBeClosed + fun uploadV2(params: FileUploadV2Params): HttpResponseFor = + uploadV2(params, RequestOptions.none()) + + /** @see uploadV2 */ + @MustBeClosed + fun uploadV2( + params: FileUploadV2Params, + 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..8aea71f0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt @@ -0,0 +1,470 @@ +// 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.FileAddTagsParams +import com.imagekit.api.models.files.FileAddTagsResponse +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.FileListParams +import com.imagekit.api.models.files.FileListResponse +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileMoveResponse +import com.imagekit.api.models.files.FileRemoveAiTagsParams +import com.imagekit.api.models.files.FileRemoveAiTagsResponse +import com.imagekit.api.models.files.FileRemoveTagsParams +import com.imagekit.api.models.files.FileRemoveTagsResponse +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileRenameResponse +import com.imagekit.api.models.files.FileUploadV1Params +import com.imagekit.api.models.files.FileUploadV1Response +import com.imagekit.api.models.files.FileUploadV2Params +import com.imagekit.api.models.files.FileUploadV2Response +import com.imagekit.api.services.blocking.files.BatchService +import com.imagekit.api.services.blocking.files.BatchServiceImpl +import com.imagekit.api.services.blocking.files.DetailService +import com.imagekit.api.services.blocking.files.DetailServiceImpl +import com.imagekit.api.services.blocking.files.MetadataService +import com.imagekit.api.services.blocking.files.MetadataServiceImpl +import com.imagekit.api.services.blocking.files.PurgeService +import com.imagekit.api.services.blocking.files.PurgeServiceImpl +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 details: DetailService by lazy { DetailServiceImpl(clientOptions) } + + private val batch: BatchService by lazy { BatchServiceImpl(clientOptions) } + + private val versions: VersionService by lazy { VersionServiceImpl(clientOptions) } + + private val purge: PurgeService by lazy { PurgeServiceImpl(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 details(): DetailService = details + + override fun batch(): BatchService = batch + + override fun versions(): VersionService = versions + + override fun purge(): PurgeService = purge + + override fun metadata(): MetadataService = metadata + + override fun list( + params: FileListParams, + requestOptions: RequestOptions, + ): List = + // get /v1/files + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: FileDeleteParams, requestOptions: RequestOptions) { + // delete /v1/files/{fileId} + withRawResponse().delete(params, requestOptions) + } + + override fun addTags( + params: FileAddTagsParams, + requestOptions: RequestOptions, + ): FileAddTagsResponse = + // post /v1/files/addTags + withRawResponse().addTags(params, requestOptions).parse() + + override fun copy(params: FileCopyParams, requestOptions: RequestOptions): FileCopyResponse = + // post /v1/files/copy + withRawResponse().copy(params, requestOptions).parse() + + override fun move(params: FileMoveParams, requestOptions: RequestOptions): FileMoveResponse = + // post /v1/files/move + withRawResponse().move(params, requestOptions).parse() + + override fun removeAiTags( + params: FileRemoveAiTagsParams, + requestOptions: RequestOptions, + ): FileRemoveAiTagsResponse = + // post /v1/files/removeAITags + withRawResponse().removeAiTags(params, requestOptions).parse() + + override fun removeTags( + params: FileRemoveTagsParams, + requestOptions: RequestOptions, + ): FileRemoveTagsResponse = + // post /v1/files/removeTags + withRawResponse().removeTags(params, requestOptions).parse() + + override fun rename( + params: FileRenameParams, + requestOptions: RequestOptions, + ): FileRenameResponse = + // put /v1/files/rename + withRawResponse().rename(params, requestOptions).parse() + + override fun uploadV1( + params: FileUploadV1Params, + requestOptions: RequestOptions, + ): FileUploadV1Response = + // post /api/v1/files/upload + withRawResponse().uploadV1(params, requestOptions).parse() + + override fun uploadV2( + params: FileUploadV2Params, + requestOptions: RequestOptions, + ): FileUploadV2Response = + // post /api/v2/files/upload + withRawResponse().uploadV2(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FileService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val details: DetailService.WithRawResponse by lazy { + DetailServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val batch: BatchService.WithRawResponse by lazy { + BatchServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val versions: VersionService.WithRawResponse by lazy { + VersionServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val purge: PurgeService.WithRawResponse by lazy { + PurgeServiceImpl.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 details(): DetailService.WithRawResponse = details + + override fun batch(): BatchService.WithRawResponse = batch + + override fun versions(): VersionService.WithRawResponse = versions + + override fun purge(): PurgeService.WithRawResponse = purge + + override fun metadata(): MetadataService.WithRawResponse = metadata + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: FileListParams, + 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() } + } + } + } + } + + 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 addTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun addTags( + params: FileAddTagsParams, + 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 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 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 removeAiTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun removeAiTags( + params: FileRemoveAiTagsParams, + 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: FileRemoveTagsParams, + 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() + } + } + } + } + + 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 uploadV1Handler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun uploadV1( + params: FileUploadV1Params, + 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 { uploadV1Handler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val uploadV2Handler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun uploadV2( + params: FileUploadV2Params, + 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 { uploadV2Handler.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..e5c54540 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderService.kt @@ -0,0 +1,95 @@ +// 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.folder.FolderCreateParams +import com.imagekit.api.models.folder.FolderCreateResponse +import com.imagekit.api.models.folder.FolderDeleteParams +import com.imagekit.api.models.folder.FolderDeleteResponse +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 + + /** + * 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 + + /** 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 + + /** + * 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 + } +} 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..01f450b9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderServiceImpl.kt @@ -0,0 +1,119 @@ +// 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.folder.FolderCreateParams +import com.imagekit.api.models.folder.FolderCreateResponse +import com.imagekit.api.models.folder.FolderDeleteParams +import com.imagekit.api.models.folder.FolderDeleteResponse +import java.util.function.Consumer + +class FolderServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FolderService { + + private val withRawResponse: FolderService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FolderService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FolderService = + FolderServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + 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() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FolderService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): FolderService.WithRawResponse = + FolderServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + 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() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchService.kt new file mode 100644 index 00000000..14b72088 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchService.kt @@ -0,0 +1,70 @@ +// 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.batch.BatchDeleteParams +import com.imagekit.api.models.files.batch.BatchDeleteResponse +import java.util.function.Consumer + +interface BatchService { + + /** + * 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): BatchService + + /** + * 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: BatchDeleteParams): BatchDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: BatchDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchDeleteResponse + + /** A view of [BatchService] 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): BatchService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/files/batch/deleteByFileIds`, but is otherwise + * the same as [BatchService.delete]. + */ + @MustBeClosed + fun delete(params: BatchDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: BatchDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchServiceImpl.kt new file mode 100644 index 00000000..262953be --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchServiceImpl.kt @@ -0,0 +1,82 @@ +// 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.batch.BatchDeleteParams +import com.imagekit.api.models.files.batch.BatchDeleteResponse +import java.util.function.Consumer + +class BatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BatchService { + + private val withRawResponse: BatchService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BatchService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BatchService = + BatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: BatchDeleteParams, + requestOptions: RequestOptions, + ): BatchDeleteResponse = + // post /v1/files/batch/deleteByFileIds + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BatchService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BatchService.WithRawResponse = + BatchServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: BatchDeleteParams, + 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() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailService.kt new file mode 100644 index 00000000..f089527f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailService.kt @@ -0,0 +1,194 @@ +// 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.details.DetailRetrieveParams +import com.imagekit.api.models.files.details.DetailRetrieveResponse +import com.imagekit.api.models.files.details.DetailUpdateParams +import com.imagekit.api.models.files.details.DetailUpdateResponse +import java.util.function.Consumer + +interface DetailService { + + /** + * 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): DetailService + + /** + * This API returns an object with details or attributes about the current version of the file. + */ + fun retrieve(fileId: String): DetailRetrieveResponse = + retrieve(fileId, DetailRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: DetailRetrieveParams = DetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DetailRetrieveResponse = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: DetailRetrieveParams = DetailRetrieveParams.none(), + ): DetailRetrieveResponse = retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: DetailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DetailRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: DetailRetrieveParams): DetailRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(fileId: String, requestOptions: RequestOptions): DetailRetrieveResponse = + retrieve(fileId, DetailRetrieveParams.none(), requestOptions) + + /** + * 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): DetailUpdateResponse = update(fileId, DetailUpdateParams.none()) + + /** @see update */ + fun update( + fileId: String, + params: DetailUpdateParams = DetailUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DetailUpdateResponse = update(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see update */ + fun update( + fileId: String, + params: DetailUpdateParams = DetailUpdateParams.none(), + ): DetailUpdateResponse = update(fileId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: DetailUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DetailUpdateResponse + + /** @see update */ + fun update(params: DetailUpdateParams): DetailUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(fileId: String, requestOptions: RequestOptions): DetailUpdateResponse = + update(fileId, DetailUpdateParams.none(), requestOptions) + + /** A view of [DetailService] 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): DetailService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the + * same as [DetailService.retrieve]. + */ + @MustBeClosed + fun retrieve(fileId: String): HttpResponseFor = + retrieve(fileId, DetailRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + params: DetailRetrieveParams = DetailRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + params: DetailRetrieveParams = DetailRetrieveParams.none(), + ): HttpResponseFor = retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: DetailRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: DetailRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(fileId, DetailRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the + * same as [DetailService.update]. + */ + @MustBeClosed + fun update(fileId: String): HttpResponseFor = + update(fileId, DetailUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + fileId: String, + params: DetailUpdateParams = DetailUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + fileId: String, + params: DetailUpdateParams = DetailUpdateParams.none(), + ): HttpResponseFor = update(fileId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: DetailUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: DetailUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + fileId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(fileId, DetailUpdateParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailServiceImpl.kt new file mode 100644 index 00000000..711fa353 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailServiceImpl.kt @@ -0,0 +1,126 @@ +// 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.details.DetailRetrieveParams +import com.imagekit.api.models.files.details.DetailRetrieveResponse +import com.imagekit.api.models.files.details.DetailUpdateParams +import com.imagekit.api.models.files.details.DetailUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DetailServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DetailService { + + private val withRawResponse: DetailService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DetailService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DetailService = + DetailServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: DetailRetrieveParams, + requestOptions: RequestOptions, + ): DetailRetrieveResponse = + // get /v1/files/{fileId}/details + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: DetailUpdateParams, + requestOptions: RequestOptions, + ): DetailUpdateResponse = + // patch /v1/files/{fileId}/details + withRawResponse().update(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DetailService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): DetailService.WithRawResponse = + DetailServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: DetailRetrieveParams, + 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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: DetailUpdateParams, + 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() + } + } + } + } + } +} 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..b2df43ae --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt @@ -0,0 +1,149 @@ +// 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.MetadataFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataFromUrlResponse +import com.imagekit.api.models.files.metadata.MetadataRetrieveParams +import com.imagekit.api.models.files.metadata.MetadataRetrieveResponse +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 retrieve(fileId: String): MetadataRetrieveResponse = + retrieve(fileId, MetadataRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MetadataRetrieveResponse = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + ): MetadataRetrieveResponse = retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: MetadataRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MetadataRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: MetadataRetrieveParams): MetadataRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(fileId: String, requestOptions: RequestOptions): MetadataRetrieveResponse = + retrieve(fileId, MetadataRetrieveParams.none(), requestOptions) + + /** + * Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. + */ + fun fromUrl(params: MetadataFromUrlParams): MetadataFromUrlResponse = + fromUrl(params, RequestOptions.none()) + + /** @see fromUrl */ + fun fromUrl( + params: MetadataFromUrlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MetadataFromUrlResponse + + /** 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.retrieve]. + */ + @MustBeClosed + fun retrieve(fileId: String): HttpResponseFor = + retrieve(fileId, MetadataRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + ): HttpResponseFor = + retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: MetadataRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: MetadataRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(fileId, MetadataRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/files/metadata`, but is otherwise the same as + * [MetadataService.fromUrl]. + */ + @MustBeClosed + fun fromUrl(params: MetadataFromUrlParams): HttpResponseFor = + fromUrl(params, RequestOptions.none()) + + /** @see fromUrl */ + @MustBeClosed + fun fromUrl( + params: MetadataFromUrlParams, + 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..c23bd1c4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt @@ -0,0 +1,121 @@ +// 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.MetadataFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataFromUrlResponse +import com.imagekit.api.models.files.metadata.MetadataRetrieveParams +import com.imagekit.api.models.files.metadata.MetadataRetrieveResponse +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 retrieve( + params: MetadataRetrieveParams, + requestOptions: RequestOptions, + ): MetadataRetrieveResponse = + // get /v1/files/{fileId}/metadata + withRawResponse().retrieve(params, requestOptions).parse() + + override fun fromUrl( + params: MetadataFromUrlParams, + requestOptions: RequestOptions, + ): MetadataFromUrlResponse = + // get /v1/files/metadata + withRawResponse().fromUrl(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 retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: MetadataRetrieveParams, + 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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fromUrlHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun fromUrl( + params: MetadataFromUrlParams, + 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 { fromUrlHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeService.kt new file mode 100644 index 00000000..b21ba504 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeService.kt @@ -0,0 +1,141 @@ +// 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.purge.PurgeExecuteParams +import com.imagekit.api.models.files.purge.PurgeExecuteResponse +import com.imagekit.api.models.files.purge.PurgeStatusParams +import com.imagekit.api.models.files.purge.PurgeStatusResponse +import java.util.function.Consumer + +interface PurgeService { + + /** + * 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): PurgeService + + /** + * 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 execute(params: PurgeExecuteParams): PurgeExecuteResponse = + execute(params, RequestOptions.none()) + + /** @see execute */ + fun execute( + params: PurgeExecuteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PurgeExecuteResponse + + /** This API returns the status of a purge cache request. */ + fun status(requestId: String): PurgeStatusResponse = status(requestId, PurgeStatusParams.none()) + + /** @see status */ + fun status( + requestId: String, + params: PurgeStatusParams = PurgeStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PurgeStatusResponse = status(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see status */ + fun status( + requestId: String, + params: PurgeStatusParams = PurgeStatusParams.none(), + ): PurgeStatusResponse = status(requestId, params, RequestOptions.none()) + + /** @see status */ + fun status( + params: PurgeStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PurgeStatusResponse + + /** @see status */ + fun status(params: PurgeStatusParams): PurgeStatusResponse = + status(params, RequestOptions.none()) + + /** @see status */ + fun status(requestId: String, requestOptions: RequestOptions): PurgeStatusResponse = + status(requestId, PurgeStatusParams.none(), requestOptions) + + /** A view of [PurgeService] 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): PurgeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/files/purge`, but is otherwise the same as + * [PurgeService.execute]. + */ + @MustBeClosed + fun execute(params: PurgeExecuteParams): HttpResponseFor = + execute(params, RequestOptions.none()) + + /** @see execute */ + @MustBeClosed + fun execute( + params: PurgeExecuteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/files/purge/{requestId}`, but is otherwise the + * same as [PurgeService.status]. + */ + @MustBeClosed + fun status(requestId: String): HttpResponseFor = + status(requestId, PurgeStatusParams.none()) + + /** @see status */ + @MustBeClosed + fun status( + requestId: String, + params: PurgeStatusParams = PurgeStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + status(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see status */ + @MustBeClosed + fun status( + requestId: String, + params: PurgeStatusParams = PurgeStatusParams.none(), + ): HttpResponseFor = status(requestId, params, RequestOptions.none()) + + /** @see status */ + @MustBeClosed + fun status( + params: PurgeStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see status */ + @MustBeClosed + fun status(params: PurgeStatusParams): HttpResponseFor = + status(params, RequestOptions.none()) + + /** @see status */ + @MustBeClosed + fun status( + requestId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + status(requestId, PurgeStatusParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceImpl.kt new file mode 100644 index 00000000..0b1a8cc2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceImpl.kt @@ -0,0 +1,123 @@ +// 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.purge.PurgeExecuteParams +import com.imagekit.api.models.files.purge.PurgeExecuteResponse +import com.imagekit.api.models.files.purge.PurgeStatusParams +import com.imagekit.api.models.files.purge.PurgeStatusResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PurgeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PurgeService { + + private val withRawResponse: PurgeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PurgeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): PurgeService = + PurgeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun execute( + params: PurgeExecuteParams, + requestOptions: RequestOptions, + ): PurgeExecuteResponse = + // post /v1/files/purge + withRawResponse().execute(params, requestOptions).parse() + + override fun status( + params: PurgeStatusParams, + requestOptions: RequestOptions, + ): PurgeStatusResponse = + // get /v1/files/purge/{requestId} + withRawResponse().status(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PurgeService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): PurgeService.WithRawResponse = + PurgeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val executeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun execute( + params: PurgeExecuteParams, + 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 { executeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val statusHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun status( + params: PurgeStatusParams, + 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 { statusHandler.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..12ab91ab --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionService.kt @@ -0,0 +1,282 @@ +// 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.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionDeleteResponse +import com.imagekit.api.models.files.versions.VersionListParams +import com.imagekit.api.models.files.versions.VersionListResponse +import com.imagekit.api.models.files.versions.VersionRestoreParams +import com.imagekit.api.models.files.versions.VersionRestoreResponse +import com.imagekit.api.models.files.versions.VersionRetrieveParams +import com.imagekit.api.models.files.versions.VersionRetrieveResponse +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 an object with details or attributes of a file version. */ + fun retrieve(versionId: String, params: VersionRetrieveParams): VersionRetrieveResponse = + retrieve(versionId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + versionId: String, + params: VersionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionRetrieveResponse = + retrieve(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: VersionRetrieveParams): VersionRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: VersionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionRetrieveResponse + + /** 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 restores a file version as the current file version. */ + fun restore(versionId: String, params: VersionRestoreParams): VersionRestoreResponse = + restore(versionId, params, RequestOptions.none()) + + /** @see restore */ + fun restore( + versionId: String, + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionRestoreResponse = + restore(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see restore */ + fun restore(params: VersionRestoreParams): VersionRestoreResponse = + restore(params, RequestOptions.none()) + + /** @see restore */ + fun restore( + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionRestoreResponse + + /** 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/{versionId}`, but is + * otherwise the same as [VersionService.retrieve]. + */ + @MustBeClosed + fun retrieve( + versionId: String, + params: VersionRetrieveParams, + ): HttpResponseFor = + retrieve(versionId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + versionId: String, + params: VersionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: VersionRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: VersionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * 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 `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..781339e4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -0,0 +1,224 @@ +// 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.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionDeleteResponse +import com.imagekit.api.models.files.versions.VersionListParams +import com.imagekit.api.models.files.versions.VersionListResponse +import com.imagekit.api.models.files.versions.VersionRestoreParams +import com.imagekit.api.models.files.versions.VersionRestoreResponse +import com.imagekit.api.models.files.versions.VersionRetrieveParams +import com.imagekit.api.models.files.versions.VersionRetrieveResponse +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 retrieve( + params: VersionRetrieveParams, + requestOptions: RequestOptions, + ): VersionRetrieveResponse = + // get /v1/files/{fileId}/versions/{versionId} + withRawResponse().retrieve(params, requestOptions).parse() + + 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 restore( + params: VersionRestoreParams, + requestOptions: RequestOptions, + ): VersionRestoreResponse = + // 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 retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: VersionRetrieveParams, + 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 { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + 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 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/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/accounts/AccountGetUsageParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParamsTest.kt new file mode 100644 index 00000000..86891087 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParamsTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts + +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 AccountGetUsageParamsTest { + + @Test + fun create() { + AccountGetUsageParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun queryParams() { + val params = + AccountGetUsageParams.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/AccountGetUsageResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponseTest.kt new file mode 100644 index 00000000..6c469ac8 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponseTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts + +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 AccountGetUsageResponseTest { + + @Test + fun create() { + val accountGetUsageResponse = + AccountGetUsageResponse.builder() + .bandwidthBytes(0L) + .extensionUnitsCount(0L) + .mediaLibraryStorageBytes(0L) + .originalCacheStorageBytes(0L) + .videoProcessingUnitsCount(0L) + .build() + + assertThat(accountGetUsageResponse.bandwidthBytes()).contains(0L) + assertThat(accountGetUsageResponse.extensionUnitsCount()).contains(0L) + assertThat(accountGetUsageResponse.mediaLibraryStorageBytes()).contains(0L) + assertThat(accountGetUsageResponse.originalCacheStorageBytes()).contains(0L) + assertThat(accountGetUsageResponse.videoProcessingUnitsCount()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accountGetUsageResponse = + AccountGetUsageResponse.builder() + .bandwidthBytes(0L) + .extensionUnitsCount(0L) + .mediaLibraryStorageBytes(0L) + .originalCacheStorageBytes(0L) + .videoProcessingUnitsCount(0L) + .build() + + val roundtrippedAccountGetUsageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountGetUsageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountGetUsageResponse).isEqualTo(accountGetUsageResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParamsTest.kt new file mode 100644 index 00000000..125e0d4a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkJobCopyFolderParamsTest { + + @Test + fun create() { + BulkJobCopyFolderParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .includeVersions(true) + .build() + } + + @Test + fun body() { + val params = + BulkJobCopyFolderParams.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 = + BulkJobCopyFolderParams.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/bulkjobs/BulkJobCopyFolderResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponseTest.kt new file mode 100644 index 00000000..4038db3e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +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 BulkJobCopyFolderResponseTest { + + @Test + fun create() { + val bulkJobCopyFolderResponse = BulkJobCopyFolderResponse.builder().jobId("jobId").build() + + assertThat(bulkJobCopyFolderResponse.jobId()).contains("jobId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkJobCopyFolderResponse = BulkJobCopyFolderResponse.builder().jobId("jobId").build() + + val roundtrippedBulkJobCopyFolderResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkJobCopyFolderResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkJobCopyFolderResponse).isEqualTo(bulkJobCopyFolderResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParamsTest.kt new file mode 100644 index 00000000..abfc5e5b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkJobMoveFolderParamsTest { + + @Test + fun create() { + BulkJobMoveFolderParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .build() + } + + @Test + fun body() { + val params = + BulkJobMoveFolderParams.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/bulkjobs/BulkJobMoveFolderResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponseTest.kt new file mode 100644 index 00000000..836bde09 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +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 BulkJobMoveFolderResponseTest { + + @Test + fun create() { + val bulkJobMoveFolderResponse = BulkJobMoveFolderResponse.builder().jobId("jobId").build() + + assertThat(bulkJobMoveFolderResponse.jobId()).contains("jobId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkJobMoveFolderResponse = BulkJobMoveFolderResponse.builder().jobId("jobId").build() + + val roundtrippedBulkJobMoveFolderResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkJobMoveFolderResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkJobMoveFolderResponse).isEqualTo(bulkJobMoveFolderResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParamsTest.kt new file mode 100644 index 00000000..487b192e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkJobRetrieveStatusParamsTest { + + @Test + fun create() { + BulkJobRetrieveStatusParams.builder().jobId("jobId").build() + } + + @Test + fun pathParams() { + val params = BulkJobRetrieveStatusParams.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/bulkjobs/BulkJobRetrieveStatusResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponseTest.kt new file mode 100644 index 00000000..5b4f7ca8 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponseTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.bulkjobs + +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 BulkJobRetrieveStatusResponseTest { + + @Test + fun create() { + val bulkJobRetrieveStatusResponse = + BulkJobRetrieveStatusResponse.builder() + .jobId("5d5b1a9b4c8c4c0001f3e4a2") + .status("Completed") + .type("COPY_FOLDER") + .build() + + assertThat(bulkJobRetrieveStatusResponse.jobId()).contains("5d5b1a9b4c8c4c0001f3e4a2") + assertThat(bulkJobRetrieveStatusResponse.status()).contains("Completed") + assertThat(bulkJobRetrieveStatusResponse.type()).contains("COPY_FOLDER") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkJobRetrieveStatusResponse = + BulkJobRetrieveStatusResponse.builder() + .jobId("5d5b1a9b4c8c4c0001f3e4a2") + .status("Completed") + .type("COPY_FOLDER") + .build() + + val roundtrippedBulkJobRetrieveStatusResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkJobRetrieveStatusResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkJobRetrieveStatusResponse) + .isEqualTo(bulkJobRetrieveStatusResponse) + } +} 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/CustomMetadataFieldCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt new file mode 100644 index 00000000..0fa0ea81 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt @@ -0,0 +1,131 @@ +// 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 CustomMetadataFieldCreateResponseTest { + + @Test + fun create() { + val customMetadataFieldCreateResponse = + CustomMetadataFieldCreateResponse.builder() + .id("id") + .label("label") + .name("name") + .schema( + CustomMetadataFieldCreateResponse.Schema.builder() + .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber( + 30.0 + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber( + 40.0 + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + assertThat(customMetadataFieldCreateResponse.id()).isEqualTo("id") + assertThat(customMetadataFieldCreateResponse.label()).isEqualTo("label") + assertThat(customMetadataFieldCreateResponse.name()).isEqualTo("name") + assertThat(customMetadataFieldCreateResponse.schema()) + .isEqualTo( + CustomMetadataFieldCreateResponse.Schema.builder() + .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString("small"), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString("large"), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customMetadataFieldCreateResponse = + CustomMetadataFieldCreateResponse.builder() + .id("id") + .label("label") + .name("name") + .schema( + CustomMetadataFieldCreateResponse.Schema.builder() + .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber( + 30.0 + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber( + 40.0 + ), + CustomMetadataFieldCreateResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + val roundtrippedCustomMetadataFieldCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customMetadataFieldCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomMetadataFieldCreateResponse) + .isEqualTo(customMetadataFieldCreateResponse) + } +} 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/CustomMetadataFieldListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt new file mode 100644 index 00000000..6dd28045 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt @@ -0,0 +1,121 @@ +// 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 CustomMetadataFieldListResponseTest { + + @Test + fun create() { + val customMetadataFieldListResponse = + CustomMetadataFieldListResponse.builder() + .id("id") + .label("label") + .name("name") + .schema( + CustomMetadataFieldListResponse.Schema.builder() + .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldListResponse.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldListResponse.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldListResponse.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldListResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + assertThat(customMetadataFieldListResponse.id()).isEqualTo("id") + assertThat(customMetadataFieldListResponse.label()).isEqualTo("label") + assertThat(customMetadataFieldListResponse.name()).isEqualTo("name") + assertThat(customMetadataFieldListResponse.schema()) + .isEqualTo( + CustomMetadataFieldListResponse.Schema.builder() + .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldListResponse.Schema.SelectOption.ofString("small"), + CustomMetadataFieldListResponse.Schema.SelectOption.ofString("medium"), + CustomMetadataFieldListResponse.Schema.SelectOption.ofString("large"), + CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldListResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customMetadataFieldListResponse = + CustomMetadataFieldListResponse.builder() + .id("id") + .label("label") + .name("name") + .schema( + CustomMetadataFieldListResponse.Schema.builder() + .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldListResponse.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldListResponse.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldListResponse.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldListResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + val roundtrippedCustomMetadataFieldListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customMetadataFieldListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomMetadataFieldListResponse) + .isEqualTo(customMetadataFieldListResponse) + } +} 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/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt new file mode 100644 index 00000000..2ce6e88a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt @@ -0,0 +1,131 @@ +// 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 CustomMetadataFieldUpdateResponseTest { + + @Test + fun create() { + val customMetadataFieldUpdateResponse = + CustomMetadataFieldUpdateResponse.builder() + .id("id") + .label("label") + .name("name") + .schema( + CustomMetadataFieldUpdateResponse.Schema.builder() + .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber( + 30.0 + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber( + 40.0 + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + assertThat(customMetadataFieldUpdateResponse.id()).isEqualTo("id") + assertThat(customMetadataFieldUpdateResponse.label()).isEqualTo("label") + assertThat(customMetadataFieldUpdateResponse.name()).isEqualTo("name") + assertThat(customMetadataFieldUpdateResponse.schema()) + .isEqualTo( + CustomMetadataFieldUpdateResponse.Schema.builder() + .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString("small"), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString("large"), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customMetadataFieldUpdateResponse = + CustomMetadataFieldUpdateResponse.builder() + .id("id") + .label("label") + .name("name") + .schema( + CustomMetadataFieldUpdateResponse.Schema.builder() + .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber( + 30.0 + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber( + 40.0 + ), + CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + val roundtrippedCustomMetadataFieldUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customMetadataFieldUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomMetadataFieldUpdateResponse) + .isEqualTo(customMetadataFieldUpdateResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifDetailsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifDetailsTest.kt new file mode 100644 index 00000000..bb999288 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifDetailsTest.kt @@ -0,0 +1,113 @@ +// 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 ExifDetailsTest { + + @Test + fun create() { + val exifDetails = + ExifDetails.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() + + assertThat(exifDetails.apertureValue()).contains(0.0) + assertThat(exifDetails.colorSpace()).contains(0L) + assertThat(exifDetails.createDate()).contains("CreateDate") + assertThat(exifDetails.customRendered()).contains(0L) + assertThat(exifDetails.dateTimeOriginal()).contains("DateTimeOriginal") + assertThat(exifDetails.exifImageHeight()).contains(0L) + assertThat(exifDetails.exifImageWidth()).contains(0L) + assertThat(exifDetails.exifVersion()).contains("ExifVersion") + assertThat(exifDetails.exposureCompensation()).contains(0.0) + assertThat(exifDetails.exposureMode()).contains(0L) + assertThat(exifDetails.exposureProgram()).contains(0L) + assertThat(exifDetails.exposureTime()).contains(0.0) + assertThat(exifDetails.flash()).contains(0L) + assertThat(exifDetails.flashpixVersion()).contains("FlashpixVersion") + assertThat(exifDetails.fNumber()).contains(0.0) + assertThat(exifDetails.focalLength()).contains(0L) + assertThat(exifDetails.focalPlaneResolutionUnit()).contains(0L) + assertThat(exifDetails.focalPlaneXResolution()).contains(0.0) + assertThat(exifDetails.focalPlaneYResolution()).contains(0.0) + assertThat(exifDetails.interopOffset()).contains(0L) + assertThat(exifDetails.iso()).contains(0L) + assertThat(exifDetails.meteringMode()).contains(0L) + assertThat(exifDetails.sceneCaptureType()).contains(0L) + assertThat(exifDetails.shutterSpeedValue()).contains(0.0) + assertThat(exifDetails.subSecTime()).contains("SubSecTime") + assertThat(exifDetails.whiteBalance()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exifDetails = + ExifDetails.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() + + val roundtrippedExifDetails = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exifDetails), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExifDetails).isEqualTo(exifDetails) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifImageTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifImageTest.kt new file mode 100644 index 00000000..19d1e50e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifImageTest.kt @@ -0,0 +1,68 @@ +// 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 ExifImageTest { + + @Test + fun create() { + val exifImage = + ExifImage.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + + assertThat(exifImage.exifOffset()).contains(0L) + assertThat(exifImage.gpsInfo()).contains(0L) + assertThat(exifImage.make()).contains("Make") + assertThat(exifImage.model()).contains("Model") + assertThat(exifImage.modifyDate()).contains("ModifyDate") + assertThat(exifImage.orientation()).contains(0L) + assertThat(exifImage.resolutionUnit()).contains(0L) + assertThat(exifImage.software()).contains("Software") + assertThat(exifImage.xResolution()).contains(0L) + assertThat(exifImage.yCbCrPositioning()).contains(0L) + assertThat(exifImage.yResolution()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exifImage = + ExifImage.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + + val roundtrippedExifImage = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exifImage), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExifImage).isEqualTo(exifImage) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsParamsTest.kt new file mode 100644 index 00000000..9d69b7e3 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsParamsTest.kt @@ -0,0 +1,34 @@ +// 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 FileAddTagsParamsTest { + + @Test + fun create() { + FileAddTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + } + + @Test + fun body() { + val params = + FileAddTagsParams.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/FileAddTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsResponseTest.kt new file mode 100644 index 00000000..02f7e41d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsResponseTest.kt @@ -0,0 +1,36 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileAddTagsResponseTest { + + @Test + fun create() { + val fileAddTagsResponse = + FileAddTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + assertThat(fileAddTagsResponse.successfullyUpdatedFileIds().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileAddTagsResponse = + FileAddTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + val roundtrippedFileAddTagsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileAddTagsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileAddTagsResponse).isEqualTo(fileAddTagsResponse) + } +} 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/FileListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListParamsTest.kt new file mode 100644 index 00000000..98a14d38 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.imagekit.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileListParamsTest { + + @Test + fun create() { + FileListParams.builder() + .fileType("fileType") + .limit("limit") + .path("path") + .searchQuery("searchQuery") + .skip("skip") + .sort("sort") + .type(FileListParams.Type.FILE) + .build() + } + + @Test + fun queryParams() { + val params = + FileListParams.builder() + .fileType("fileType") + .limit("limit") + .path("path") + .searchQuery("searchQuery") + .skip("skip") + .sort("sort") + .type(FileListParams.Type.FILE) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("fileType", "fileType") + .put("limit", "limit") + .put("path", "path") + .put("searchQuery", "searchQuery") + .put("skip", "skip") + .put("sort", "sort") + .put("type", "file") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = FileListParams.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/files/FileListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListResponseTest.kt new file mode 100644 index 00000000..10b34caf --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListResponseTest.kt @@ -0,0 +1,121 @@ +// 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 FileListResponseTest { + + @Test + fun create() { + val fileListResponse = + FileListResponse.builder() + .addAiTag( + FileListResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo(FileListResponse.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .build() + + assertThat(fileListResponse.aiTags().getOrNull()) + .containsExactly( + FileListResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(fileListResponse.createdAt()).contains("createdAt") + assertThat(fileListResponse.customCoordinates()).contains("customCoordinates") + assertThat(fileListResponse._customMetadata()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(fileListResponse.fileId()).contains("fileId") + assertThat(fileListResponse.filePath()).contains("filePath") + assertThat(fileListResponse.fileType()).contains("fileType") + assertThat(fileListResponse.hasAlpha()).contains(true) + assertThat(fileListResponse.height()).contains(0.0) + assertThat(fileListResponse.isPrivateFile()).contains(true) + assertThat(fileListResponse.isPublished()).contains(true) + assertThat(fileListResponse.mime()).contains("mime") + assertThat(fileListResponse.name()).contains("name") + assertThat(fileListResponse.size()).contains(0.0) + assertThat(fileListResponse.tags().getOrNull()).containsExactly("string") + assertThat(fileListResponse.thumbnail()).contains("thumbnail") + assertThat(fileListResponse.type()).contains("type") + assertThat(fileListResponse.updatedAt()).contains("updatedAt") + assertThat(fileListResponse.url()).contains("url") + assertThat(fileListResponse.versionInfo()) + .contains(FileListResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileListResponse.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileListResponse = + FileListResponse.builder() + .addAiTag( + FileListResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo(FileListResponse.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .build() + + val roundtrippedFileListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileListResponse).isEqualTo(fileListResponse) + } +} 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/FileRemoveAiTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParamsTest.kt new file mode 100644 index 00000000..a516a53d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParamsTest.kt @@ -0,0 +1,34 @@ +// 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 FileRemoveAiTagsParamsTest { + + @Test + fun create() { + FileRemoveAiTagsParams.builder() + .aiTags(listOf("t-shirt", "round-neck", "sale2019")) + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + } + + @Test + fun body() { + val params = + FileRemoveAiTagsParams.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/FileRemoveAiTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponseTest.kt new file mode 100644 index 00000000..ae58571c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponseTest.kt @@ -0,0 +1,36 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileRemoveAiTagsResponseTest { + + @Test + fun create() { + val fileRemoveAiTagsResponse = + FileRemoveAiTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + assertThat(fileRemoveAiTagsResponse.successfullyUpdatedFileIds().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileRemoveAiTagsResponse = + FileRemoveAiTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + val roundtrippedFileRemoveAiTagsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileRemoveAiTagsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileRemoveAiTagsResponse).isEqualTo(fileRemoveAiTagsResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsParamsTest.kt new file mode 100644 index 00000000..a3293050 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsParamsTest.kt @@ -0,0 +1,34 @@ +// 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 FileRemoveTagsParamsTest { + + @Test + fun create() { + FileRemoveTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + } + + @Test + fun body() { + val params = + FileRemoveTagsParams.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/FileRemoveTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponseTest.kt new file mode 100644 index 00000000..314af3ce --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponseTest.kt @@ -0,0 +1,36 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileRemoveTagsResponseTest { + + @Test + fun create() { + val fileRemoveTagsResponse = + FileRemoveTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + assertThat(fileRemoveTagsResponse.successfullyUpdatedFileIds().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileRemoveTagsResponse = + FileRemoveTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + val roundtrippedFileRemoveTagsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileRemoveTagsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileRemoveTagsResponse).isEqualTo(fileRemoveTagsResponse) + } +} 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/FileUploadV1ParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ParamsTest.kt new file mode 100644 index 00000000..2851c583 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ParamsTest.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +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 FileUploadV1ParamsTest { + + @Test + fun create() { + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata("\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n") + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .build() + } + + @Test + fun body() { + val params = + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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("https://www.example.com/rest-of-the-image-path.jpg"), + "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( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ), + "expire" to MultipartField.of("expire"), + "extensions" to + MultipartField.of( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ), + "folder" to MultipartField.of("folder"), + "isPrivateFile" to MultipartField.of(FileUploadV1Params.IsPrivateFile.TRUE), + "isPublished" to MultipartField.of(FileUploadV1Params.IsPublished.TRUE), + "overwriteAITags" to + MultipartField.of(FileUploadV1Params.OverwriteAiTags.TRUE), + "overwriteCustomMetadata" to + MultipartField.of(FileUploadV1Params.OverwriteCustomMetadata.TRUE), + "overwriteFile" to MultipartField.of("overwriteFile"), + "overwriteTags" to MultipartField.of(FileUploadV1Params.OverwriteTags.TRUE), + "publicKey" to MultipartField.of("publicKey"), + "responseFields" to MultipartField.of("responseFields"), + "signature" to MultipartField.of("signature"), + "tags" to MultipartField.of("t-shirt,round-neck,men"), + "transformation" to + MultipartField.of( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ), + "useUniqueFileName" to + MultipartField.of(FileUploadV1Params.UseUniqueFileName.TRUE), + "webhookUrl" to MultipartField.of("webhookUrl"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .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("https://www.example.com/rest-of-the-image-path.jpg"), + "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/FileUploadV1ResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ResponseTest.kt new file mode 100644 index 00000000..c5efd039 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ResponseTest.kt @@ -0,0 +1,1335 @@ +// 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 FileUploadV1ResponseTest { + + @Test + fun create() { + val fileUploadV1Response = + FileUploadV1Response.builder() + .addAiTag( + FileUploadV1Response.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .duration(0L) + .embeddedMetadata( + FileUploadV1Response.EmbeddedMetadata.builder() + .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") + .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") + .aboutCvTermName("CV-Term Name 1 (ref2019.1)") + .aboutCvTermRefinedAbout( + "http://example.com/cv/refinements2/ref2019.1/codeX145" + ) + .additionalModelInformation("Additional Model Info (ref2019.1)") + .applicationRecordVersion(4L) + .artist("Creator1 (ref2019.1)") + .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") + .artworkContentDescription("AO Content Description 1 (ref2019.1)") + .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") + .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") + .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") + .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") + .addArtworkCreator("AO Creator Name 1a (ref2019.1)") + .addArtworkCreator("AO Creator Name 1b (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") + .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) + .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") + .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") + .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") + .artworkSource("AO Source 1 (ref2019.1)") + .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") + .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") + .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") + .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") + .artworkTitle("AO Title 1 (ref2019.1)") + .authorsPosition("Creator's Job Title (ref2019.1)") + .byline("Creator1 (ref2019.1)") + .bylineTitle("Creator's Job Title (ref2019.1)") + .caption("The description aka caption (ref2019.1)") + .captionAbstract("The description aka caption (ref2019.1)") + .captionWriter("Description Writer (ref2019.1)") + .city("City (Core) (ref2019.1)") + .colorSpace("Uncalibrated") + .componentsConfiguration("Y,Cb,Cr,-") + .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .copyrightNotice( + "Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)" + ) + .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") + .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") + .country("Country (Core) (ref2019.1)") + .countryCode("R19") + .countryPrimaryLocationCode("R19") + .countryPrimaryLocationName("Country (Core) (ref2019.1)") + .creator("Creator1 (ref2019.1)") + .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") + .creatorCity("Creator's CI: City (ref2019.1)") + .creatorCountry("Creator's CI: Country (ref2019.1)") + .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") + .creatorRegion("Creator's CI: State/Province (ref2019.1)") + .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") + .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") + .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") + .credit("Credit Line (ref2019.1)") + .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) + .description("The description aka caption (ref2019.1)") + .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") + .digitalSourceType( + "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" + ) + .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") + .embeddedEncodedRightsExprLangId( + "http://example.org/RELids/id4711/ref2019.1" + ) + .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .event("An Event (ref2019.1)") + .exifVersion("0232") + .flashpixVersion("0100") + .genreCvId("http://example.com/cv/genre/ref2019.1") + .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") + .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") + .genreCvTermRefinedAbout( + "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" + ) + .headline("The Headline (ref2019.1)") + .imageCreatorId("Image Creator Id 1 (ref2019.1)") + .imageCreatorImageId("Image Creator Image ID (ref2019.1)") + .imageCreatorName("Image Creator Name 1 (ref2019.1)") + .imageDescription("The description aka caption (ref2019.1)") + .addImageRegionBoundaryH(0.385) + .addImageRegionBoundaryRx(0.068) + .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) + .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) + .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) + .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) + .addImageRegionBoundaryW(0.127) + .addImageRegionBoundaryX(0.31) + .addImageRegionBoundaryX(0.59) + .addImageRegionBoundaryY(0.18) + .addImageRegionBoundaryY(0.426) + .imageRegionCtypeIdentifier( + listOf( + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + ) + ) + .imageRegionCtypeName( + listOf( + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + ) + ) + .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) + .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) + .imageRegionOrganisationInImageName( + listOf( + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr3 (ref2019.1)", + ) + ) + .imageRegionPersonInImage( + listOf( + "Person name no 1 in region persltr2 (ref2019.1)", + "Person name no 1 in region persltr3 (ref2019.1)", + "Person name no 1 in region persltr1 (ref2019.1)", + ) + ) + .imageRegionRoleIdentifier( + listOf( + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + ) + ) + .imageRegionRoleName( + listOf( + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + ) + ) + .imageSupplierId("Image Supplier Id (ref2019.1)") + .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") + .imageSupplierName("Image Supplier Name (ref2019.1)") + .instructions("An Instruction (ref2019.1)") + .intellectualGenre("A Genre (ref2019.1)") + .keywords( + listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") + ) + .addLicensorCity("Licensor City 1 (ref2019.1)") + .addLicensorCity("Licensor City 2 (ref2019.1)") + .addLicensorCountry("Licensor Country 1 (ref2019.1)") + .addLicensorCountry("Licensor Country 2 (ref2019.1)") + .addLicensorEmail("Licensor Email 1 (ref2019.1)") + .addLicensorEmail("Licensor Email 2 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") + .addLicensorId("Licensor ID 1 (ref2019.1)") + .addLicensorId("Licensor ID 2 (ref2019.1)") + .addLicensorName("Licensor Name 1 (ref2019.1)") + .addLicensorName("Licensor Name 2 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") + .addLicensorRegion("Licensor Region 1 (ref2019.1)") + .addLicensorRegion("Licensor Region 2 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") + .addLicensorUrl("Licensor URL 1 (ref2019.1)") + .addLicensorUrl("Licensor URL 2 (ref2019.1)") + .linkedEncodedRightsExpr( + "http://example.org/linkedrightsexpression/id986/ref2019.1" + ) + .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") + .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .location("Sublocation (Core) (ref2019.1)") + .locationCreatedCity("City (Location created1) (ref2019.1)") + .locationCreatedCountryCode("R17") + .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") + .locationCreatedGpsAltitude("480 m") + .locationCreatedGpsLatitude("48,16.5N") + .locationCreatedGpsLongitude("16,20.28E") + .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") + .locationCreatedLocationName( + "Location Name (Location created1) (ref2019.1)" + ) + .locationCreatedProvinceState( + "Province/State (Location created1) (ref2019.1)" + ) + .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") + .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") + .addLocationShownCity("City (Location shown1) (ref2019.1)") + .addLocationShownCity("City (Location shown2) (ref2019.1)") + .addLocationShownCountryCode("R17") + .addLocationShownCountryCode("R17") + .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") + .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") + .addLocationShownGpsAltitude("140 m") + .addLocationShownGpsAltitude("120 m") + .addLocationShownGpsLatitude("48,8.82N") + .addLocationShownGpsLatitude("47,57.12N") + .addLocationShownGpsLongitude("17,5.88E") + .addLocationShownGpsLongitude("16,49.8E") + .locationShownLocationId( + listOf( + "Location Id 1a(Location shown1) (ref2019.1)", + "Location Id 1b(Location shown1) (ref2019.1)", + "Location Id 2a(Location shown2) (ref2019.1)", + "Location Id 2b(Location shown2) (ref2019.1)", + ) + ) + .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") + .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") + .addLocationShownProvinceState( + "Province/State (Location shown1) (ref2019.1)" + ) + .addLocationShownProvinceState( + "Province/State (Location shown2) (ref2019.1)" + ) + .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") + .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") + .maxAvailHeight(20.0) + .maxAvailWidth(19.0) + .modelAge(listOf(25.0, 27.0, 30.0)) + .addModelReleaseId("Model Release ID 1 (ref2019.1)") + .addModelReleaseId("Model Release ID 2 (ref2019.1)") + .objectAttributeReference("A Genre (ref2019.1)") + .objectName("The Title (ref2019.1)") + .offsetTimeOriginal("+00:00") + .organisationInImageCode( + listOf( + "Organisation Code 1 (ref2019.1)", + "Organisation Code 2 (ref2019.1)", + "Organisation Code 3 (ref2019.1)", + ) + ) + .organisationInImageName( + listOf( + "Organisation Name 1 (ref2019.1)", + "Organisation Name 2 (ref2019.1)", + "Organisation Name 3 (ref2019.1)", + ) + ) + .orientation("Horizontal (normal)") + .originalTransmissionReference("Job Id (ref2019.1)") + .addPersonInImage("Person Shown 1 (ref2019.1)") + .addPersonInImage("Person Shown 2 (ref2019.1)") + .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") + .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") + .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") + .addPersonInImageCvTermRefinedAbout( + "http://example.com/cv/refinements987/codeY765/ref2019.1" + ) + .addPersonInImageDescription("Person Description 1 (ref2019.1)") + .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") + .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") + .addPersonInImageName("Person Name 1 (ref2019.1)") + .addProductInImageDescription("Product Description 1 (ref2019.1)") + .addProductInImageGtin(123456782019.1) + .addProductInImageName("Product Name 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") + .provinceState("Province/State(Core)(ref2019.1)") + .rating(1L) + .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") + .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") + .addRegistryItemId("Registry Image ID 1 (ref2019.1)") + .addRegistryItemId("Registry Image ID 2 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") + .resolutionUnit("inches") + .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .addScene("IPTC-Scene-Code1 (ref2019.1)") + .addScene("IPTC-Scene-Code2 (ref2019.1)") + .source("Source (ref2019.1)") + .specialInstructions("An Instruction (ref2019.1)") + .state("Province/State(Core)(ref2019.1)") + .subject( + listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") + ) + .subjectCode( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .subjectReference( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .sublocation("Sublocation (Core) (ref2019.1)") + .timeCreated("19:01:03+00:00") + .title("The Title (ref2019.1)") + .transmissionReference("Job Id (ref2019.1)") + .usageTerms("Rights Usage Terms (ref2019.1)") + .webStatement("http://www.WebStatementOfRights.org/2019.1") + .writer("Description Writer (ref2019.1)") + .writerEditor("Description Writer (ref2019.1)") + .xResolution(72.0) + .yResolution(72.0) + .build() + ) + .extensionStatus( + FileUploadV1Response.ExtensionStatus.builder() + .awsAutoTagging(FileUploadV1Response.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadV1Response.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadV1Response.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + FileUploadV1Response.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadV1Response.Metadata.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadV1Response.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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( + FileUploadV1Response.VersionInfo.builder().id("id").name("name").build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + + assertThat(fileUploadV1Response.aiTags().getOrNull()) + .containsExactly( + FileUploadV1Response.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(fileUploadV1Response.audioCodec()).contains("audioCodec") + assertThat(fileUploadV1Response.bitRate()).contains(0L) + assertThat(fileUploadV1Response.customCoordinates()).contains("customCoordinates") + assertThat(fileUploadV1Response._customMetadata()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(fileUploadV1Response.duration()).contains(0L) + assertThat(fileUploadV1Response.embeddedMetadata()) + .contains( + FileUploadV1Response.EmbeddedMetadata.builder() + .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") + .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") + .aboutCvTermName("CV-Term Name 1 (ref2019.1)") + .aboutCvTermRefinedAbout( + "http://example.com/cv/refinements2/ref2019.1/codeX145" + ) + .additionalModelInformation("Additional Model Info (ref2019.1)") + .applicationRecordVersion(4L) + .artist("Creator1 (ref2019.1)") + .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") + .artworkContentDescription("AO Content Description 1 (ref2019.1)") + .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") + .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") + .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") + .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") + .addArtworkCreator("AO Creator Name 1a (ref2019.1)") + .addArtworkCreator("AO Creator Name 1b (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") + .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) + .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") + .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") + .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") + .artworkSource("AO Source 1 (ref2019.1)") + .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") + .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") + .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") + .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") + .artworkTitle("AO Title 1 (ref2019.1)") + .authorsPosition("Creator's Job Title (ref2019.1)") + .byline("Creator1 (ref2019.1)") + .bylineTitle("Creator's Job Title (ref2019.1)") + .caption("The description aka caption (ref2019.1)") + .captionAbstract("The description aka caption (ref2019.1)") + .captionWriter("Description Writer (ref2019.1)") + .city("City (Core) (ref2019.1)") + .colorSpace("Uncalibrated") + .componentsConfiguration("Y,Cb,Cr,-") + .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .copyrightNotice("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") + .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") + .country("Country (Core) (ref2019.1)") + .countryCode("R19") + .countryPrimaryLocationCode("R19") + .countryPrimaryLocationName("Country (Core) (ref2019.1)") + .creator("Creator1 (ref2019.1)") + .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") + .creatorCity("Creator's CI: City (ref2019.1)") + .creatorCountry("Creator's CI: Country (ref2019.1)") + .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") + .creatorRegion("Creator's CI: State/Province (ref2019.1)") + .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") + .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") + .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") + .credit("Credit Line (ref2019.1)") + .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) + .description("The description aka caption (ref2019.1)") + .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") + .digitalSourceType( + "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" + ) + .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") + .embeddedEncodedRightsExprLangId("http://example.org/RELids/id4711/ref2019.1") + .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .event("An Event (ref2019.1)") + .exifVersion("0232") + .flashpixVersion("0100") + .genreCvId("http://example.com/cv/genre/ref2019.1") + .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") + .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") + .genreCvTermRefinedAbout( + "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" + ) + .headline("The Headline (ref2019.1)") + .imageCreatorId("Image Creator Id 1 (ref2019.1)") + .imageCreatorImageId("Image Creator Image ID (ref2019.1)") + .imageCreatorName("Image Creator Name 1 (ref2019.1)") + .imageDescription("The description aka caption (ref2019.1)") + .addImageRegionBoundaryH(0.385) + .addImageRegionBoundaryRx(0.068) + .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) + .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) + .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) + .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) + .addImageRegionBoundaryW(0.127) + .addImageRegionBoundaryX(0.31) + .addImageRegionBoundaryX(0.59) + .addImageRegionBoundaryY(0.18) + .addImageRegionBoundaryY(0.426) + .imageRegionCtypeIdentifier( + listOf( + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + ) + ) + .imageRegionCtypeName( + listOf( + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + ) + ) + .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) + .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) + .imageRegionOrganisationInImageName( + listOf( + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr3 (ref2019.1)", + ) + ) + .imageRegionPersonInImage( + listOf( + "Person name no 1 in region persltr2 (ref2019.1)", + "Person name no 1 in region persltr3 (ref2019.1)", + "Person name no 1 in region persltr1 (ref2019.1)", + ) + ) + .imageRegionRoleIdentifier( + listOf( + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + ) + ) + .imageRegionRoleName( + listOf( + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + ) + ) + .imageSupplierId("Image Supplier Id (ref2019.1)") + .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") + .imageSupplierName("Image Supplier Name (ref2019.1)") + .instructions("An Instruction (ref2019.1)") + .intellectualGenre("A Genre (ref2019.1)") + .keywords(listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1")) + .addLicensorCity("Licensor City 1 (ref2019.1)") + .addLicensorCity("Licensor City 2 (ref2019.1)") + .addLicensorCountry("Licensor Country 1 (ref2019.1)") + .addLicensorCountry("Licensor Country 2 (ref2019.1)") + .addLicensorEmail("Licensor Email 1 (ref2019.1)") + .addLicensorEmail("Licensor Email 2 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") + .addLicensorId("Licensor ID 1 (ref2019.1)") + .addLicensorId("Licensor ID 2 (ref2019.1)") + .addLicensorName("Licensor Name 1 (ref2019.1)") + .addLicensorName("Licensor Name 2 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") + .addLicensorRegion("Licensor Region 1 (ref2019.1)") + .addLicensorRegion("Licensor Region 2 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") + .addLicensorUrl("Licensor URL 1 (ref2019.1)") + .addLicensorUrl("Licensor URL 2 (ref2019.1)") + .linkedEncodedRightsExpr( + "http://example.org/linkedrightsexpression/id986/ref2019.1" + ) + .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") + .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .location("Sublocation (Core) (ref2019.1)") + .locationCreatedCity("City (Location created1) (ref2019.1)") + .locationCreatedCountryCode("R17") + .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") + .locationCreatedGpsAltitude("480 m") + .locationCreatedGpsLatitude("48,16.5N") + .locationCreatedGpsLongitude("16,20.28E") + .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") + .locationCreatedLocationName("Location Name (Location created1) (ref2019.1)") + .locationCreatedProvinceState("Province/State (Location created1) (ref2019.1)") + .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") + .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") + .addLocationShownCity("City (Location shown1) (ref2019.1)") + .addLocationShownCity("City (Location shown2) (ref2019.1)") + .addLocationShownCountryCode("R17") + .addLocationShownCountryCode("R17") + .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") + .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") + .addLocationShownGpsAltitude("140 m") + .addLocationShownGpsAltitude("120 m") + .addLocationShownGpsLatitude("48,8.82N") + .addLocationShownGpsLatitude("47,57.12N") + .addLocationShownGpsLongitude("17,5.88E") + .addLocationShownGpsLongitude("16,49.8E") + .locationShownLocationId( + listOf( + "Location Id 1a(Location shown1) (ref2019.1)", + "Location Id 1b(Location shown1) (ref2019.1)", + "Location Id 2a(Location shown2) (ref2019.1)", + "Location Id 2b(Location shown2) (ref2019.1)", + ) + ) + .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") + .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") + .addLocationShownProvinceState("Province/State (Location shown1) (ref2019.1)") + .addLocationShownProvinceState("Province/State (Location shown2) (ref2019.1)") + .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") + .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") + .maxAvailHeight(20.0) + .maxAvailWidth(19.0) + .modelAge(listOf(25.0, 27.0, 30.0)) + .addModelReleaseId("Model Release ID 1 (ref2019.1)") + .addModelReleaseId("Model Release ID 2 (ref2019.1)") + .objectAttributeReference("A Genre (ref2019.1)") + .objectName("The Title (ref2019.1)") + .offsetTimeOriginal("+00:00") + .organisationInImageCode( + listOf( + "Organisation Code 1 (ref2019.1)", + "Organisation Code 2 (ref2019.1)", + "Organisation Code 3 (ref2019.1)", + ) + ) + .organisationInImageName( + listOf( + "Organisation Name 1 (ref2019.1)", + "Organisation Name 2 (ref2019.1)", + "Organisation Name 3 (ref2019.1)", + ) + ) + .orientation("Horizontal (normal)") + .originalTransmissionReference("Job Id (ref2019.1)") + .addPersonInImage("Person Shown 1 (ref2019.1)") + .addPersonInImage("Person Shown 2 (ref2019.1)") + .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") + .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") + .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") + .addPersonInImageCvTermRefinedAbout( + "http://example.com/cv/refinements987/codeY765/ref2019.1" + ) + .addPersonInImageDescription("Person Description 1 (ref2019.1)") + .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") + .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") + .addPersonInImageName("Person Name 1 (ref2019.1)") + .addProductInImageDescription("Product Description 1 (ref2019.1)") + .addProductInImageGtin(123456782019.1) + .addProductInImageName("Product Name 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") + .provinceState("Province/State(Core)(ref2019.1)") + .rating(1L) + .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") + .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") + .addRegistryItemId("Registry Image ID 1 (ref2019.1)") + .addRegistryItemId("Registry Image ID 2 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") + .resolutionUnit("inches") + .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .addScene("IPTC-Scene-Code1 (ref2019.1)") + .addScene("IPTC-Scene-Code2 (ref2019.1)") + .source("Source (ref2019.1)") + .specialInstructions("An Instruction (ref2019.1)") + .state("Province/State(Core)(ref2019.1)") + .subject(listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1")) + .subjectCode(listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1")) + .subjectReference( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .sublocation("Sublocation (Core) (ref2019.1)") + .timeCreated("19:01:03+00:00") + .title("The Title (ref2019.1)") + .transmissionReference("Job Id (ref2019.1)") + .usageTerms("Rights Usage Terms (ref2019.1)") + .webStatement("http://www.WebStatementOfRights.org/2019.1") + .writer("Description Writer (ref2019.1)") + .writerEditor("Description Writer (ref2019.1)") + .xResolution(72.0) + .yResolution(72.0) + .build() + ) + assertThat(fileUploadV1Response.extensionStatus()) + .contains( + FileUploadV1Response.ExtensionStatus.builder() + .awsAutoTagging(FileUploadV1Response.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadV1Response.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadV1Response.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + assertThat(fileUploadV1Response.fileId()).contains("fileId") + assertThat(fileUploadV1Response.filePath()).contains("filePath") + assertThat(fileUploadV1Response.fileType()).contains("fileType") + assertThat(fileUploadV1Response.height()).contains(0.0) + assertThat(fileUploadV1Response.isPrivateFile()).contains(true) + assertThat(fileUploadV1Response.isPublished()).contains(true) + assertThat(fileUploadV1Response.metadata()) + .contains( + FileUploadV1Response.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadV1Response.Metadata.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadV1Response.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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(fileUploadV1Response.name()).contains("name") + assertThat(fileUploadV1Response.size()).contains(0.0) + assertThat(fileUploadV1Response.tags().getOrNull()).containsExactly("string") + assertThat(fileUploadV1Response.thumbnailUrl()).contains("thumbnailUrl") + assertThat(fileUploadV1Response.url()).contains("url") + assertThat(fileUploadV1Response.versionInfo()) + .contains(FileUploadV1Response.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileUploadV1Response.videoCodec()).contains("videoCodec") + assertThat(fileUploadV1Response.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileUploadV1Response = + FileUploadV1Response.builder() + .addAiTag( + FileUploadV1Response.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .duration(0L) + .embeddedMetadata( + FileUploadV1Response.EmbeddedMetadata.builder() + .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") + .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") + .aboutCvTermName("CV-Term Name 1 (ref2019.1)") + .aboutCvTermRefinedAbout( + "http://example.com/cv/refinements2/ref2019.1/codeX145" + ) + .additionalModelInformation("Additional Model Info (ref2019.1)") + .applicationRecordVersion(4L) + .artist("Creator1 (ref2019.1)") + .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") + .artworkContentDescription("AO Content Description 1 (ref2019.1)") + .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") + .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") + .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") + .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") + .addArtworkCreator("AO Creator Name 1a (ref2019.1)") + .addArtworkCreator("AO Creator Name 1b (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") + .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) + .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") + .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") + .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") + .artworkSource("AO Source 1 (ref2019.1)") + .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") + .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") + .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") + .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") + .artworkTitle("AO Title 1 (ref2019.1)") + .authorsPosition("Creator's Job Title (ref2019.1)") + .byline("Creator1 (ref2019.1)") + .bylineTitle("Creator's Job Title (ref2019.1)") + .caption("The description aka caption (ref2019.1)") + .captionAbstract("The description aka caption (ref2019.1)") + .captionWriter("Description Writer (ref2019.1)") + .city("City (Core) (ref2019.1)") + .colorSpace("Uncalibrated") + .componentsConfiguration("Y,Cb,Cr,-") + .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .copyrightNotice( + "Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)" + ) + .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") + .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") + .country("Country (Core) (ref2019.1)") + .countryCode("R19") + .countryPrimaryLocationCode("R19") + .countryPrimaryLocationName("Country (Core) (ref2019.1)") + .creator("Creator1 (ref2019.1)") + .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") + .creatorCity("Creator's CI: City (ref2019.1)") + .creatorCountry("Creator's CI: Country (ref2019.1)") + .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") + .creatorRegion("Creator's CI: State/Province (ref2019.1)") + .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") + .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") + .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") + .credit("Credit Line (ref2019.1)") + .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) + .description("The description aka caption (ref2019.1)") + .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") + .digitalSourceType( + "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" + ) + .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") + .embeddedEncodedRightsExprLangId( + "http://example.org/RELids/id4711/ref2019.1" + ) + .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .event("An Event (ref2019.1)") + .exifVersion("0232") + .flashpixVersion("0100") + .genreCvId("http://example.com/cv/genre/ref2019.1") + .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") + .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") + .genreCvTermRefinedAbout( + "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" + ) + .headline("The Headline (ref2019.1)") + .imageCreatorId("Image Creator Id 1 (ref2019.1)") + .imageCreatorImageId("Image Creator Image ID (ref2019.1)") + .imageCreatorName("Image Creator Name 1 (ref2019.1)") + .imageDescription("The description aka caption (ref2019.1)") + .addImageRegionBoundaryH(0.385) + .addImageRegionBoundaryRx(0.068) + .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) + .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) + .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) + .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) + .addImageRegionBoundaryW(0.127) + .addImageRegionBoundaryX(0.31) + .addImageRegionBoundaryX(0.59) + .addImageRegionBoundaryY(0.18) + .addImageRegionBoundaryY(0.426) + .imageRegionCtypeIdentifier( + listOf( + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + ) + ) + .imageRegionCtypeName( + listOf( + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + ) + ) + .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) + .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) + .imageRegionOrganisationInImageName( + listOf( + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr3 (ref2019.1)", + ) + ) + .imageRegionPersonInImage( + listOf( + "Person name no 1 in region persltr2 (ref2019.1)", + "Person name no 1 in region persltr3 (ref2019.1)", + "Person name no 1 in region persltr1 (ref2019.1)", + ) + ) + .imageRegionRoleIdentifier( + listOf( + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + ) + ) + .imageRegionRoleName( + listOf( + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + ) + ) + .imageSupplierId("Image Supplier Id (ref2019.1)") + .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") + .imageSupplierName("Image Supplier Name (ref2019.1)") + .instructions("An Instruction (ref2019.1)") + .intellectualGenre("A Genre (ref2019.1)") + .keywords( + listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") + ) + .addLicensorCity("Licensor City 1 (ref2019.1)") + .addLicensorCity("Licensor City 2 (ref2019.1)") + .addLicensorCountry("Licensor Country 1 (ref2019.1)") + .addLicensorCountry("Licensor Country 2 (ref2019.1)") + .addLicensorEmail("Licensor Email 1 (ref2019.1)") + .addLicensorEmail("Licensor Email 2 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") + .addLicensorId("Licensor ID 1 (ref2019.1)") + .addLicensorId("Licensor ID 2 (ref2019.1)") + .addLicensorName("Licensor Name 1 (ref2019.1)") + .addLicensorName("Licensor Name 2 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") + .addLicensorRegion("Licensor Region 1 (ref2019.1)") + .addLicensorRegion("Licensor Region 2 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") + .addLicensorUrl("Licensor URL 1 (ref2019.1)") + .addLicensorUrl("Licensor URL 2 (ref2019.1)") + .linkedEncodedRightsExpr( + "http://example.org/linkedrightsexpression/id986/ref2019.1" + ) + .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") + .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .location("Sublocation (Core) (ref2019.1)") + .locationCreatedCity("City (Location created1) (ref2019.1)") + .locationCreatedCountryCode("R17") + .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") + .locationCreatedGpsAltitude("480 m") + .locationCreatedGpsLatitude("48,16.5N") + .locationCreatedGpsLongitude("16,20.28E") + .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") + .locationCreatedLocationName( + "Location Name (Location created1) (ref2019.1)" + ) + .locationCreatedProvinceState( + "Province/State (Location created1) (ref2019.1)" + ) + .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") + .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") + .addLocationShownCity("City (Location shown1) (ref2019.1)") + .addLocationShownCity("City (Location shown2) (ref2019.1)") + .addLocationShownCountryCode("R17") + .addLocationShownCountryCode("R17") + .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") + .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") + .addLocationShownGpsAltitude("140 m") + .addLocationShownGpsAltitude("120 m") + .addLocationShownGpsLatitude("48,8.82N") + .addLocationShownGpsLatitude("47,57.12N") + .addLocationShownGpsLongitude("17,5.88E") + .addLocationShownGpsLongitude("16,49.8E") + .locationShownLocationId( + listOf( + "Location Id 1a(Location shown1) (ref2019.1)", + "Location Id 1b(Location shown1) (ref2019.1)", + "Location Id 2a(Location shown2) (ref2019.1)", + "Location Id 2b(Location shown2) (ref2019.1)", + ) + ) + .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") + .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") + .addLocationShownProvinceState( + "Province/State (Location shown1) (ref2019.1)" + ) + .addLocationShownProvinceState( + "Province/State (Location shown2) (ref2019.1)" + ) + .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") + .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") + .maxAvailHeight(20.0) + .maxAvailWidth(19.0) + .modelAge(listOf(25.0, 27.0, 30.0)) + .addModelReleaseId("Model Release ID 1 (ref2019.1)") + .addModelReleaseId("Model Release ID 2 (ref2019.1)") + .objectAttributeReference("A Genre (ref2019.1)") + .objectName("The Title (ref2019.1)") + .offsetTimeOriginal("+00:00") + .organisationInImageCode( + listOf( + "Organisation Code 1 (ref2019.1)", + "Organisation Code 2 (ref2019.1)", + "Organisation Code 3 (ref2019.1)", + ) + ) + .organisationInImageName( + listOf( + "Organisation Name 1 (ref2019.1)", + "Organisation Name 2 (ref2019.1)", + "Organisation Name 3 (ref2019.1)", + ) + ) + .orientation("Horizontal (normal)") + .originalTransmissionReference("Job Id (ref2019.1)") + .addPersonInImage("Person Shown 1 (ref2019.1)") + .addPersonInImage("Person Shown 2 (ref2019.1)") + .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") + .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") + .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") + .addPersonInImageCvTermRefinedAbout( + "http://example.com/cv/refinements987/codeY765/ref2019.1" + ) + .addPersonInImageDescription("Person Description 1 (ref2019.1)") + .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") + .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") + .addPersonInImageName("Person Name 1 (ref2019.1)") + .addProductInImageDescription("Product Description 1 (ref2019.1)") + .addProductInImageGtin(123456782019.1) + .addProductInImageName("Product Name 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") + .provinceState("Province/State(Core)(ref2019.1)") + .rating(1L) + .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") + .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") + .addRegistryItemId("Registry Image ID 1 (ref2019.1)") + .addRegistryItemId("Registry Image ID 2 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") + .resolutionUnit("inches") + .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .addScene("IPTC-Scene-Code1 (ref2019.1)") + .addScene("IPTC-Scene-Code2 (ref2019.1)") + .source("Source (ref2019.1)") + .specialInstructions("An Instruction (ref2019.1)") + .state("Province/State(Core)(ref2019.1)") + .subject( + listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") + ) + .subjectCode( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .subjectReference( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .sublocation("Sublocation (Core) (ref2019.1)") + .timeCreated("19:01:03+00:00") + .title("The Title (ref2019.1)") + .transmissionReference("Job Id (ref2019.1)") + .usageTerms("Rights Usage Terms (ref2019.1)") + .webStatement("http://www.WebStatementOfRights.org/2019.1") + .writer("Description Writer (ref2019.1)") + .writerEditor("Description Writer (ref2019.1)") + .xResolution(72.0) + .yResolution(72.0) + .build() + ) + .extensionStatus( + FileUploadV1Response.ExtensionStatus.builder() + .awsAutoTagging(FileUploadV1Response.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadV1Response.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadV1Response.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + FileUploadV1Response.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadV1Response.Metadata.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadV1Response.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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( + FileUploadV1Response.VersionInfo.builder().id("id").name("name").build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + + val roundtrippedFileUploadV1Response = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileUploadV1Response), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileUploadV1Response).isEqualTo(fileUploadV1Response) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ParamsTest.kt new file mode 100644 index 00000000..9489ce69 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ParamsTest.kt @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +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 FileUploadV2ParamsTest { + + @Test + fun create() { + FileUploadV2Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata("\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV2Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV2Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV2Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV2Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV2Params.OverwriteTags.TRUE) + .responseFields("responseFields") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV2Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .build() + } + + @Test + fun body() { + val params = + FileUploadV2Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV2Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV2Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV2Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV2Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV2Params.OverwriteTags.TRUE) + .responseFields("responseFields") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV2Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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("https://www.example.com/rest-of-the-image-path.jpg"), + "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( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ), + "extensions" to + MultipartField.of( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ), + "folder" to MultipartField.of("folder"), + "isPrivateFile" to MultipartField.of(FileUploadV2Params.IsPrivateFile.TRUE), + "isPublished" to MultipartField.of(FileUploadV2Params.IsPublished.TRUE), + "overwriteAITags" to + MultipartField.of(FileUploadV2Params.OverwriteAiTags.TRUE), + "overwriteCustomMetadata" to + MultipartField.of(FileUploadV2Params.OverwriteCustomMetadata.TRUE), + "overwriteFile" to MultipartField.of("overwriteFile"), + "overwriteTags" to MultipartField.of(FileUploadV2Params.OverwriteTags.TRUE), + "responseFields" to MultipartField.of("responseFields"), + "tags" to MultipartField.of("t-shirt,round-neck,men"), + "transformation" to + MultipartField.of( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ), + "useUniqueFileName" to + MultipartField.of(FileUploadV2Params.UseUniqueFileName.TRUE), + "webhookUrl" to MultipartField.of("webhookUrl"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FileUploadV2Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .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("https://www.example.com/rest-of-the-image-path.jpg"), + "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/FileUploadV2ResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ResponseTest.kt new file mode 100644 index 00000000..acb48c21 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ResponseTest.kt @@ -0,0 +1,1335 @@ +// 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 FileUploadV2ResponseTest { + + @Test + fun create() { + val fileUploadV2Response = + FileUploadV2Response.builder() + .addAiTag( + FileUploadV2Response.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .duration(0L) + .embeddedMetadata( + FileUploadV2Response.EmbeddedMetadata.builder() + .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") + .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") + .aboutCvTermName("CV-Term Name 1 (ref2019.1)") + .aboutCvTermRefinedAbout( + "http://example.com/cv/refinements2/ref2019.1/codeX145" + ) + .additionalModelInformation("Additional Model Info (ref2019.1)") + .applicationRecordVersion(4L) + .artist("Creator1 (ref2019.1)") + .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") + .artworkContentDescription("AO Content Description 1 (ref2019.1)") + .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") + .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") + .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") + .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") + .addArtworkCreator("AO Creator Name 1a (ref2019.1)") + .addArtworkCreator("AO Creator Name 1b (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") + .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) + .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") + .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") + .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") + .artworkSource("AO Source 1 (ref2019.1)") + .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") + .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") + .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") + .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") + .artworkTitle("AO Title 1 (ref2019.1)") + .authorsPosition("Creator's Job Title (ref2019.1)") + .byline("Creator1 (ref2019.1)") + .bylineTitle("Creator's Job Title (ref2019.1)") + .caption("The description aka caption (ref2019.1)") + .captionAbstract("The description aka caption (ref2019.1)") + .captionWriter("Description Writer (ref2019.1)") + .city("City (Core) (ref2019.1)") + .colorSpace("Uncalibrated") + .componentsConfiguration("Y,Cb,Cr,-") + .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .copyrightNotice( + "Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)" + ) + .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") + .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") + .country("Country (Core) (ref2019.1)") + .countryCode("R19") + .countryPrimaryLocationCode("R19") + .countryPrimaryLocationName("Country (Core) (ref2019.1)") + .creator("Creator1 (ref2019.1)") + .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") + .creatorCity("Creator's CI: City (ref2019.1)") + .creatorCountry("Creator's CI: Country (ref2019.1)") + .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") + .creatorRegion("Creator's CI: State/Province (ref2019.1)") + .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") + .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") + .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") + .credit("Credit Line (ref2019.1)") + .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) + .description("The description aka caption (ref2019.1)") + .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") + .digitalSourceType( + "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" + ) + .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") + .embeddedEncodedRightsExprLangId( + "http://example.org/RELids/id4711/ref2019.1" + ) + .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .event("An Event (ref2019.1)") + .exifVersion("0232") + .flashpixVersion("0100") + .genreCvId("http://example.com/cv/genre/ref2019.1") + .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") + .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") + .genreCvTermRefinedAbout( + "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" + ) + .headline("The Headline (ref2019.1)") + .imageCreatorId("Image Creator Id 1 (ref2019.1)") + .imageCreatorImageId("Image Creator Image ID (ref2019.1)") + .imageCreatorName("Image Creator Name 1 (ref2019.1)") + .imageDescription("The description aka caption (ref2019.1)") + .addImageRegionBoundaryH(0.385) + .addImageRegionBoundaryRx(0.068) + .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) + .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) + .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) + .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) + .addImageRegionBoundaryW(0.127) + .addImageRegionBoundaryX(0.31) + .addImageRegionBoundaryX(0.59) + .addImageRegionBoundaryY(0.18) + .addImageRegionBoundaryY(0.426) + .imageRegionCtypeIdentifier( + listOf( + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + ) + ) + .imageRegionCtypeName( + listOf( + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + ) + ) + .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) + .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) + .imageRegionOrganisationInImageName( + listOf( + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr3 (ref2019.1)", + ) + ) + .imageRegionPersonInImage( + listOf( + "Person name no 1 in region persltr2 (ref2019.1)", + "Person name no 1 in region persltr3 (ref2019.1)", + "Person name no 1 in region persltr1 (ref2019.1)", + ) + ) + .imageRegionRoleIdentifier( + listOf( + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + ) + ) + .imageRegionRoleName( + listOf( + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + ) + ) + .imageSupplierId("Image Supplier Id (ref2019.1)") + .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") + .imageSupplierName("Image Supplier Name (ref2019.1)") + .instructions("An Instruction (ref2019.1)") + .intellectualGenre("A Genre (ref2019.1)") + .keywords( + listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") + ) + .addLicensorCity("Licensor City 1 (ref2019.1)") + .addLicensorCity("Licensor City 2 (ref2019.1)") + .addLicensorCountry("Licensor Country 1 (ref2019.1)") + .addLicensorCountry("Licensor Country 2 (ref2019.1)") + .addLicensorEmail("Licensor Email 1 (ref2019.1)") + .addLicensorEmail("Licensor Email 2 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") + .addLicensorId("Licensor ID 1 (ref2019.1)") + .addLicensorId("Licensor ID 2 (ref2019.1)") + .addLicensorName("Licensor Name 1 (ref2019.1)") + .addLicensorName("Licensor Name 2 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") + .addLicensorRegion("Licensor Region 1 (ref2019.1)") + .addLicensorRegion("Licensor Region 2 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") + .addLicensorUrl("Licensor URL 1 (ref2019.1)") + .addLicensorUrl("Licensor URL 2 (ref2019.1)") + .linkedEncodedRightsExpr( + "http://example.org/linkedrightsexpression/id986/ref2019.1" + ) + .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") + .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .location("Sublocation (Core) (ref2019.1)") + .locationCreatedCity("City (Location created1) (ref2019.1)") + .locationCreatedCountryCode("R17") + .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") + .locationCreatedGpsAltitude("480 m") + .locationCreatedGpsLatitude("48,16.5N") + .locationCreatedGpsLongitude("16,20.28E") + .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") + .locationCreatedLocationName( + "Location Name (Location created1) (ref2019.1)" + ) + .locationCreatedProvinceState( + "Province/State (Location created1) (ref2019.1)" + ) + .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") + .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") + .addLocationShownCity("City (Location shown1) (ref2019.1)") + .addLocationShownCity("City (Location shown2) (ref2019.1)") + .addLocationShownCountryCode("R17") + .addLocationShownCountryCode("R17") + .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") + .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") + .addLocationShownGpsAltitude("140 m") + .addLocationShownGpsAltitude("120 m") + .addLocationShownGpsLatitude("48,8.82N") + .addLocationShownGpsLatitude("47,57.12N") + .addLocationShownGpsLongitude("17,5.88E") + .addLocationShownGpsLongitude("16,49.8E") + .locationShownLocationId( + listOf( + "Location Id 1a(Location shown1) (ref2019.1)", + "Location Id 1b(Location shown1) (ref2019.1)", + "Location Id 2a(Location shown2) (ref2019.1)", + "Location Id 2b(Location shown2) (ref2019.1)", + ) + ) + .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") + .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") + .addLocationShownProvinceState( + "Province/State (Location shown1) (ref2019.1)" + ) + .addLocationShownProvinceState( + "Province/State (Location shown2) (ref2019.1)" + ) + .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") + .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") + .maxAvailHeight(20.0) + .maxAvailWidth(19.0) + .modelAge(listOf(25.0, 27.0, 30.0)) + .addModelReleaseId("Model Release ID 1 (ref2019.1)") + .addModelReleaseId("Model Release ID 2 (ref2019.1)") + .objectAttributeReference("A Genre (ref2019.1)") + .objectName("The Title (ref2019.1)") + .offsetTimeOriginal("+00:00") + .organisationInImageCode( + listOf( + "Organisation Code 1 (ref2019.1)", + "Organisation Code 2 (ref2019.1)", + "Organisation Code 3 (ref2019.1)", + ) + ) + .organisationInImageName( + listOf( + "Organisation Name 1 (ref2019.1)", + "Organisation Name 2 (ref2019.1)", + "Organisation Name 3 (ref2019.1)", + ) + ) + .orientation("Horizontal (normal)") + .originalTransmissionReference("Job Id (ref2019.1)") + .addPersonInImage("Person Shown 1 (ref2019.1)") + .addPersonInImage("Person Shown 2 (ref2019.1)") + .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") + .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") + .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") + .addPersonInImageCvTermRefinedAbout( + "http://example.com/cv/refinements987/codeY765/ref2019.1" + ) + .addPersonInImageDescription("Person Description 1 (ref2019.1)") + .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") + .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") + .addPersonInImageName("Person Name 1 (ref2019.1)") + .addProductInImageDescription("Product Description 1 (ref2019.1)") + .addProductInImageGtin(123456782019.1) + .addProductInImageName("Product Name 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") + .provinceState("Province/State(Core)(ref2019.1)") + .rating(1L) + .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") + .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") + .addRegistryItemId("Registry Image ID 1 (ref2019.1)") + .addRegistryItemId("Registry Image ID 2 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") + .resolutionUnit("inches") + .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .addScene("IPTC-Scene-Code1 (ref2019.1)") + .addScene("IPTC-Scene-Code2 (ref2019.1)") + .source("Source (ref2019.1)") + .specialInstructions("An Instruction (ref2019.1)") + .state("Province/State(Core)(ref2019.1)") + .subject( + listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") + ) + .subjectCode( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .subjectReference( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .sublocation("Sublocation (Core) (ref2019.1)") + .timeCreated("19:01:03+00:00") + .title("The Title (ref2019.1)") + .transmissionReference("Job Id (ref2019.1)") + .usageTerms("Rights Usage Terms (ref2019.1)") + .webStatement("http://www.WebStatementOfRights.org/2019.1") + .writer("Description Writer (ref2019.1)") + .writerEditor("Description Writer (ref2019.1)") + .xResolution(72.0) + .yResolution(72.0) + .build() + ) + .extensionStatus( + FileUploadV2Response.ExtensionStatus.builder() + .awsAutoTagging(FileUploadV2Response.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadV2Response.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadV2Response.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + FileUploadV2Response.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadV2Response.Metadata.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadV2Response.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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( + FileUploadV2Response.VersionInfo.builder().id("id").name("name").build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + + assertThat(fileUploadV2Response.aiTags().getOrNull()) + .containsExactly( + FileUploadV2Response.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(fileUploadV2Response.audioCodec()).contains("audioCodec") + assertThat(fileUploadV2Response.bitRate()).contains(0L) + assertThat(fileUploadV2Response.customCoordinates()).contains("customCoordinates") + assertThat(fileUploadV2Response._customMetadata()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(fileUploadV2Response.duration()).contains(0L) + assertThat(fileUploadV2Response.embeddedMetadata()) + .contains( + FileUploadV2Response.EmbeddedMetadata.builder() + .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") + .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") + .aboutCvTermName("CV-Term Name 1 (ref2019.1)") + .aboutCvTermRefinedAbout( + "http://example.com/cv/refinements2/ref2019.1/codeX145" + ) + .additionalModelInformation("Additional Model Info (ref2019.1)") + .applicationRecordVersion(4L) + .artist("Creator1 (ref2019.1)") + .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") + .artworkContentDescription("AO Content Description 1 (ref2019.1)") + .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") + .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") + .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") + .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") + .addArtworkCreator("AO Creator Name 1a (ref2019.1)") + .addArtworkCreator("AO Creator Name 1b (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") + .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) + .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") + .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") + .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") + .artworkSource("AO Source 1 (ref2019.1)") + .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") + .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") + .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") + .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") + .artworkTitle("AO Title 1 (ref2019.1)") + .authorsPosition("Creator's Job Title (ref2019.1)") + .byline("Creator1 (ref2019.1)") + .bylineTitle("Creator's Job Title (ref2019.1)") + .caption("The description aka caption (ref2019.1)") + .captionAbstract("The description aka caption (ref2019.1)") + .captionWriter("Description Writer (ref2019.1)") + .city("City (Core) (ref2019.1)") + .colorSpace("Uncalibrated") + .componentsConfiguration("Y,Cb,Cr,-") + .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .copyrightNotice("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") + .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") + .country("Country (Core) (ref2019.1)") + .countryCode("R19") + .countryPrimaryLocationCode("R19") + .countryPrimaryLocationName("Country (Core) (ref2019.1)") + .creator("Creator1 (ref2019.1)") + .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") + .creatorCity("Creator's CI: City (ref2019.1)") + .creatorCountry("Creator's CI: Country (ref2019.1)") + .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") + .creatorRegion("Creator's CI: State/Province (ref2019.1)") + .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") + .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") + .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") + .credit("Credit Line (ref2019.1)") + .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) + .description("The description aka caption (ref2019.1)") + .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") + .digitalSourceType( + "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" + ) + .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") + .embeddedEncodedRightsExprLangId("http://example.org/RELids/id4711/ref2019.1") + .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .event("An Event (ref2019.1)") + .exifVersion("0232") + .flashpixVersion("0100") + .genreCvId("http://example.com/cv/genre/ref2019.1") + .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") + .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") + .genreCvTermRefinedAbout( + "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" + ) + .headline("The Headline (ref2019.1)") + .imageCreatorId("Image Creator Id 1 (ref2019.1)") + .imageCreatorImageId("Image Creator Image ID (ref2019.1)") + .imageCreatorName("Image Creator Name 1 (ref2019.1)") + .imageDescription("The description aka caption (ref2019.1)") + .addImageRegionBoundaryH(0.385) + .addImageRegionBoundaryRx(0.068) + .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) + .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) + .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) + .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) + .addImageRegionBoundaryW(0.127) + .addImageRegionBoundaryX(0.31) + .addImageRegionBoundaryX(0.59) + .addImageRegionBoundaryY(0.18) + .addImageRegionBoundaryY(0.426) + .imageRegionCtypeIdentifier( + listOf( + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + ) + ) + .imageRegionCtypeName( + listOf( + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + ) + ) + .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) + .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) + .imageRegionOrganisationInImageName( + listOf( + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr3 (ref2019.1)", + ) + ) + .imageRegionPersonInImage( + listOf( + "Person name no 1 in region persltr2 (ref2019.1)", + "Person name no 1 in region persltr3 (ref2019.1)", + "Person name no 1 in region persltr1 (ref2019.1)", + ) + ) + .imageRegionRoleIdentifier( + listOf( + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + ) + ) + .imageRegionRoleName( + listOf( + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + ) + ) + .imageSupplierId("Image Supplier Id (ref2019.1)") + .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") + .imageSupplierName("Image Supplier Name (ref2019.1)") + .instructions("An Instruction (ref2019.1)") + .intellectualGenre("A Genre (ref2019.1)") + .keywords(listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1")) + .addLicensorCity("Licensor City 1 (ref2019.1)") + .addLicensorCity("Licensor City 2 (ref2019.1)") + .addLicensorCountry("Licensor Country 1 (ref2019.1)") + .addLicensorCountry("Licensor Country 2 (ref2019.1)") + .addLicensorEmail("Licensor Email 1 (ref2019.1)") + .addLicensorEmail("Licensor Email 2 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") + .addLicensorId("Licensor ID 1 (ref2019.1)") + .addLicensorId("Licensor ID 2 (ref2019.1)") + .addLicensorName("Licensor Name 1 (ref2019.1)") + .addLicensorName("Licensor Name 2 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") + .addLicensorRegion("Licensor Region 1 (ref2019.1)") + .addLicensorRegion("Licensor Region 2 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") + .addLicensorUrl("Licensor URL 1 (ref2019.1)") + .addLicensorUrl("Licensor URL 2 (ref2019.1)") + .linkedEncodedRightsExpr( + "http://example.org/linkedrightsexpression/id986/ref2019.1" + ) + .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") + .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .location("Sublocation (Core) (ref2019.1)") + .locationCreatedCity("City (Location created1) (ref2019.1)") + .locationCreatedCountryCode("R17") + .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") + .locationCreatedGpsAltitude("480 m") + .locationCreatedGpsLatitude("48,16.5N") + .locationCreatedGpsLongitude("16,20.28E") + .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") + .locationCreatedLocationName("Location Name (Location created1) (ref2019.1)") + .locationCreatedProvinceState("Province/State (Location created1) (ref2019.1)") + .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") + .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") + .addLocationShownCity("City (Location shown1) (ref2019.1)") + .addLocationShownCity("City (Location shown2) (ref2019.1)") + .addLocationShownCountryCode("R17") + .addLocationShownCountryCode("R17") + .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") + .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") + .addLocationShownGpsAltitude("140 m") + .addLocationShownGpsAltitude("120 m") + .addLocationShownGpsLatitude("48,8.82N") + .addLocationShownGpsLatitude("47,57.12N") + .addLocationShownGpsLongitude("17,5.88E") + .addLocationShownGpsLongitude("16,49.8E") + .locationShownLocationId( + listOf( + "Location Id 1a(Location shown1) (ref2019.1)", + "Location Id 1b(Location shown1) (ref2019.1)", + "Location Id 2a(Location shown2) (ref2019.1)", + "Location Id 2b(Location shown2) (ref2019.1)", + ) + ) + .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") + .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") + .addLocationShownProvinceState("Province/State (Location shown1) (ref2019.1)") + .addLocationShownProvinceState("Province/State (Location shown2) (ref2019.1)") + .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") + .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") + .maxAvailHeight(20.0) + .maxAvailWidth(19.0) + .modelAge(listOf(25.0, 27.0, 30.0)) + .addModelReleaseId("Model Release ID 1 (ref2019.1)") + .addModelReleaseId("Model Release ID 2 (ref2019.1)") + .objectAttributeReference("A Genre (ref2019.1)") + .objectName("The Title (ref2019.1)") + .offsetTimeOriginal("+00:00") + .organisationInImageCode( + listOf( + "Organisation Code 1 (ref2019.1)", + "Organisation Code 2 (ref2019.1)", + "Organisation Code 3 (ref2019.1)", + ) + ) + .organisationInImageName( + listOf( + "Organisation Name 1 (ref2019.1)", + "Organisation Name 2 (ref2019.1)", + "Organisation Name 3 (ref2019.1)", + ) + ) + .orientation("Horizontal (normal)") + .originalTransmissionReference("Job Id (ref2019.1)") + .addPersonInImage("Person Shown 1 (ref2019.1)") + .addPersonInImage("Person Shown 2 (ref2019.1)") + .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") + .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") + .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") + .addPersonInImageCvTermRefinedAbout( + "http://example.com/cv/refinements987/codeY765/ref2019.1" + ) + .addPersonInImageDescription("Person Description 1 (ref2019.1)") + .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") + .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") + .addPersonInImageName("Person Name 1 (ref2019.1)") + .addProductInImageDescription("Product Description 1 (ref2019.1)") + .addProductInImageGtin(123456782019.1) + .addProductInImageName("Product Name 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") + .provinceState("Province/State(Core)(ref2019.1)") + .rating(1L) + .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") + .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") + .addRegistryItemId("Registry Image ID 1 (ref2019.1)") + .addRegistryItemId("Registry Image ID 2 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") + .resolutionUnit("inches") + .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .addScene("IPTC-Scene-Code1 (ref2019.1)") + .addScene("IPTC-Scene-Code2 (ref2019.1)") + .source("Source (ref2019.1)") + .specialInstructions("An Instruction (ref2019.1)") + .state("Province/State(Core)(ref2019.1)") + .subject(listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1")) + .subjectCode(listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1")) + .subjectReference( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .sublocation("Sublocation (Core) (ref2019.1)") + .timeCreated("19:01:03+00:00") + .title("The Title (ref2019.1)") + .transmissionReference("Job Id (ref2019.1)") + .usageTerms("Rights Usage Terms (ref2019.1)") + .webStatement("http://www.WebStatementOfRights.org/2019.1") + .writer("Description Writer (ref2019.1)") + .writerEditor("Description Writer (ref2019.1)") + .xResolution(72.0) + .yResolution(72.0) + .build() + ) + assertThat(fileUploadV2Response.extensionStatus()) + .contains( + FileUploadV2Response.ExtensionStatus.builder() + .awsAutoTagging(FileUploadV2Response.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadV2Response.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadV2Response.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + assertThat(fileUploadV2Response.fileId()).contains("fileId") + assertThat(fileUploadV2Response.filePath()).contains("filePath") + assertThat(fileUploadV2Response.fileType()).contains("fileType") + assertThat(fileUploadV2Response.height()).contains(0.0) + assertThat(fileUploadV2Response.isPrivateFile()).contains(true) + assertThat(fileUploadV2Response.isPublished()).contains(true) + assertThat(fileUploadV2Response.metadata()) + .contains( + FileUploadV2Response.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadV2Response.Metadata.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadV2Response.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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(fileUploadV2Response.name()).contains("name") + assertThat(fileUploadV2Response.size()).contains(0.0) + assertThat(fileUploadV2Response.tags().getOrNull()).containsExactly("string") + assertThat(fileUploadV2Response.thumbnailUrl()).contains("thumbnailUrl") + assertThat(fileUploadV2Response.url()).contains("url") + assertThat(fileUploadV2Response.versionInfo()) + .contains(FileUploadV2Response.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileUploadV2Response.videoCodec()).contains("videoCodec") + assertThat(fileUploadV2Response.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileUploadV2Response = + FileUploadV2Response.builder() + .addAiTag( + FileUploadV2Response.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .duration(0L) + .embeddedMetadata( + FileUploadV2Response.EmbeddedMetadata.builder() + .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") + .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") + .aboutCvTermName("CV-Term Name 1 (ref2019.1)") + .aboutCvTermRefinedAbout( + "http://example.com/cv/refinements2/ref2019.1/codeX145" + ) + .additionalModelInformation("Additional Model Info (ref2019.1)") + .applicationRecordVersion(4L) + .artist("Creator1 (ref2019.1)") + .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") + .artworkContentDescription("AO Content Description 1 (ref2019.1)") + .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") + .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") + .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") + .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") + .addArtworkCreator("AO Creator Name 1a (ref2019.1)") + .addArtworkCreator("AO Creator Name 1b (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") + .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") + .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) + .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") + .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") + .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") + .artworkSource("AO Source 1 (ref2019.1)") + .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") + .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") + .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") + .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") + .artworkTitle("AO Title 1 (ref2019.1)") + .authorsPosition("Creator's Job Title (ref2019.1)") + .byline("Creator1 (ref2019.1)") + .bylineTitle("Creator's Job Title (ref2019.1)") + .caption("The description aka caption (ref2019.1)") + .captionAbstract("The description aka caption (ref2019.1)") + .captionWriter("Description Writer (ref2019.1)") + .city("City (Core) (ref2019.1)") + .colorSpace("Uncalibrated") + .componentsConfiguration("Y,Cb,Cr,-") + .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .copyrightNotice( + "Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)" + ) + .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") + .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") + .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") + .country("Country (Core) (ref2019.1)") + .countryCode("R19") + .countryPrimaryLocationCode("R19") + .countryPrimaryLocationName("Country (Core) (ref2019.1)") + .creator("Creator1 (ref2019.1)") + .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") + .creatorCity("Creator's CI: City (ref2019.1)") + .creatorCountry("Creator's CI: Country (ref2019.1)") + .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") + .creatorRegion("Creator's CI: State/Province (ref2019.1)") + .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") + .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") + .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") + .credit("Credit Line (ref2019.1)") + .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) + .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) + .description("The description aka caption (ref2019.1)") + .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") + .digitalSourceType( + "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" + ) + .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") + .embeddedEncodedRightsExprLangId( + "http://example.org/RELids/id4711/ref2019.1" + ) + .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .event("An Event (ref2019.1)") + .exifVersion("0232") + .flashpixVersion("0100") + .genreCvId("http://example.com/cv/genre/ref2019.1") + .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") + .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") + .genreCvTermRefinedAbout( + "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" + ) + .headline("The Headline (ref2019.1)") + .imageCreatorId("Image Creator Id 1 (ref2019.1)") + .imageCreatorImageId("Image Creator Image ID (ref2019.1)") + .imageCreatorName("Image Creator Name 1 (ref2019.1)") + .imageDescription("The description aka caption (ref2019.1)") + .addImageRegionBoundaryH(0.385) + .addImageRegionBoundaryRx(0.068) + .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) + .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) + .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) + .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) + .addImageRegionBoundaryW(0.127) + .addImageRegionBoundaryX(0.31) + .addImageRegionBoundaryX(0.59) + .addImageRegionBoundaryY(0.18) + .addImageRegionBoundaryY(0.426) + .imageRegionCtypeIdentifier( + listOf( + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + "https://example.org/rctype/type2019.1a", + "https://example.org/rctype/type2019.1b", + ) + ) + .imageRegionCtypeName( + listOf( + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + "Region Boundary Content Type Name (ref2019.1)", + ) + ) + .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) + .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) + .imageRegionOrganisationInImageName( + listOf( + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr2 (ref2019.1)", + "Organisation name no 1 in region persltr3 (ref2019.1)", + ) + ) + .imageRegionPersonInImage( + listOf( + "Person name no 1 in region persltr2 (ref2019.1)", + "Person name no 1 in region persltr3 (ref2019.1)", + "Person name no 1 in region persltr1 (ref2019.1)", + ) + ) + .imageRegionRoleIdentifier( + listOf( + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + "https://example.org/rrole/role2019.1a", + "https://example.org/rrole/role2019.1b", + ) + ) + .imageRegionRoleName( + listOf( + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + "Region Boundary Content Role Name (ref2019.1)", + ) + ) + .imageSupplierId("Image Supplier Id (ref2019.1)") + .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") + .imageSupplierName("Image Supplier Name (ref2019.1)") + .instructions("An Instruction (ref2019.1)") + .intellectualGenre("A Genre (ref2019.1)") + .keywords( + listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") + ) + .addLicensorCity("Licensor City 1 (ref2019.1)") + .addLicensorCity("Licensor City 2 (ref2019.1)") + .addLicensorCountry("Licensor Country 1 (ref2019.1)") + .addLicensorCountry("Licensor Country 2 (ref2019.1)") + .addLicensorEmail("Licensor Email 1 (ref2019.1)") + .addLicensorEmail("Licensor Email 2 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") + .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") + .addLicensorId("Licensor ID 1 (ref2019.1)") + .addLicensorId("Licensor ID 2 (ref2019.1)") + .addLicensorName("Licensor Name 1 (ref2019.1)") + .addLicensorName("Licensor Name 2 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") + .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") + .addLicensorRegion("Licensor Region 1 (ref2019.1)") + .addLicensorRegion("Licensor Region 2 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") + .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") + .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") + .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") + .addLicensorUrl("Licensor URL 1 (ref2019.1)") + .addLicensorUrl("Licensor URL 2 (ref2019.1)") + .linkedEncodedRightsExpr( + "http://example.org/linkedrightsexpression/id986/ref2019.1" + ) + .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") + .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") + .location("Sublocation (Core) (ref2019.1)") + .locationCreatedCity("City (Location created1) (ref2019.1)") + .locationCreatedCountryCode("R17") + .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") + .locationCreatedGpsAltitude("480 m") + .locationCreatedGpsLatitude("48,16.5N") + .locationCreatedGpsLongitude("16,20.28E") + .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") + .locationCreatedLocationName( + "Location Name (Location created1) (ref2019.1)" + ) + .locationCreatedProvinceState( + "Province/State (Location created1) (ref2019.1)" + ) + .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") + .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") + .addLocationShownCity("City (Location shown1) (ref2019.1)") + .addLocationShownCity("City (Location shown2) (ref2019.1)") + .addLocationShownCountryCode("R17") + .addLocationShownCountryCode("R17") + .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") + .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") + .addLocationShownGpsAltitude("140 m") + .addLocationShownGpsAltitude("120 m") + .addLocationShownGpsLatitude("48,8.82N") + .addLocationShownGpsLatitude("47,57.12N") + .addLocationShownGpsLongitude("17,5.88E") + .addLocationShownGpsLongitude("16,49.8E") + .locationShownLocationId( + listOf( + "Location Id 1a(Location shown1) (ref2019.1)", + "Location Id 1b(Location shown1) (ref2019.1)", + "Location Id 2a(Location shown2) (ref2019.1)", + "Location Id 2b(Location shown2) (ref2019.1)", + ) + ) + .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") + .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") + .addLocationShownProvinceState( + "Province/State (Location shown1) (ref2019.1)" + ) + .addLocationShownProvinceState( + "Province/State (Location shown2) (ref2019.1)" + ) + .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") + .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") + .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") + .maxAvailHeight(20.0) + .maxAvailWidth(19.0) + .modelAge(listOf(25.0, 27.0, 30.0)) + .addModelReleaseId("Model Release ID 1 (ref2019.1)") + .addModelReleaseId("Model Release ID 2 (ref2019.1)") + .objectAttributeReference("A Genre (ref2019.1)") + .objectName("The Title (ref2019.1)") + .offsetTimeOriginal("+00:00") + .organisationInImageCode( + listOf( + "Organisation Code 1 (ref2019.1)", + "Organisation Code 2 (ref2019.1)", + "Organisation Code 3 (ref2019.1)", + ) + ) + .organisationInImageName( + listOf( + "Organisation Name 1 (ref2019.1)", + "Organisation Name 2 (ref2019.1)", + "Organisation Name 3 (ref2019.1)", + ) + ) + .orientation("Horizontal (normal)") + .originalTransmissionReference("Job Id (ref2019.1)") + .addPersonInImage("Person Shown 1 (ref2019.1)") + .addPersonInImage("Person Shown 2 (ref2019.1)") + .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") + .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") + .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") + .addPersonInImageCvTermRefinedAbout( + "http://example.com/cv/refinements987/codeY765/ref2019.1" + ) + .addPersonInImageDescription("Person Description 1 (ref2019.1)") + .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") + .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") + .addPersonInImageName("Person Name 1 (ref2019.1)") + .addProductInImageDescription("Product Description 1 (ref2019.1)") + .addProductInImageGtin(123456782019.1) + .addProductInImageName("Product Name 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") + .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") + .provinceState("Province/State(Core)(ref2019.1)") + .rating(1L) + .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") + .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") + .addRegistryItemId("Registry Image ID 1 (ref2019.1)") + .addRegistryItemId("Registry Image ID 2 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") + .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") + .resolutionUnit("inches") + .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") + .addScene("IPTC-Scene-Code1 (ref2019.1)") + .addScene("IPTC-Scene-Code2 (ref2019.1)") + .source("Source (ref2019.1)") + .specialInstructions("An Instruction (ref2019.1)") + .state("Province/State(Core)(ref2019.1)") + .subject( + listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") + ) + .subjectCode( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .subjectReference( + listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") + ) + .sublocation("Sublocation (Core) (ref2019.1)") + .timeCreated("19:01:03+00:00") + .title("The Title (ref2019.1)") + .transmissionReference("Job Id (ref2019.1)") + .usageTerms("Rights Usage Terms (ref2019.1)") + .webStatement("http://www.WebStatementOfRights.org/2019.1") + .writer("Description Writer (ref2019.1)") + .writerEditor("Description Writer (ref2019.1)") + .xResolution(72.0) + .yResolution(72.0) + .build() + ) + .extensionStatus( + FileUploadV2Response.ExtensionStatus.builder() + .awsAutoTagging(FileUploadV2Response.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadV2Response.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadV2Response.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + FileUploadV2Response.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadV2Response.Metadata.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadV2Response.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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( + FileUploadV2Response.VersionInfo.builder().id("id").name("name").build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + + val roundtrippedFileUploadV2Response = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileUploadV2Response), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileUploadV2Response).isEqualTo(fileUploadV2Response) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/GpsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/GpsTest.kt new file mode 100644 index 00000000..f7e622aa --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/GpsTest.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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GpsTest { + + @Test + fun create() { + val gps = Gps.builder().addGpsVersionId(0L).build() + + assertThat(gps.gpsVersionId().getOrNull()).containsExactly(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val gps = Gps.builder().addGpsVersionId(0L).build() + + val roundtrippedGps = + jsonMapper.readValue(jsonMapper.writeValueAsString(gps), jacksonTypeRef()) + + assertThat(roundtrippedGps).isEqualTo(gps) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/InteroperabilityTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/InteroperabilityTest.kt new file mode 100644 index 00000000..d0d26859 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/InteroperabilityTest.kt @@ -0,0 +1,41 @@ +// 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 InteroperabilityTest { + + @Test + fun create() { + val interoperability = + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + + assertThat(interoperability.interopIndex()).contains("InteropIndex") + assertThat(interoperability.interopVersion()).contains("InteropVersion") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val interoperability = + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + + val roundtrippedInteroperability = + jsonMapper.readValue( + jsonMapper.writeValueAsString(interoperability), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInteroperability).isEqualTo(interoperability) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ThumbnailTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ThumbnailTest.kt new file mode 100644 index 00000000..9fa4db51 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ThumbnailTest.kt @@ -0,0 +1,53 @@ +// 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 ThumbnailTest { + + @Test + fun create() { + val thumbnail = + Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + + assertThat(thumbnail.compression()).contains(0L) + assertThat(thumbnail.resolutionUnit()).contains(0L) + assertThat(thumbnail.thumbnailLength()).contains(0L) + assertThat(thumbnail.thumbnailOffset()).contains(0L) + assertThat(thumbnail.xResolution()).contains(0L) + assertThat(thumbnail.yResolution()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val thumbnail = + Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + + val roundtrippedThumbnail = + jsonMapper.readValue( + jsonMapper.writeValueAsString(thumbnail), + jacksonTypeRef(), + ) + + assertThat(roundtrippedThumbnail).isEqualTo(thumbnail) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParamsTest.kt new file mode 100644 index 00000000..4734ceb4 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.batch + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchDeleteParamsTest { + + @Test + fun create() { + BatchDeleteParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + } + + @Test + fun body() { + val params = + BatchDeleteParams.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/batch/BatchDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponseTest.kt new file mode 100644 index 00000000..0fd76815 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponseTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.batch + +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 BatchDeleteResponseTest { + + @Test + fun create() { + val batchDeleteResponse = + BatchDeleteResponse.builder().addSuccessfullyDeletedFileId("string").build() + + assertThat(batchDeleteResponse.successfullyDeletedFileIds().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchDeleteResponse = + BatchDeleteResponse.builder().addSuccessfullyDeletedFileId("string").build() + + val roundtrippedBatchDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchDeleteResponse).isEqualTo(batchDeleteResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParamsTest.kt new file mode 100644 index 00000000..38bd15de --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.details + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DetailRetrieveParamsTest { + + @Test + fun create() { + DetailRetrieveParams.builder().fileId("fileId").build() + } + + @Test + fun pathParams() { + val params = DetailRetrieveParams.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/details/DetailRetrieveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponseTest.kt new file mode 100644 index 00000000..70671f73 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponseTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.details + +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 DetailRetrieveResponseTest { + + @Test + fun create() { + val detailRetrieveResponse = + DetailRetrieveResponse.builder() + .addAiTag( + DetailRetrieveResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + DetailRetrieveResponse.VersionInfo.builder().id("id").name("name").build() + ) + .width(0.0) + .build() + + assertThat(detailRetrieveResponse.aiTags().getOrNull()) + .containsExactly( + DetailRetrieveResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(detailRetrieveResponse.createdAt()).contains("createdAt") + assertThat(detailRetrieveResponse.customCoordinates()).contains("customCoordinates") + assertThat(detailRetrieveResponse._customMetadata()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(detailRetrieveResponse.fileId()).contains("fileId") + assertThat(detailRetrieveResponse.filePath()).contains("filePath") + assertThat(detailRetrieveResponse.fileType()).contains("fileType") + assertThat(detailRetrieveResponse.hasAlpha()).contains(true) + assertThat(detailRetrieveResponse.height()).contains(0.0) + assertThat(detailRetrieveResponse.isPrivateFile()).contains(true) + assertThat(detailRetrieveResponse.isPublished()).contains(true) + assertThat(detailRetrieveResponse.mime()).contains("mime") + assertThat(detailRetrieveResponse.name()).contains("name") + assertThat(detailRetrieveResponse.size()).contains(0.0) + assertThat(detailRetrieveResponse.tags().getOrNull()).containsExactly("string") + assertThat(detailRetrieveResponse.thumbnail()).contains("thumbnail") + assertThat(detailRetrieveResponse.type()).contains("type") + assertThat(detailRetrieveResponse.updatedAt()).contains("updatedAt") + assertThat(detailRetrieveResponse.url()).contains("url") + assertThat(detailRetrieveResponse.versionInfo()) + .contains(DetailRetrieveResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(detailRetrieveResponse.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val detailRetrieveResponse = + DetailRetrieveResponse.builder() + .addAiTag( + DetailRetrieveResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + DetailRetrieveResponse.VersionInfo.builder().id("id").name("name").build() + ) + .width(0.0) + .build() + + val roundtrippedDetailRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(detailRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDetailRetrieveResponse).isEqualTo(detailRetrieveResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateParamsTest.kt new file mode 100644 index 00000000..388987cc --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateParamsTest.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.details + +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 DetailUpdateParamsTest { + + @Test + fun create() { + DetailUpdateParams.builder() + .fileId("fileId") + .body( + DetailUpdateParams.Body.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .extensions( + listOf( + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + ) + ) + .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 = DetailUpdateParams.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 = + DetailUpdateParams.builder() + .fileId("fileId") + .body( + DetailUpdateParams.Body.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .extensions( + listOf( + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + ) + ) + .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( + DetailUpdateParams.Body.ofUpdateFileDetails( + DetailUpdateParams.Body.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .extensions( + listOf( + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = DetailUpdateParams.builder().fileId("fileId").build() + + val body = params._body().getOrNull() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponseTest.kt new file mode 100644 index 00000000..c590f5c8 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponseTest.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.details + +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 DetailUpdateResponseTest { + + @Test + fun create() { + val detailUpdateResponse = + DetailUpdateResponse.builder() + .addAiTag( + DetailUpdateResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .extensionStatus( + DetailUpdateResponse.ExtensionStatus.builder() + .awsAutoTagging(DetailUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + DetailUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(DetailUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + DetailUpdateResponse.VersionInfo.builder().id("id").name("name").build() + ) + .width(0.0) + .build() + + assertThat(detailUpdateResponse.aiTags().getOrNull()) + .containsExactly( + DetailUpdateResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(detailUpdateResponse.createdAt()).contains("createdAt") + assertThat(detailUpdateResponse.customCoordinates()).contains("customCoordinates") + assertThat(detailUpdateResponse._customMetadata()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(detailUpdateResponse.extensionStatus()) + .contains( + DetailUpdateResponse.ExtensionStatus.builder() + .awsAutoTagging(DetailUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + DetailUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(DetailUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + assertThat(detailUpdateResponse.fileId()).contains("fileId") + assertThat(detailUpdateResponse.filePath()).contains("filePath") + assertThat(detailUpdateResponse.fileType()).contains("fileType") + assertThat(detailUpdateResponse.hasAlpha()).contains(true) + assertThat(detailUpdateResponse.height()).contains(0.0) + assertThat(detailUpdateResponse.isPrivateFile()).contains(true) + assertThat(detailUpdateResponse.isPublished()).contains(true) + assertThat(detailUpdateResponse.mime()).contains("mime") + assertThat(detailUpdateResponse.name()).contains("name") + assertThat(detailUpdateResponse.size()).contains(0.0) + assertThat(detailUpdateResponse.tags().getOrNull()).containsExactly("string") + assertThat(detailUpdateResponse.thumbnail()).contains("thumbnail") + assertThat(detailUpdateResponse.type()).contains("type") + assertThat(detailUpdateResponse.updatedAt()).contains("updatedAt") + assertThat(detailUpdateResponse.url()).contains("url") + assertThat(detailUpdateResponse.versionInfo()) + .contains(DetailUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(detailUpdateResponse.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val detailUpdateResponse = + DetailUpdateResponse.builder() + .addAiTag( + DetailUpdateResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .extensionStatus( + DetailUpdateResponse.ExtensionStatus.builder() + .awsAutoTagging(DetailUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + DetailUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(DetailUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + DetailUpdateResponse.VersionInfo.builder().id("id").name("name").build() + ) + .width(0.0) + .build() + + val roundtrippedDetailUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(detailUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDetailUpdateResponse).isEqualTo(detailUpdateResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParamsTest.kt new file mode 100644 index 00000000..19940214 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParamsTest.kt @@ -0,0 +1,24 @@ +// 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 MetadataFromUrlParamsTest { + + @Test + fun create() { + MetadataFromUrlParams.builder().url("url").build() + } + + @Test + fun queryParams() { + val params = MetadataFromUrlParams.builder().url("url").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("url", "url").build()) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponseTest.kt new file mode 100644 index 00000000..e808d3fa --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponseTest.kt @@ -0,0 +1,294 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +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.ExifDetails +import com.imagekit.api.models.files.ExifImage +import com.imagekit.api.models.files.Gps +import com.imagekit.api.models.files.Interoperability +import com.imagekit.api.models.files.Thumbnail +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MetadataFromUrlResponseTest { + + @Test + fun create() { + val metadataFromUrlResponse = + MetadataFromUrlResponse.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + MetadataFromUrlResponse.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + MetadataFromUrlResponse.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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(metadataFromUrlResponse.audioCodec()).contains("audioCodec") + assertThat(metadataFromUrlResponse.bitRate()).contains(0L) + assertThat(metadataFromUrlResponse.density()).contains(0L) + assertThat(metadataFromUrlResponse.duration()).contains(0L) + assertThat(metadataFromUrlResponse.exif()) + .contains( + MetadataFromUrlResponse.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + MetadataFromUrlResponse.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + assertThat(metadataFromUrlResponse.format()).contains("format") + assertThat(metadataFromUrlResponse.hasColorProfile()).contains(true) + assertThat(metadataFromUrlResponse.hasTransparency()).contains(true) + assertThat(metadataFromUrlResponse.height()).contains(0L) + assertThat(metadataFromUrlResponse.pHash()).contains("pHash") + assertThat(metadataFromUrlResponse.quality()).contains(0L) + assertThat(metadataFromUrlResponse.size()).contains(0L) + assertThat(metadataFromUrlResponse.videoCodec()).contains("videoCodec") + assertThat(metadataFromUrlResponse.width()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val metadataFromUrlResponse = + MetadataFromUrlResponse.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + MetadataFromUrlResponse.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + MetadataFromUrlResponse.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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 roundtrippedMetadataFromUrlResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(metadataFromUrlResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMetadataFromUrlResponse).isEqualTo(metadataFromUrlResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParamsTest.kt new file mode 100644 index 00000000..239baeab --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParamsTest.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 MetadataRetrieveParamsTest { + + @Test + fun create() { + MetadataRetrieveParams.builder().fileId("fileId").build() + } + + @Test + fun pathParams() { + val params = MetadataRetrieveParams.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/metadata/MetadataRetrieveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponseTest.kt new file mode 100644 index 00000000..a9013499 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponseTest.kt @@ -0,0 +1,294 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +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.ExifDetails +import com.imagekit.api.models.files.ExifImage +import com.imagekit.api.models.files.Gps +import com.imagekit.api.models.files.Interoperability +import com.imagekit.api.models.files.Thumbnail +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MetadataRetrieveResponseTest { + + @Test + fun create() { + val metadataRetrieveResponse = + MetadataRetrieveResponse.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + MetadataRetrieveResponse.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + MetadataRetrieveResponse.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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(metadataRetrieveResponse.audioCodec()).contains("audioCodec") + assertThat(metadataRetrieveResponse.bitRate()).contains(0L) + assertThat(metadataRetrieveResponse.density()).contains(0L) + assertThat(metadataRetrieveResponse.duration()).contains(0L) + assertThat(metadataRetrieveResponse.exif()) + .contains( + MetadataRetrieveResponse.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + MetadataRetrieveResponse.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + assertThat(metadataRetrieveResponse.format()).contains("format") + assertThat(metadataRetrieveResponse.hasColorProfile()).contains(true) + assertThat(metadataRetrieveResponse.hasTransparency()).contains(true) + assertThat(metadataRetrieveResponse.height()).contains(0L) + assertThat(metadataRetrieveResponse.pHash()).contains("pHash") + assertThat(metadataRetrieveResponse.quality()).contains(0L) + assertThat(metadataRetrieveResponse.size()).contains(0L) + assertThat(metadataRetrieveResponse.videoCodec()).contains("videoCodec") + assertThat(metadataRetrieveResponse.width()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val metadataRetrieveResponse = + MetadataRetrieveResponse.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + MetadataRetrieveResponse.Exif.builder() + .exif( + ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) + .image( + ExifImage.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( + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + MetadataRetrieveResponse.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + 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 roundtrippedMetadataRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(metadataRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMetadataRetrieveResponse).isEqualTo(metadataRetrieveResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParamsTest.kt new file mode 100644 index 00000000..0fbd833e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.purge + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PurgeExecuteParamsTest { + + @Test + fun create() { + PurgeExecuteParams.builder() + .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + .build() + } + + @Test + fun body() { + val params = + PurgeExecuteParams.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/files/purge/PurgeExecuteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponseTest.kt new file mode 100644 index 00000000..37cce050 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.purge + +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 PurgeExecuteResponseTest { + + @Test + fun create() { + val purgeExecuteResponse = PurgeExecuteResponse.builder().requestId("requestId").build() + + assertThat(purgeExecuteResponse.requestId()).contains("requestId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val purgeExecuteResponse = PurgeExecuteResponse.builder().requestId("requestId").build() + + val roundtrippedPurgeExecuteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(purgeExecuteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPurgeExecuteResponse).isEqualTo(purgeExecuteResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParamsTest.kt new file mode 100644 index 00000000..ac95f1a3 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.purge + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PurgeStatusParamsTest { + + @Test + fun create() { + PurgeStatusParams.builder().requestId("requestId").build() + } + + @Test + fun pathParams() { + val params = PurgeStatusParams.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/files/purge/PurgeStatusResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponseTest.kt new file mode 100644 index 00000000..6c9c7f80 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.purge + +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 PurgeStatusResponseTest { + + @Test + fun create() { + val purgeStatusResponse = + PurgeStatusResponse.builder().status(PurgeStatusResponse.Status.COMPLETED).build() + + assertThat(purgeStatusResponse.status()).contains(PurgeStatusResponse.Status.COMPLETED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val purgeStatusResponse = + PurgeStatusResponse.builder().status(PurgeStatusResponse.Status.COMPLETED).build() + + val roundtrippedPurgeStatusResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(purgeStatusResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPurgeStatusResponse).isEqualTo(purgeStatusResponse) + } +} 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/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/VersionListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt new file mode 100644 index 00000000..fcbaa63f --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt @@ -0,0 +1,125 @@ +// 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.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 VersionListResponseTest { + + @Test + fun create() { + val versionListResponse = + VersionListResponse.builder() + .addAiTag( + VersionListResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + VersionListResponse.VersionInfo.builder().id("id").name("name").build() + ) + .width(0.0) + .build() + + assertThat(versionListResponse.aiTags().getOrNull()) + .containsExactly( + VersionListResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(versionListResponse.createdAt()).contains("createdAt") + assertThat(versionListResponse.customCoordinates()).contains("customCoordinates") + assertThat(versionListResponse._customMetadata()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(versionListResponse.fileId()).contains("fileId") + assertThat(versionListResponse.filePath()).contains("filePath") + assertThat(versionListResponse.fileType()).contains("fileType") + assertThat(versionListResponse.hasAlpha()).contains(true) + assertThat(versionListResponse.height()).contains(0.0) + assertThat(versionListResponse.isPrivateFile()).contains(true) + assertThat(versionListResponse.isPublished()).contains(true) + assertThat(versionListResponse.mime()).contains("mime") + assertThat(versionListResponse.name()).contains("name") + assertThat(versionListResponse.size()).contains(0.0) + assertThat(versionListResponse.tags().getOrNull()).containsExactly("string") + assertThat(versionListResponse.thumbnail()).contains("thumbnail") + assertThat(versionListResponse.type()).contains("type") + assertThat(versionListResponse.updatedAt()).contains("updatedAt") + assertThat(versionListResponse.url()).contains("url") + assertThat(versionListResponse.versionInfo()) + .contains(VersionListResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(versionListResponse.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val versionListResponse = + VersionListResponse.builder() + .addAiTag( + VersionListResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + VersionListResponse.VersionInfo.builder().id("id").name("name").build() + ) + .width(0.0) + .build() + + val roundtrippedVersionListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(versionListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVersionListResponse).isEqualTo(versionListResponse) + } +} 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/files/versions/VersionRestoreResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt new file mode 100644 index 00000000..2d330753 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt @@ -0,0 +1,170 @@ +// 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.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 VersionRestoreResponseTest { + + @Test + fun create() { + val versionRestoreResponse = + VersionRestoreResponse.builder() + .addAiTag( + VersionRestoreResponse.AiTag.builder() + .confidence(90.12) + .name("Shirt") + .source("google-auto-tagging") + .build() + ) + .addAiTag( + VersionRestoreResponse.AiTag.builder() + .confidence(80.12) + .name("T-shirt") + .source("aws-auto-tagging") + .build() + ) + .createdAt("2019-08-24T06:14:41.313Z") + .customCoordinates(null) + .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .fileId("598821f949c0a938d57563bd") + .filePath("/images/products/file.jpg") + .fileType("image") + .hasAlpha(false) + .height(100.0) + .isPrivateFile(false) + .isPublished(true) + .mime("image/jpeg") + .name("file.jpg") + .size(100.0) + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .thumbnail( + "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" + ) + .type("file") + .updatedAt("2019-08-24T06:14:41.313Z") + .url( + "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" + ) + .versionInfo( + VersionRestoreResponse.VersionInfo.builder() + .id("598821f949c0a938d57563bd") + .name("Version 2") + .build() + ) + .width(100.0) + .build() + + assertThat(versionRestoreResponse.aiTags().getOrNull()) + .containsExactly( + VersionRestoreResponse.AiTag.builder() + .confidence(90.12) + .name("Shirt") + .source("google-auto-tagging") + .build(), + VersionRestoreResponse.AiTag.builder() + .confidence(80.12) + .name("T-shirt") + .source("aws-auto-tagging") + .build(), + ) + assertThat(versionRestoreResponse.createdAt()).contains("2019-08-24T06:14:41.313Z") + assertThat(versionRestoreResponse.customCoordinates()).isEmpty + assertThat(versionRestoreResponse._customMetadata()) + .isEqualTo(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + assertThat(versionRestoreResponse.fileId()).contains("598821f949c0a938d57563bd") + assertThat(versionRestoreResponse.filePath()).contains("/images/products/file.jpg") + assertThat(versionRestoreResponse.fileType()).contains("image") + assertThat(versionRestoreResponse.hasAlpha()).contains(false) + assertThat(versionRestoreResponse.height()).contains(100.0) + assertThat(versionRestoreResponse.isPrivateFile()).contains(false) + assertThat(versionRestoreResponse.isPublished()).contains(true) + assertThat(versionRestoreResponse.mime()).contains("image/jpeg") + assertThat(versionRestoreResponse.name()).contains("file.jpg") + assertThat(versionRestoreResponse.size()).contains(100.0) + assertThat(versionRestoreResponse.tags().getOrNull()) + .containsExactly("t-shirt", "round-neck", "sale2019") + assertThat(versionRestoreResponse.thumbnail()) + .contains( + "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" + ) + assertThat(versionRestoreResponse.type()).contains("file") + assertThat(versionRestoreResponse.updatedAt()).contains("2019-08-24T06:14:41.313Z") + assertThat(versionRestoreResponse.url()) + .contains( + "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" + ) + assertThat(versionRestoreResponse.versionInfo()) + .contains( + VersionRestoreResponse.VersionInfo.builder() + .id("598821f949c0a938d57563bd") + .name("Version 2") + .build() + ) + assertThat(versionRestoreResponse.width()).contains(100.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val versionRestoreResponse = + VersionRestoreResponse.builder() + .addAiTag( + VersionRestoreResponse.AiTag.builder() + .confidence(90.12) + .name("Shirt") + .source("google-auto-tagging") + .build() + ) + .addAiTag( + VersionRestoreResponse.AiTag.builder() + .confidence(80.12) + .name("T-shirt") + .source("aws-auto-tagging") + .build() + ) + .createdAt("2019-08-24T06:14:41.313Z") + .customCoordinates(null) + .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .fileId("598821f949c0a938d57563bd") + .filePath("/images/products/file.jpg") + .fileType("image") + .hasAlpha(false) + .height(100.0) + .isPrivateFile(false) + .isPublished(true) + .mime("image/jpeg") + .name("file.jpg") + .size(100.0) + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .thumbnail( + "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" + ) + .type("file") + .updatedAt("2019-08-24T06:14:41.313Z") + .url( + "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" + ) + .versionInfo( + VersionRestoreResponse.VersionInfo.builder() + .id("598821f949c0a938d57563bd") + .name("Version 2") + .build() + ) + .width(100.0) + .build() + + val roundtrippedVersionRestoreResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(versionRestoreResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVersionRestoreResponse).isEqualTo(versionRestoreResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParamsTest.kt new file mode 100644 index 00000000..8d352a30 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParamsTest.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 VersionRetrieveParamsTest { + + @Test + fun create() { + VersionRetrieveParams.builder().fileId("fileId").versionId("versionId").build() + } + + @Test + fun pathParams() { + val params = VersionRetrieveParams.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/VersionRetrieveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponseTest.kt new file mode 100644 index 00000000..4933bb17 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponseTest.kt @@ -0,0 +1,125 @@ +// 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.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 VersionRetrieveResponseTest { + + @Test + fun create() { + val versionRetrieveResponse = + VersionRetrieveResponse.builder() + .addAiTag( + VersionRetrieveResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + VersionRetrieveResponse.VersionInfo.builder().id("id").name("name").build() + ) + .width(0.0) + .build() + + assertThat(versionRetrieveResponse.aiTags().getOrNull()) + .containsExactly( + VersionRetrieveResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(versionRetrieveResponse.createdAt()).contains("createdAt") + assertThat(versionRetrieveResponse.customCoordinates()).contains("customCoordinates") + assertThat(versionRetrieveResponse._customMetadata()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(versionRetrieveResponse.fileId()).contains("fileId") + assertThat(versionRetrieveResponse.filePath()).contains("filePath") + assertThat(versionRetrieveResponse.fileType()).contains("fileType") + assertThat(versionRetrieveResponse.hasAlpha()).contains(true) + assertThat(versionRetrieveResponse.height()).contains(0.0) + assertThat(versionRetrieveResponse.isPrivateFile()).contains(true) + assertThat(versionRetrieveResponse.isPublished()).contains(true) + assertThat(versionRetrieveResponse.mime()).contains("mime") + assertThat(versionRetrieveResponse.name()).contains("name") + assertThat(versionRetrieveResponse.size()).contains(0.0) + assertThat(versionRetrieveResponse.tags().getOrNull()).containsExactly("string") + assertThat(versionRetrieveResponse.thumbnail()).contains("thumbnail") + assertThat(versionRetrieveResponse.type()).contains("type") + assertThat(versionRetrieveResponse.updatedAt()).contains("updatedAt") + assertThat(versionRetrieveResponse.url()).contains("url") + assertThat(versionRetrieveResponse.versionInfo()) + .contains(VersionRetrieveResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(versionRetrieveResponse.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val versionRetrieveResponse = + VersionRetrieveResponse.builder() + .addAiTag( + VersionRetrieveResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + VersionRetrieveResponse.VersionInfo.builder().id("id").name("name").build() + ) + .width(0.0) + .build() + + val roundtrippedVersionRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(versionRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVersionRetrieveResponse).isEqualTo(versionRetrieveResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateParamsTest.kt new file mode 100644 index 00000000..7d25e9a6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folder + +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/folder/FolderCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateResponseTest.kt new file mode 100644 index 00000000..0bca32b6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folder + +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/folder/FolderDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteParamsTest.kt new file mode 100644 index 00000000..b4ec8b25 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folder + +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/folder/FolderDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteResponseTest.kt new file mode 100644 index 00000000..478b1ca1 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folder + +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/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt new file mode 100644 index 00000000..96c27b41 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -0,0 +1,929 @@ +// 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.FileUploadV1Params +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 filesUploadV1_400() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_400WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_401() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_401WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_403() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_403WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_404() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_404WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_422() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_422WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_429() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_429WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_500() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_500WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_999() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1_999WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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 filesUploadV1InvalidJsonBody() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) + + val e = + assertThrows { + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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..648e4af9 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -0,0 +1,89 @@ +// 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.FileUploadV1Params +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 uploadV1() { + val fileService = client.files() + stubFor(post(anyUrl()).willReturn(ok("{}"))) + + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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/AccountServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AccountServiceAsyncTest.kt new file mode 100644 index 00000000..447db8f3 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AccountServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// 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.accounts.AccountGetUsageParams +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 AccountServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun getUsage() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val accountServiceAsync = client.accounts() + + val responseFuture = + accountServiceAsync.getUsage( + AccountGetUsageParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncTest.kt new file mode 100644 index 00000000..53282310 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncTest.kt @@ -0,0 +1,79 @@ +// 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.bulkjobs.BulkJobCopyFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkJobServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun copyFolder() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkJobServiceAsync = client.bulkJobs() + + val responseFuture = + bulkJobServiceAsync.copyFolder( + BulkJobCopyFolderParams.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 moveFolder() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkJobServiceAsync = client.bulkJobs() + + val responseFuture = + bulkJobServiceAsync.moveFolder( + BulkJobMoveFolderParams.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 retrieveStatus() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkJobServiceAsync = client.bulkJobs() + + val responseFuture = bulkJobServiceAsync.retrieveStatus("jobId") + + val response = responseFuture.get() + response.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..cc8b78d6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -0,0 +1,304 @@ +// 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.files.FileAddTagsParams +import com.imagekit.api.models.files.FileCopyParams +import com.imagekit.api.models.files.FileListParams +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileRemoveAiTagsParams +import com.imagekit.api.models.files.FileRemoveTagsParams +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileUploadV1Params +import com.imagekit.api.models.files.FileUploadV2Params +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 list() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val filesFuture = + fileServiceAsync.list( + FileListParams.builder() + .fileType("fileType") + .limit("limit") + .path("path") + .searchQuery("searchQuery") + .skip("skip") + .sort("sort") + .type(FileListParams.Type.FILE) + .build() + ) + + 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 fileServiceAsync = client.files() + + val future = fileServiceAsync.delete("fileId") + + val response = future.get() + } + + @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 fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.addTags( + FileAddTagsParams.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 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 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 removeAiTags() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.removeAiTags( + FileRemoveAiTagsParams.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 fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.removeTags( + FileRemoveTagsParams.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 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 uploadV1() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun uploadV2() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.uploadV2( + FileUploadV2Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV2Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV2Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV2Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV2Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV2Params.OverwriteTags.TRUE) + .responseFields("responseFields") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV2Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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..fd310639 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt @@ -0,0 +1,58 @@ +// 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.folder.FolderCreateParams +import com.imagekit.api.models.folder.FolderDeleteParams +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.folder() + + 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.folder() + + val folderFuture = + folderServiceAsync.delete( + FolderDeleteParams.builder().folderPath("/folder/to/delete/").build() + ) + + val folder = folderFuture.get() + folder.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncTest.kt new file mode 100644 index 00000000..bae3c702 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncTest.kt @@ -0,0 +1,37 @@ +// 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.batch.BatchDeleteParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BatchServiceAsyncTest { + + @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 batchServiceAsync = client.files().batch() + + val batchFuture = + batchServiceAsync.delete( + BatchDeleteParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + ) + + val batch = batchFuture.get() + batch.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncTest.kt new file mode 100644 index 00000000..5ffd2a18 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncTest.kt @@ -0,0 +1,128 @@ +// 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.core.JsonValue +import com.imagekit.api.models.files.details.DetailUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DetailServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val detailServiceAsync = client.files().details() + + val detailFuture = detailServiceAsync.retrieve("fileId") + + val detail = detailFuture.get() + detail.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 detailServiceAsync = client.files().details() + + val detailFuture = + detailServiceAsync.update( + DetailUpdateParams.builder() + .fileId("fileId") + .body( + DetailUpdateParams.Body.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + JsonValue.from(mapOf("brand" to "Nike", "color" to "red")) + ) + .extensions( + listOf( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .ofRemovedotBg( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + DetailUpdateParams.Body.UpdateFileDetails + .Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + DetailUpdateParams.Body.UpdateFileDetails + .Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension + .ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails + .Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension + .ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails + .Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) + .build() + ) + + val detail = detailFuture.get() + detail.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..1dd5de70 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt @@ -0,0 +1,49 @@ +// 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.MetadataFromUrlParams +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 retrieve() { + 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.retrieve("fileId") + + val metadata = metadataFuture.get() + metadata.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun fromUrl() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val metadataServiceAsync = client.files().metadata() + + val responseFuture = + metadataServiceAsync.fromUrl(MetadataFromUrlParams.builder().url("url").build()) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncTest.kt new file mode 100644 index 00000000..8204860a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncTest.kt @@ -0,0 +1,53 @@ +// 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.purge.PurgeExecuteParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PurgeServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun execute() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val purgeServiceAsync = client.files().purge() + + val responseFuture = + purgeServiceAsync.execute( + PurgeExecuteParams.builder() + .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun status() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val purgeServiceAsync = client.files().purge() + + val responseFuture = purgeServiceAsync.status("requestId") + + val response = responseFuture.get() + response.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..89ee14cc --- /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.VersionRestoreParams +import com.imagekit.api.models.files.versions.VersionRetrieveParams +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 retrieve() { + 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.retrieve( + VersionRetrieveParams.builder().fileId("fileId").versionId("versionId").build() + ) + + val version = versionFuture.get() + version.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 versionServiceAsync = client.files().versions() + + val versionsFuture = versionServiceAsync.list("fileId") + + val versions = versionsFuture.get() + versions.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 restore() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionServiceAsync = client.files().versions() + + val responseFuture = + versionServiceAsync.restore( + VersionRestoreParams.builder().fileId("fileId").versionId("versionId").build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AccountServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AccountServiceTest.kt new file mode 100644 index 00000000..6a2abd3c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AccountServiceTest.kt @@ -0,0 +1,37 @@ +// 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.accounts.AccountGetUsageParams +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 AccountServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun getUsage() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val accountService = client.accounts() + + val response = + accountService.getUsage( + AccountGetUsageParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/BulkJobServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/BulkJobServiceTest.kt new file mode 100644 index 00000000..1415b6e0 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/BulkJobServiceTest.kt @@ -0,0 +1,76 @@ +// 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.bulkjobs.BulkJobCopyFolderParams +import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkJobServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun copyFolder() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkJobService = client.bulkJobs() + + val response = + bulkJobService.copyFolder( + BulkJobCopyFolderParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .includeVersions(true) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun moveFolder() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkJobService = client.bulkJobs() + + val response = + bulkJobService.moveFolder( + BulkJobMoveFolderParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveStatus() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkJobService = client.bulkJobs() + + val response = bulkJobService.retrieveStatus("jobId") + + response.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..ed90880e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -0,0 +1,293 @@ +// 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.files.FileAddTagsParams +import com.imagekit.api.models.files.FileCopyParams +import com.imagekit.api.models.files.FileListParams +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileRemoveAiTagsParams +import com.imagekit.api.models.files.FileRemoveTagsParams +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileUploadV1Params +import com.imagekit.api.models.files.FileUploadV2Params +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 list() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val files = + fileService.list( + FileListParams.builder() + .fileType("fileType") + .limit("limit") + .path("path") + .searchQuery("searchQuery") + .skip("skip") + .sort("sort") + .type(FileListParams.Type.FILE) + .build() + ) + + 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 fileService = client.files() + + fileService.delete("fileId") + } + + @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 fileService = client.files() + + val response = + fileService.addTags( + FileAddTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + ) + + response.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 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 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 removeAiTags() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val response = + fileService.removeAiTags( + FileRemoveAiTagsParams.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 fileService = client.files() + + val response = + fileService.removeTags( + FileRemoveTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .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 uploadV1() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val response = + fileService.uploadV1( + FileUploadV1Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .expire("expire") + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV1Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .publicKey("publicKey") + .responseFields("responseFields") + .signature("signature") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun uploadV2() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val response = + fileService.uploadV2( + FileUploadV2Params.builder() + .file("https://www.example.com/rest-of-the-image-path.jpg") + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + ) + .extensions( + "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + ) + .folder("folder") + .isPrivateFile(FileUploadV2Params.IsPrivateFile.TRUE) + .isPublished(FileUploadV2Params.IsPublished.TRUE) + .overwriteAiTags(FileUploadV2Params.OverwriteAiTags.TRUE) + .overwriteCustomMetadata(FileUploadV2Params.OverwriteCustomMetadata.TRUE) + .overwriteFile("overwriteFile") + .overwriteTags(FileUploadV2Params.OverwriteTags.TRUE) + .responseFields("responseFields") + .tags("t-shirt,round-neck,men") + .transformation( + "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + ) + .useUniqueFileName(FileUploadV2Params.UseUniqueFileName.TRUE) + .webhookUrl("webhookUrl") + .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..64b86567 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt @@ -0,0 +1,56 @@ +// 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.folder.FolderCreateParams +import com.imagekit.api.models.folder.FolderDeleteParams +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.folder() + + 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.folder() + + val folder = + folderService.delete( + FolderDeleteParams.builder().folderPath("/folder/to/delete/").build() + ) + + folder.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BatchServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BatchServiceTest.kt new file mode 100644 index 00000000..843205f0 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BatchServiceTest.kt @@ -0,0 +1,36 @@ +// 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.batch.BatchDeleteParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BatchServiceTest { + + @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 batchService = client.files().batch() + + val batch = + batchService.delete( + BatchDeleteParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + ) + + batch.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/DetailServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/DetailServiceTest.kt new file mode 100644 index 00000000..1952294b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/DetailServiceTest.kt @@ -0,0 +1,126 @@ +// 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.core.JsonValue +import com.imagekit.api.models.files.details.DetailUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DetailServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val detailService = client.files().details() + + val detail = detailService.retrieve("fileId") + + detail.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 detailService = client.files().details() + + val detail = + detailService.update( + DetailUpdateParams.builder() + .fileId("fileId") + .body( + DetailUpdateParams.Body.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + JsonValue.from(mapOf("brand" to "Nike", "color" to "red")) + ) + .extensions( + listOf( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .ofRemovedotBg( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + DetailUpdateParams.Body.UpdateFileDetails + .Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + DetailUpdateParams.Body.UpdateFileDetails + .Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension + .ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails + .Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + DetailUpdateParams.Body.UpdateFileDetails.Extension + .ofAutoTagging( + DetailUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + DetailUpdateParams.Body.UpdateFileDetails + .Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) + .build() + ) + + detail.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..cbf5e594 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt @@ -0,0 +1,46 @@ +// 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.MetadataFromUrlParams +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 retrieve() { + 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.retrieve("fileId") + + metadata.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun fromUrl() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val metadataService = client.files().metadata() + + val response = metadataService.fromUrl(MetadataFromUrlParams.builder().url("url").build()) + + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceTest.kt new file mode 100644 index 00000000..7f2e4404 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceTest.kt @@ -0,0 +1,51 @@ +// 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.purge.PurgeExecuteParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PurgeServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun execute() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val purgeService = client.files().purge() + + val response = + purgeService.execute( + PurgeExecuteParams.builder() + .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun status() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val purgeService = client.files().purge() + + val response = purgeService.status("requestId") + + response.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..834b3d32 --- /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.VersionRestoreParams +import com.imagekit.api.models.files.versions.VersionRetrieveParams +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 retrieve() { + 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.retrieve( + VersionRetrieveParams.builder().fileId("fileId").versionId("versionId").build() + ) + + version.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 versionService = client.files().versions() + + val versions = versionService.list("fileId") + + versions.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 restore() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionService = client.files().versions() + + val response = + versionService.restore( + VersionRestoreParams.builder().fileId("fileId").versionId("versionId").build() + ) + + response.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..11db2fec --- /dev/null +++ b/image-kit-java-proguard-test/build.gradle.kts @@ -0,0 +1,103 @@ +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") + + dontwarn() + + 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..1e5ed845 --- /dev/null +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,102 @@ +// 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.jsonMapper +import com.imagekit.api.models.files.ExifDetails +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.folder()).isNotNull() + assertThat(client.bulkJobs()).isNotNull() + assertThat(client.accounts()).isNotNull() + } + + @Test + fun exifDetailsRoundtrip() { + val jsonMapper = jsonMapper() + val exifDetails = + ExifDetails.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() + + val roundtrippedExifDetails = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exifDetails), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExifDetails).isEqualTo(exifDetails) + } +} diff --git a/image-kit-java-proguard-test/test.pro b/image-kit-java-proguard-test/test.pro new file mode 100644 index 00000000..4dff75bf --- /dev/null +++ b/image-kit-java-proguard-test/test.pro @@ -0,0 +1,8 @@ +# 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. +-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/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..7c0be4d5 --- /dev/null +++ b/scripts/format @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running formatters" +./gradlew format diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..aea8af71 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running lints" +./gradlew lint 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.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 61631e4bce3e1982ba1619cf4ee8c8fb9745d3c7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 16 Aug 2025 17:09:30 +0000 Subject: [PATCH 003/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e0223abb..eed320bb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 31 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0ffd73f83f6d2c3ad75d943fab8f4511847a7b1f8db10fb26a08f075ec814cc9.yml openapi_spec_hash: afa5d5b601dc01949e9b9acff127ae0d -config_hash: d5947210e5a105aee14f8dc6b47ba6bb +config_hash: a1e8435842b619cd75c7718d86640d26 From a2492cfc9fd9d063c27c073f6ef75338cfe1247c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 Aug 2025 06:01:36 +0000 Subject: [PATCH 004/125] feat(api): manual updates --- .stats.yml | 8 +- README.md | 154 +- .../com/imagekit/api/client/ImageKitClient.kt | 20 +- .../api/client/ImageKitClientAsync.kt | 20 +- .../api/client/ImageKitClientAsyncImpl.kt | 54 +- .../imagekit/api/client/ImageKitClientImpl.kt | 48 +- .../accounts/origins/OriginCreateParams.kt | 5225 +++++++ .../accounts/origins/OriginCreateResponse.kt | 4589 ++++++ .../accounts/origins/OriginDeleteParams.kt | 239 + .../accounts/origins/OriginGetParams.kt | 196 + .../accounts/origins/OriginGetResponse.kt | 4586 ++++++ .../accounts/origins/OriginListParams.kt | 173 + .../accounts/origins/OriginListResponse.kt | 4586 ++++++ .../accounts/origins/OriginUpdateParams.kt | 5253 +++++++ .../accounts/origins/OriginUpdateResponse.kt | 4589 ++++++ .../urlendpoints/UrlEndpointCreateParams.kt | 1818 +++ .../urlendpoints/UrlEndpointCreateResponse.kt | 1497 ++ .../urlendpoints/UrlEndpointDeleteParams.kt | 241 + .../urlendpoints/UrlEndpointGetParams.kt | 197 + .../urlendpoints/UrlEndpointGetResponse.kt | 1497 ++ .../urlendpoints/UrlEndpointListParams.kt | 173 + .../urlendpoints/UrlEndpointListResponse.kt | 1497 ++ .../urlendpoints/UrlEndpointUpdateParams.kt | 1844 +++ .../urlendpoints/UrlEndpointUpdateResponse.kt | 1497 ++ .../UsageGetParams.kt} | 28 +- .../UsageGetResponse.kt} | 34 +- .../api/models/assets/AssetListParams.kt | 865 ++ .../api/models/assets/AssetListResponse.kt | 2070 +++ .../models/beta/v2/files/FileUploadParams.kt | 5846 ++++++++ .../beta/v2/files/FileUploadResponse.kt | 5880 ++++++++ .../invalidation/InvalidationCreateParams.kt} | 26 +- .../InvalidationCreateResponse.kt} | 28 +- .../invalidation/InvalidationGetParams.kt} | 32 +- .../invalidation/InvalidationGetResponse.kt} | 26 +- .../CustomMetadataFieldCreateParams.kt | 10 +- .../CustomMetadataFieldCreateResponse.kt | 10 +- .../CustomMetadataFieldListParams.kt | 10 +- .../CustomMetadataFieldListResponse.kt | 10 +- .../CustomMetadataFieldUpdateResponse.kt | 10 +- .../imagekit/api/models/files/ExifDetails.kt | 1142 -- .../imagekit/api/models/files/ExifImage.kt | 522 - ...tailRetrieveParams.kt => FileGetParams.kt} | 28 +- ...FileListResponse.kt => FileGetResponse.kt} | 64 +- .../api/models/files/FileListParams.kt | 553 - ...ailUpdateParams.kt => FileUpdateParams.kt} | 425 +- ...pdateResponse.kt => FileUpdateResponse.kt} | 262 +- .../api/models/files/FileUploadParams.kt | 6112 ++++++++ .../api/models/files/FileUploadResponse.kt | 5880 ++++++++ .../api/models/files/FileUploadV1Params.kt | 3127 ---- .../api/models/files/FileUploadV1Response.kt | 11793 ---------------- .../api/models/files/FileUploadV2Params.kt | 2861 ---- .../api/models/files/FileUploadV2Response.kt | 11793 ---------------- .../api/models/files/Interoperability.kt | 201 - .../imagekit/api/models/files/Thumbnail.kt | 359 - .../BulkAddTagsParams.kt} | 26 +- .../BulkAddTagsResponse.kt} | 26 +- .../BulkDeleteParams.kt} | 30 +- .../BulkDeleteResponse.kt} | 26 +- .../BulkRemoveAiTagsParams.kt} | 26 +- .../BulkRemoveAiTagsResponse.kt} | 26 +- .../BulkRemoveTagsParams.kt} | 26 +- .../BulkRemoveTagsResponse.kt} | 26 +- .../files/details/DetailRetrieveResponse.kt | 1353 -- .../files/metadata/MetadataFromUrlResponse.kt | 1110 -- ...lParams.kt => MetadataGetFromUrlParams.kt} | 24 +- .../metadata/MetadataGetFromUrlResponse.kt | 3576 +++++ ...RetrieveParams.kt => MetadataGetParams.kt} | 26 +- .../files/metadata/MetadataGetResponse.kt | 3574 +++++ .../metadata/MetadataRetrieveResponse.kt | 1110 -- ...nRetrieveParams.kt => VersionGetParams.kt} | 26 +- ...rieveResponse.kt => VersionGetResponse.kt} | 64 +- .../FolderCopyParams.kt} | 30 +- .../FolderCopyResponse.kt} | 28 +- .../{folder => folders}/FolderCreateParams.kt | 2 +- .../FolderCreateResponse.kt | 2 +- .../{folder => folders}/FolderDeleteParams.kt | 2 +- .../FolderDeleteResponse.kt | 2 +- .../FolderMoveParams.kt} | 30 +- .../FolderMoveResponse.kt} | 28 +- .../api/models/folders/FolderRenameParams.kt | 646 + .../FolderRenameResponse.kt} | 87 +- .../job/JobGetParams.kt} | 34 +- .../job/JobGetResponse.kt} | 89 +- .../api/services/async/AccountServiceAsync.kt | 41 +- .../services/async/AccountServiceAsyncImpl.kt | 86 +- .../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/BulkJobServiceAsync.kt | 186 - .../services/async/BulkJobServiceAsyncImpl.kt | 170 - .../api/services/async/CacheServiceAsync.kt | 39 + .../services/async/CacheServiceAsyncImpl.kt | 44 + .../api/services/async/FileServiceAsync.kt | 368 +- .../services/async/FileServiceAsyncImpl.kt | 273 +- .../api/services/async/FolderServiceAsync.kt | 104 +- .../services/async/FolderServiceAsyncImpl.kt | 140 +- .../async/accounts/OriginServiceAsync.kt | 314 + .../async/accounts/OriginServiceAsyncImpl.kt | 248 + .../async/accounts/UrlEndpointServiceAsync.kt | 323 + .../accounts/UrlEndpointServiceAsyncImpl.kt | 248 + .../async/accounts/UsageServiceAsync.kt | 66 + .../UsageServiceAsyncImpl.kt} | 52 +- .../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 + .../InvalidationServiceAsyncImpl.kt} | 68 +- .../services/async/files/BatchServiceAsync.kt | 72 - .../services/async/files/BulkServiceAsync.kt | 160 + .../async/files/BulkServiceAsyncImpl.kt | 206 + .../async/files/DetailServiceAsync.kt | 201 - .../async/files/DetailServiceAsyncImpl.kt | 133 - .../async/files/MetadataServiceAsync.kt | 137 +- .../async/files/MetadataServiceAsyncImpl.kt | 48 +- .../services/async/files/PurgeServiceAsync.kt | 145 - .../async/files/VersionServiceAsync.kt | 109 +- .../async/files/VersionServiceAsyncImpl.kt | 84 +- .../services/async/folders/JobServiceAsync.kt | 107 + .../async/folders/JobServiceAsyncImpl.kt | 89 + .../api/services/blocking/AccountService.kt | 41 +- .../services/blocking/AccountServiceImpl.kt | 80 +- .../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/BulkJobService.kt | 185 - .../services/blocking/BulkJobServiceImpl.kt | 160 - .../api/services/blocking/CacheService.kt | 37 + .../api/services/blocking/CacheServiceImpl.kt | 42 + .../api/services/blocking/FileService.kt | 340 +- .../api/services/blocking/FileServiceImpl.kt | 261 +- .../api/services/blocking/FolderService.kt | 106 +- .../services/blocking/FolderServiceImpl.kt | 131 +- .../blocking/accounts/OriginService.kt | 301 + .../blocking/accounts/OriginServiceImpl.kt | 227 + .../blocking/accounts/UrlEndpointService.kt | 322 + .../accounts/UrlEndpointServiceImpl.kt | 230 + .../blocking/accounts/UsageService.kt | 65 + .../UsageServiceImpl.kt} | 51 +- .../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 + .../InvalidationServiceImpl.kt} | 68 +- .../services/blocking/files/BatchService.kt | 70 - .../services/blocking/files/BulkService.kt | 160 + .../blocking/files/BulkServiceImpl.kt | 192 + .../services/blocking/files/DetailService.kt | 194 - .../blocking/files/DetailServiceImpl.kt | 126 - .../blocking/files/MetadataService.kt | 121 +- .../blocking/files/MetadataServiceImpl.kt | 48 +- .../services/blocking/files/PurgeService.kt | 141 - .../services/blocking/files/VersionService.kt | 107 +- .../blocking/files/VersionServiceImpl.kt | 81 +- .../services/blocking/folders/JobService.kt | 104 + .../blocking/folders/JobServiceImpl.kt | 81 + .../accounts/AccountGetUsageResponseTest.kt | 50 - .../origins/OriginCreateParamsTest.kt | 95 + .../origins/OriginCreateResponseTest.kt | 437 + .../origins/OriginDeleteParamsTest.kt | 23 + .../accounts/origins/OriginGetParamsTest.kt | 23 + .../accounts/origins/OriginGetResponseTest.kt | 436 + .../accounts/origins/OriginListParamsTest.kt | 13 + .../origins/OriginListResponseTest.kt | 436 + .../origins/OriginUpdateParamsTest.kt | 119 + .../origins/OriginUpdateResponseTest.kt | 437 + .../UrlEndpointCreateParamsTest.kt | 71 + .../UrlEndpointCreateResponseTest.kt | 80 + .../UrlEndpointDeleteParamsTest.kt | 23 + .../urlendpoints/UrlEndpointGetParamsTest.kt | 23 + .../UrlEndpointGetResponseTest.kt | 76 + .../urlendpoints/UrlEndpointListParamsTest.kt | 13 + .../UrlEndpointListResponseTest.kt | 79 + .../UrlEndpointUpdateParamsTest.kt | 84 + .../UrlEndpointUpdateResponseTest.kt | 80 + .../UsageGetParamsTest.kt} | 8 +- .../accounts/usage/UsageGetResponseTest.kt | 50 + .../AssetListParamsTest.kt} | 38 +- .../models/assets/AssetListResponseTest.kt | 170 + .../beta/v2/files/FileUploadParamsTest.kt | 330 + .../beta/v2/files/FileUploadResponseTest.kt | 437 + .../bulkjobs/BulkJobCopyFolderResponseTest.kt | 32 - .../bulkjobs/BulkJobMoveFolderResponseTest.kt | 32 - .../BulkJobRetrieveStatusResponseTest.kt | 45 - .../InvalidationCreateParamsTest.kt} | 8 +- .../InvalidationCreateResponseTest.kt | 34 + .../InvalidationGetParamsTest.kt} | 8 +- .../InvalidationGetResponseTest.kt | 39 + .../api/models/files/ExifDetailsTest.kt | 113 - .../api/models/files/ExifImageTest.kt | 68 - .../models/files/FileAddTagsResponseTest.kt | 36 - ...ieveParamsTest.kt => FileGetParamsTest.kt} | 8 +- ...ResponseTest.kt => FileGetResponseTest.kt} | 72 +- .../files/FileRemoveAiTagsResponseTest.kt | 36 - .../files/FileRemoveTagsResponseTest.kt | 36 - ...eParamsTest.kt => FileUpdateParamsTest.kt} | 119 +- .../models/files/FileUpdateResponseTest.kt | 154 + .../api/models/files/FileUploadParamsTest.kt | 339 + .../models/files/FileUploadResponseTest.kt | 437 + .../models/files/FileUploadV1ParamsTest.kt | 161 - .../models/files/FileUploadV1ResponseTest.kt | 1335 -- .../models/files/FileUploadV2ParamsTest.kt | 152 - .../models/files/FileUploadV2ResponseTest.kt | 1335 -- .../com/imagekit/api/models/files/GpsTest.kt | 30 - .../api/models/files/InteroperabilityTest.kt | 41 - .../api/models/files/ThumbnailTest.kt | 53 - .../files/batch/BatchDeleteResponseTest.kt | 36 - .../BulkAddTagsParamsTest.kt} | 8 +- .../files/bulk/BulkAddTagsResponseTest.kt | 36 + .../BulkDeleteParamsTest.kt} | 8 +- .../files/bulk/BulkDeleteResponseTest.kt | 36 + .../BulkRemoveAiTagsParamsTest.kt} | 8 +- .../bulk/BulkRemoveAiTagsResponseTest.kt | 36 + .../BulkRemoveTagsParamsTest.kt} | 8 +- .../files/bulk/BulkRemoveTagsResponseTest.kt | 36 + .../details/DetailRetrieveResponseTest.kt | 125 - .../files/details/DetailUpdateResponseTest.kt | 153 - ...est.kt => MetadataGetFromUrlParamsTest.kt} | 9 +- ...t.kt => MetadataGetFromUrlResponseTest.kt} | 101 +- ...ParamsTest.kt => MetadataGetParamsTest.kt} | 6 +- ...onseTest.kt => MetadataGetResponseTest.kt} | 93 +- .../files/purge/PurgeExecuteResponseTest.kt | 32 - .../files/purge/PurgeStatusResponseTest.kt | 34 - ...eParamsTest.kt => VersionGetParamsTest.kt} | 6 +- ...ponseTest.kt => VersionGetResponseTest.kt} | 76 +- .../FolderCopyParamsTest.kt} | 10 +- .../models/folders/FolderCopyResponseTest.kt | 32 + .../FolderCreateParamsTest.kt | 2 +- .../FolderCreateResponseTest.kt | 2 +- .../FolderDeleteParamsTest.kt | 2 +- .../FolderDeleteResponseTest.kt | 2 +- .../FolderMoveParamsTest.kt} | 8 +- .../models/folders/FolderMoveResponseTest.kt | 32 + .../models/folders/FolderRenameParamsTest.kt | 48 + .../folders/FolderRenameResponseTest.kt | 32 + .../job/JobGetParamsTest.kt} | 8 +- .../models/folders/job/JobGetResponseTest.kt | 47 + .../api/services/ErrorHandlingTest.kt | 1736 ++- .../api/services/ServiceParamsTest.kt | 95 +- .../services/async/AssetServiceAsyncTest.kt | 42 + .../services/async/BulkJobServiceAsyncTest.kt | 79 - .../services/async/FileServiceAsyncTest.kt | 327 +- .../services/async/FolderServiceAsyncTest.kt | 82 +- .../async/accounts/OriginServiceAsyncTest.kt | 132 + .../accounts/UrlEndpointServiceAsyncTest.kt | 132 + .../UsageServiceAsyncTest.kt} | 20 +- .../async/beta/v2/FileServiceAsyncTest.kt | 120 + .../InvalidationServiceAsyncTest.kt} | 30 +- .../async/files/BulkServiceAsyncTest.kt | 112 + .../async/files/DetailServiceAsyncTest.kt | 128 - .../async/files/MetadataServiceAsyncTest.kt | 12 +- .../async/files/VersionServiceAsyncTest.kt | 30 +- .../JobServiceAsyncTest.kt} | 21 +- .../api/services/blocking/AssetServiceTest.kt | 41 + .../services/blocking/BulkJobServiceTest.kt | 76 - .../api/services/blocking/FileServiceTest.kt | 320 +- .../services/blocking/FolderServiceTest.kt | 79 +- .../blocking/accounts/OriginServiceTest.kt | 126 + .../accounts/UrlEndpointServiceTest.kt | 126 + .../UsageServiceTest.kt} | 18 +- .../blocking/beta/v2/FileServiceTest.kt | 119 + .../InvalidationServiceTest.kt} | 26 +- .../blocking/files/BulkServiceTest.kt | 108 + .../blocking/files/DetailServiceTest.kt | 126 - .../blocking/files/MetadataServiceTest.kt | 13 +- .../blocking/files/VersionServiceTest.kt | 26 +- .../JobServiceTest.kt} | 19 +- .../api/proguard/ProGuardCompatibilityTest.kt | 139 +- 271 files changed, 90311 insertions(+), 45253 deletions(-) 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/OriginCreateResponse.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/OriginGetResponse.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/OriginListResponse.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/origins/OriginUpdateResponse.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/UrlEndpointCreateResponse.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/UrlEndpointGetResponse.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/UrlEndpointListResponse.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/urlendpoints/UrlEndpointUpdateResponse.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/{AccountGetUsageParams.kt => usage/UsageGetParams.kt} (90%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/{AccountGetUsageResponse.kt => usage/UsageGetResponse.kt} (90%) 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 rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{files/purge/PurgeExecuteParams.kt => cache/invalidation/InvalidationCreateParams.kt} (94%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{files/purge/PurgeExecuteResponse.kt => cache/invalidation/InvalidationCreateResponse.kt} (83%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{files/purge/PurgeStatusParams.kt => cache/invalidation/InvalidationGetParams.kt} (85%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{files/purge/PurgeStatusResponse.kt => cache/invalidation/InvalidationGetResponse.kt} (91%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifDetails.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifImage.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{details/DetailRetrieveParams.kt => FileGetParams.kt} (86%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{FileListResponse.kt => FileGetResponse.kt} (96%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListParams.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{details/DetailUpdateParams.kt => FileUpdateParams.kt} (86%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{details/DetailUpdateResponse.kt => FileUpdateResponse.kt} (88%) 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 delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Params.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Response.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Params.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Response.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Interoperability.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Thumbnail.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{FileAddTagsParams.kt => bulk/BulkAddTagsParams.kt} (96%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{FileAddTagsResponse.kt => bulk/BulkAddTagsResponse.kt} (90%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{batch/BatchDeleteParams.kt => bulk/BulkDeleteParams.kt} (94%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{batch/BatchDeleteResponse.kt => bulk/BulkDeleteResponse.kt} (88%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{FileRemoveAiTagsParams.kt => bulk/BulkRemoveAiTagsParams.kt} (96%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{FileRemoveAiTagsResponse.kt => bulk/BulkRemoveAiTagsResponse.kt} (90%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{FileRemoveTagsParams.kt => bulk/BulkRemoveTagsParams.kt} (96%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{FileRemoveTagsResponse.kt => bulk/BulkRemoveTagsResponse.kt} (90%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponse.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/{MetadataFromUrlParams.kt => MetadataGetFromUrlParams.kt} (89%) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/{MetadataRetrieveParams.kt => MetadataGetParams.kt} (87%) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponse.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/{VersionRetrieveParams.kt => VersionGetParams.kt} (89%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/{VersionRetrieveResponse.kt => VersionGetResponse.kt} (95%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobCopyFolderParams.kt => folders/FolderCopyParams.kt} (96%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobMoveFolderResponse.kt => folders/FolderCopyResponse.kt} (83%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{folder => folders}/FolderCreateParams.kt (99%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{folder => folders}/FolderCreateResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{folder => folders}/FolderDeleteParams.kt (99%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{folder => folders}/FolderDeleteResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobMoveFolderParams.kt => folders/FolderMoveParams.kt} (95%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobCopyFolderResponse.kt => folders/FolderMoveResponse.kt} (83%) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{files/Gps.kt => folders/FolderRenameResponse.kt} (54%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobRetrieveStatusParams.kt => folders/job/JobGetParams.kt} (83%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobRetrieveStatusResponse.kt => folders/job/JobGetResponse.kt} (68%) 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 delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsync.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncImpl.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/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 rename image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/{files/BatchServiceAsyncImpl.kt => accounts/UsageServiceAsyncImpl.kt} (61%) 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 rename image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/{files/PurgeServiceAsyncImpl.kt => cache/InvalidationServiceAsyncImpl.kt} (65%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsync.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 delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsync.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncImpl.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsync.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/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 delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobService.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobServiceImpl.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/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 rename image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/{files/BatchServiceImpl.kt => accounts/UsageServiceImpl.kt} (58%) 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 rename image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/{files/PurgeServiceImpl.kt => cache/InvalidationServiceImpl.kt} (64%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchService.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 delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailService.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailServiceImpl.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeService.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 delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponseTest.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/OriginCreateResponseTest.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/OriginGetResponseTest.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/OriginListResponseTest.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/origins/OriginUpdateResponseTest.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/UrlEndpointCreateResponseTest.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/UrlEndpointGetResponseTest.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/UrlEndpointListResponseTest.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/urlendpoints/UrlEndpointUpdateResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/{AccountGetUsageParamsTest.kt => usage/UsageGetParamsTest.kt} (83%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{files/FileListParamsTest.kt => assets/AssetListParamsTest.kt} (56%) 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 delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{files/purge/PurgeExecuteParamsTest.kt => cache/invalidation/InvalidationCreateParamsTest.kt} (75%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{files/purge/PurgeStatusParamsTest.kt => cache/invalidation/InvalidationGetParamsTest.kt} (60%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifDetailsTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifImageTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{details/DetailRetrieveParamsTest.kt => FileGetParamsTest.kt} (61%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{FileListResponseTest.kt => FileGetResponseTest.kt} (53%) delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{details/DetailUpdateParamsTest.kt => FileUpdateParamsTest.kt} (61%) 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 delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ParamsTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ParamsTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/GpsTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/InteroperabilityTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ThumbnailTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{FileAddTagsParamsTest.kt => bulk/BulkAddTagsParamsTest.kt} (84%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{batch/BatchDeleteParamsTest.kt => bulk/BulkDeleteParamsTest.kt} (80%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{FileRemoveAiTagsParamsTest.kt => bulk/BulkRemoveAiTagsParamsTest.kt} (83%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{FileRemoveTagsParamsTest.kt => bulk/BulkRemoveTagsParamsTest.kt} (83%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/{MetadataFromUrlParamsTest.kt => MetadataGetFromUrlParamsTest.kt} (52%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/{MetadataRetrieveResponseTest.kt => MetadataGetFromUrlResponseTest.kt} (75%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/{MetadataRetrieveParamsTest.kt => MetadataGetParamsTest.kt} (68%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/{MetadataFromUrlResponseTest.kt => MetadataGetResponseTest.kt} (78%) delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/{VersionRetrieveParamsTest.kt => VersionGetParamsTest.kt} (67%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/{VersionRetrieveResponseTest.kt => VersionGetResponseTest.kt} (50%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobCopyFolderParamsTest.kt => folders/FolderCopyParamsTest.kt} (85%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{folder => folders}/FolderCreateParamsTest.kt (94%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{folder => folders}/FolderCreateResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{folder => folders}/FolderDeleteParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{folder => folders}/FolderDeleteResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobMoveFolderParamsTest.kt => folders/FolderMoveParamsTest.kt} (80%) 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 rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{bulkjobs/BulkJobRetrieveStatusParamsTest.kt => folders/job/JobGetParamsTest.kt} (60%) 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/services/async/AssetServiceAsyncTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncTest.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 rename image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/{AccountServiceAsyncTest.kt => accounts/UsageServiceAsyncTest.kt} (66%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/{files/PurgeServiceAsyncTest.kt => cache/InvalidationServiceAsyncTest.kt} (59%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/{files/BatchServiceAsyncTest.kt => folders/JobServiceAsyncTest.kt} (53%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/BulkJobServiceTest.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 rename image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/{AccountServiceTest.kt => accounts/UsageServiceTest.kt} (70%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/{files/PurgeServiceTest.kt => cache/InvalidationServiceTest.kt} (64%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/DetailServiceTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/{files/BatchServiceTest.kt => folders/JobServiceTest.kt} (55%) diff --git a/.stats.yml b/.stats.yml index eed320bb..ee7ab859 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 31 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0ffd73f83f6d2c3ad75d943fab8f4511847a7b1f8db10fb26a08f075ec814cc9.yml -openapi_spec_hash: afa5d5b601dc01949e9b9acff127ae0d -config_hash: a1e8435842b619cd75c7718d86640d26 +configured_endpoints: 42 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c01164d5dc8f8c9ab2b7c1a1c793ac522d565f96e569b0e56a4e9353e39bab85.yml +openapi_spec_hash: ac7b3a2b968fe86bf7bb81192209123f +config_hash: 8a4138f8d02720b4736ab63effb7fa2d diff --git a/README.md b/README.md index 607670b1..cb3ea8a9 100644 --- a/README.md +++ b/README.md @@ -36,18 +36,19 @@ This library requires Java 8 or later. ```java import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import com.imagekit.api.models.files.FileUploadV1Params; -import com.imagekit.api.models.files.FileUploadV1Response; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -FileUploadV1Params params = FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("some content".getBytes())) .fileName("fileName") .build(); -FileUploadV1Response response = client.files().uploadV1(params); +FileUploadResponse response = client.files().upload(params); ``` ## Client configuration @@ -122,7 +123,7 @@ The `withOptions()` method does not affect the original client or service. 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. -For example, `client.files().uploadV1(...)` should be called with an instance of `FileUploadV1Params`, and it will return an instance of `FileUploadV1Response`. +For example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`. ## Immutability @@ -139,19 +140,20 @@ The default client is synchronous. To switch to asynchronous execution, call the ```java import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import com.imagekit.api.models.files.FileUploadV1Params; -import com.imagekit.api.models.files.FileUploadV1Response; +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.orgMyPasswordToken` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -FileUploadV1Params params = FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("some content".getBytes())) .fileName("fileName") .build(); -CompletableFuture response = client.async().files().uploadV1(params); +CompletableFuture response = client.async().files().upload(params); ``` Or create an asynchronous client from the beginning: @@ -159,23 +161,88 @@ 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.FileUploadV1Params; -import com.imagekit.api.models.files.FileUploadV1Response; +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.orgMyPasswordToken` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); -FileUploadV1Params params = FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("some content".getBytes())) .fileName("fileName") .build(); -CompletableFuture response = client.files().uploadV1(params); +CompletableFuture response = client.files().upload(params); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. +## File uploads + +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 java.nio.file.Paths; + +FileUploadParams params = FileUploadParams.builder() + .fileName("fileName") + .file(Paths.get("/path/to/file")) + .build(); +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.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); +``` + +Or a `byte[]` array: + +```java +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); +``` + +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 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); +``` + ## Raw responses 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. @@ -185,14 +252,15 @@ To access this data, prefix any HTTP method call on a client or service with `wi ```java import com.imagekit.api.core.http.Headers; import com.imagekit.api.core.http.HttpResponseFor; -import com.imagekit.api.models.files.FileUploadV1Params; -import com.imagekit.api.models.files.FileUploadV1Response; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; -FileUploadV1Params params = FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("some content".getBytes())) .fileName("fileName") .build(); -HttpResponseFor response = client.files().withRawResponse().uploadV1(params); +HttpResponseFor response = client.files().withRawResponse().upload(params); int statusCode = response.statusCode(); Headers headers = response.headers(); @@ -201,9 +269,9 @@ 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.FileUploadV1Response; +import com.imagekit.api.models.files.FileUploadResponse; -FileUploadV1Response parsedResponse = response.parse(); +FileUploadResponse parsedResponse = response.parse(); ``` ## Error handling @@ -299,9 +367,9 @@ 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.FileUploadV1Response; +import com.imagekit.api.models.files.FileUploadResponse; -FileUploadV1Response response = client.files().uploadV1( +FileUploadResponse response = client.files().upload( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() ); ``` @@ -406,9 +474,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu ```java import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.files.FileUploadV1Params; +import com.imagekit.api.models.files.FileUploadParams; -FileUploadV1Params params = FileUploadV1Params.builder() +FileUploadParams params = FileUploadParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) @@ -421,10 +489,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(); @@ -436,11 +504,12 @@ To set a documented parameter or property to an undocumented or not yet supporte ```java import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.files.FileUploadV1Params; +import com.imagekit.api.models.files.FileUploadParams; +import java.io.ByteArrayInputStream; -FileUploadV1Params params = FileUploadV1Params.builder() - .file(JsonValue.from(42)) - .fileName("fileName") +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("some content".getBytes())) + .fileName(JsonValue.from(42)) .build(); ``` @@ -489,9 +558,9 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](image-ki ```java import com.imagekit.api.core.JsonMissing; -import com.imagekit.api.models.files.FileUploadV1Params; +import com.imagekit.api.models.files.FileUploadParams; -FileUploadV1Params params = FileUploadV1Params.builder() +FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(JsonMissing.of()) .build(); @@ -505,7 +574,7 @@ To access undocumented response properties, call the `_additionalProperties()` m import com.imagekit.api.core.JsonValue; import java.util.Map; -Map additionalProperties = client.files().uploadV1(params)._additionalProperties(); +Map additionalProperties = client.files().upload(params)._additionalProperties(); JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { @@ -533,9 +602,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().uploadV1(params)._file(); +JsonField file = client.files().upload(params)._file(); if (file.isMissing()) { // The property is absent from the JSON response @@ -560,17 +630,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`Im 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.FileUploadV1Response; +import com.imagekit.api.models.files.FileUploadResponse; -FileUploadV1Response response = client.files().uploadV1(params).validate(); +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.FileUploadV1Response; +import com.imagekit.api.models.files.FileUploadResponse; -FileUploadV1Response response = client.files().uploadV1( +FileUploadResponse response = client.files().upload( params, RequestOptions.builder().responseValidation(true).build() ); ``` 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 cfb877a8..9467c831 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 @@ -4,7 +4,9 @@ package com.imagekit.api.client import com.imagekit.api.core.ClientOptions import com.imagekit.api.services.blocking.AccountService -import com.imagekit.api.services.blocking.BulkJobService +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 @@ -50,12 +52,16 @@ interface ImageKitClient { fun files(): FileService - fun folder(): FolderService + fun assets(): AssetService - fun bulkJobs(): BulkJobService + fun cache(): CacheService + + fun folders(): FolderService fun accounts(): AccountService + fun beta(): BetaService + /** * Closes this client, relinquishing any underlying resources. * @@ -83,10 +89,14 @@ interface ImageKitClient { fun files(): FileService.WithRawResponse - fun folder(): FolderService.WithRawResponse + fun assets(): AssetService.WithRawResponse - fun bulkJobs(): BulkJobService.WithRawResponse + fun cache(): CacheService.WithRawResponse + + fun folders(): FolderService.WithRawResponse fun accounts(): AccountService.WithRawResponse + + fun beta(): BetaService.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 7be195f3..fdef9561 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 @@ -4,7 +4,9 @@ package com.imagekit.api.client import com.imagekit.api.core.ClientOptions import com.imagekit.api.services.async.AccountServiceAsync -import com.imagekit.api.services.async.BulkJobServiceAsync +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 @@ -50,12 +52,16 @@ interface ImageKitClientAsync { fun files(): FileServiceAsync - fun folder(): FolderServiceAsync + fun assets(): AssetServiceAsync - fun bulkJobs(): BulkJobServiceAsync + fun cache(): CacheServiceAsync + + fun folders(): FolderServiceAsync fun accounts(): AccountServiceAsync + fun beta(): BetaServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -87,10 +93,14 @@ interface ImageKitClientAsync { fun files(): FileServiceAsync.WithRawResponse - fun folder(): FolderServiceAsync.WithRawResponse + fun assets(): AssetServiceAsync.WithRawResponse - fun bulkJobs(): BulkJobServiceAsync.WithRawResponse + fun cache(): CacheServiceAsync.WithRawResponse + + fun folders(): FolderServiceAsync.WithRawResponse fun accounts(): AccountServiceAsync.WithRawResponse + + fun beta(): BetaServiceAsync.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 ca9f5ca3..2552b193 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 @@ -6,8 +6,12 @@ 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.BulkJobServiceAsync -import com.imagekit.api.services.async.BulkJobServiceAsyncImpl +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 @@ -39,18 +43,24 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK private val files: FileServiceAsync by lazy { FileServiceAsyncImpl(clientOptionsWithUserAgent) } - private val folder: FolderServiceAsync by lazy { - FolderServiceAsyncImpl(clientOptionsWithUserAgent) + private val assets: AssetServiceAsync by lazy { + AssetServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val cache: CacheServiceAsync by lazy { + CacheServiceAsyncImpl(clientOptionsWithUserAgent) } - private val bulkJobs: BulkJobServiceAsync by lazy { - BulkJobServiceAsyncImpl(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) } + override fun sync(): ImageKitClient = sync override fun withRawResponse(): ImageKitClientAsync.WithRawResponse = withRawResponse @@ -62,12 +72,16 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun files(): FileServiceAsync = files - override fun folder(): FolderServiceAsync = folder + override fun assets(): AssetServiceAsync = assets + + override fun cache(): CacheServiceAsync = cache - override fun bulkJobs(): BulkJobServiceAsync = bulkJobs + override fun folders(): FolderServiceAsync = folders override fun accounts(): AccountServiceAsync = accounts + override fun beta(): BetaServiceAsync = beta + override fun close() = clientOptions.httpClient.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -81,18 +95,26 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK FileServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val folder: FolderServiceAsync.WithRawResponse by lazy { - FolderServiceAsyncImpl.WithRawResponseImpl(clientOptions) + private val assets: AssetServiceAsync.WithRawResponse by lazy { + AssetServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val bulkJobs: BulkJobServiceAsync.WithRawResponse by lazy { - BulkJobServiceAsyncImpl.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) + } + override fun withOptions( modifier: Consumer ): ImageKitClientAsync.WithRawResponse = @@ -105,10 +127,14 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun files(): FileServiceAsync.WithRawResponse = files - override fun folder(): FolderServiceAsync.WithRawResponse = folder + override fun assets(): AssetServiceAsync.WithRawResponse = assets + + override fun cache(): CacheServiceAsync.WithRawResponse = cache - override fun bulkJobs(): BulkJobServiceAsync.WithRawResponse = bulkJobs + override fun folders(): FolderServiceAsync.WithRawResponse = folders override fun accounts(): AccountServiceAsync.WithRawResponse = accounts + + override fun beta(): BetaServiceAsync.WithRawResponse = beta } } 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 9abcbac7..62a932af 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 @@ -6,8 +6,12 @@ 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.BulkJobService -import com.imagekit.api.services.blocking.BulkJobServiceImpl +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 @@ -39,12 +43,16 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli private val files: FileService by lazy { FileServiceImpl(clientOptionsWithUserAgent) } - private val folder: FolderService by lazy { FolderServiceImpl(clientOptionsWithUserAgent) } + private val assets: AssetService by lazy { AssetServiceImpl(clientOptionsWithUserAgent) } - private val bulkJobs: BulkJobService by lazy { BulkJobServiceImpl(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) } + override fun async(): ImageKitClientAsync = async override fun withRawResponse(): ImageKitClient.WithRawResponse = withRawResponse @@ -56,12 +64,16 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun files(): FileService = files - override fun folder(): FolderService = folder + override fun assets(): AssetService = assets + + override fun cache(): CacheService = cache - override fun bulkJobs(): BulkJobService = bulkJobs + override fun folders(): FolderService = folders override fun accounts(): AccountService = accounts + override fun beta(): BetaService = beta + override fun close() = clientOptions.httpClient.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -75,18 +87,26 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli FileServiceImpl.WithRawResponseImpl(clientOptions) } - private val folder: FolderService.WithRawResponse by lazy { - FolderServiceImpl.WithRawResponseImpl(clientOptions) + private val assets: AssetService.WithRawResponse by lazy { + AssetServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val cache: CacheService.WithRawResponse by lazy { + CacheServiceImpl.WithRawResponseImpl(clientOptions) } - private val bulkJobs: BulkJobService.WithRawResponse by lazy { - BulkJobServiceImpl.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) + } + override fun withOptions( modifier: Consumer ): ImageKitClient.WithRawResponse = @@ -99,10 +119,14 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun files(): FileService.WithRawResponse = files - override fun folder(): FolderService.WithRawResponse = folder + override fun assets(): AssetService.WithRawResponse = assets + + override fun cache(): CacheService.WithRawResponse = cache - override fun bulkJobs(): BulkJobService.WithRawResponse = bulkJobs + override fun folders(): FolderService.WithRawResponse = folders override fun accounts(): AccountService.WithRawResponse = accounts + + override fun beta(): BetaService.WithRawResponse = beta } } 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..2066e7a6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt @@ -0,0 +1,5225 @@ +// 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.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.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.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ +class OriginCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Schema for origin resources. */ + fun body(): Body = body + + /** 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 + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OriginCreateParams]. */ + class Builder internal constructor() { + + private var body: Body? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(originCreateParams: OriginCreateParams) = apply { + body = originCreateParams.body + additionalHeaders = originCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = originCreateParams.additionalQueryParams.toBuilder() + } + + /** Schema for origin resources. */ + fun body(body: Body) = apply { this.body = body } + + /** Alias for calling [body] with `Body.ofS3(s3)`. */ + fun body(s3: Body.S3) = body(Body.ofS3(s3)) + + /** Alias for calling [body] with `Body.ofS3Compatible(s3Compatible)`. */ + fun body(s3Compatible: Body.S3Compatible) = body(Body.ofS3Compatible(s3Compatible)) + + /** Alias for calling [body] with `Body.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun body(cloudinaryBackup: Body.CloudinaryBackup) = + body(Body.ofCloudinaryBackup(cloudinaryBackup)) + + /** Alias for calling [body] with `Body.ofWebFolder(webFolder)`. */ + fun body(webFolder: Body.WebFolder) = body(Body.ofWebFolder(webFolder)) + + /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ + fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) + + /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ + fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = + body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + + /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ + fun body(azureBlobStorage: Body.AzureBlobStorage) = + body(Body.ofAzureBlobStorage(azureBlobStorage)) + + /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ + fun body(akeneoPim: Body.AkeneoPim) = body(Body.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 + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OriginCreateParams = + OriginCreateParams( + checkRequired("body", body), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Schema for origin resources. */ + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = 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 googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) + + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + + 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 isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + + fun isAzureBlobStorage(): Boolean = azureBlobStorage != 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 asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + + 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Body = 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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() + } + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.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 Body && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && + akeneoPim == other.akeneoPim + } + + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + googleCloudStorageGcs, + azureBlobStorage, + akeneoPim, + ) + + override fun toString(): String = + when { + s3 != null -> "Body{s3=$s3}" + s3Compatible != null -> "Body{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "Body{webFolder=$webFolder}" + webProxy != null -> "Body{webProxy=$webProxy}" + googleCloudStorageGcs != null -> + "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = Body(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = Body(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + Body(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Body(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) + + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + Body(googleCloudStorageGcs = googleCloudStorageGcs) + + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + Body(azureBlobStorage = azureBlobStorage) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) + } + + /** An interface that defines how to map each variant of [Body] 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 visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): 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(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPim = 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.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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } + } + + class S3 + private constructor( + private val accessKey: JsonField, + private val bucket: JsonField, + private val name: JsonField, + private val secretKey: JsonField, + private val type: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): S3 = + S3( + checkRequired("accessKey", accessKey), + checkRequired("bucket", bucket), + checkRequired("name", name), + checkRequired("secretKey", secretKey), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3 = apply { + if (validated) { + return@apply + } + + accessKey() + bucket() + name() + secretKey() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + 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 S3 = of("S3") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3 + } + + /** + * 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 { + S3, + /** + * 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) { + S3 -> Value.S3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + 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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", 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().validate() + 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.asKnown().getOrNull()?.validity() ?: 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) + + 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 S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3_COMPATIBLE + } + + /** + * 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 { + S3_COMPATIBLE, + /** + * 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) { + S3_COMPATIBLE -> Value.S3_COMPATIBLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3_COMPATIBLE -> Known.S3_COMPATIBLE + 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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CloudinaryBackup = + CloudinaryBackup( + checkRequired("accessKey", accessKey), + checkRequired("bucket", bucket), + checkRequired("name", name), + checkRequired("secretKey", secretKey), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryBackup = apply { + if (validated) { + return@apply + } + + accessKey() + bucket() + name() + secretKey() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY_BACKUP + } + + /** + * 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 { + CLOUDINARY_BACKUP, + /** + * 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) { + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + 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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebFolder = + WebFolder( + checkRequired("baseUrl", baseUrl), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebFolder = apply { + if (validated) { + return@apply + } + + baseUrl() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_FOLDER = of("WEB_FOLDER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_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 { + WEB_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) { + WEB_FOLDER -> Value.WEB_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) { + WEB_FOLDER -> Known.WEB_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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebProxy]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var type: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebProxy = + WebProxy( + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebProxy = apply { + if (validated) { + return@apply + } + + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_PROXY = of("WEB_PROXY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_PROXY + } + + /** + * 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 { + WEB_PROXY, + /** + * 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) { + WEB_PROXY -> Value.WEB_PROXY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_PROXY -> Known.WEB_PROXY + 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 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 GoogleCloudStorageGcs + private constructor( + private val bucket: JsonField, + private val clientEmail: JsonField, + private val name: JsonField, + private val privateKey: JsonField, + private val type: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 + * [GoogleCloudStorageGcs]. + * + * The following fields are required: + * ```java + * .bucket() + * .clientEmail() + * .name() + * .privateKey() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleCloudStorageGcs]. */ + 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: JsonField? = null + 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.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 + } + + 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 } + + /** 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 [GoogleCloudStorageGcs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bucket() + * .clientEmail() + * .name() + * .privateKey() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( + checkRequired("bucket", bucket), + checkRequired("clientEmail", clientEmail), + checkRequired("name", name), + checkRequired("privateKey", privateKey), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } + + bucket() + clientEmail() + name() + privateKey() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + 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 GCS = of("GCS") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GCS + } + + /** + * 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 { + GCS, + /** + * 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) { + GCS -> Value.GCS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GCS -> Known.GCS + 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 GoogleCloudStorageGcs && + 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() = + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + } + + class AzureBlobStorage + private constructor( + private val accountName: JsonField, + private val container: JsonField, + private val name: JsonField, + private val sasToken: JsonField, + private val type: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [AzureBlobStorage]. + * + * The following fields are required: + * ```java + * .accountName() + * .container() + * .name() + * .sasToken() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlobStorage]. */ + 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: JsonField? = null + 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(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.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 } + + 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 } + + /** 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 [AzureBlobStorage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountName() + * .container() + * .name() + * .sasToken() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("name", name), + checkRequired("sasToken", sasToken), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply + } + + accountName() + container() + name() + sasToken() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + 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 AZURE_BLOB = of("AZURE_BLOB") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AZURE_BLOB + } + + /** + * 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 { + AZURE_BLOB, + /** + * 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) { + AZURE_BLOB -> Value.AZURE_BLOB + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AZURE_BLOB -> Known.AZURE_BLOB + 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 AzureBlobStorage && + 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() = + "AzureBlobStorage{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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * .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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * .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), + checkRequired("type", 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().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (username.asKnown().isPresent) 1 else 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKENEO_PIM + } + + /** + * 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 { + AKENEO_PIM, + /** + * 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) { + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKENEO_PIM -> Known.AKENEO_PIM + 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 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}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OriginCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OriginCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt new file mode 100644 index 00000000..5155af8b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt @@ -0,0 +1,4589 @@ +// 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.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.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 = OriginCreateResponse.Deserializer::class) +@JsonSerialize(using = OriginCreateResponse.Serializer::class) +class OriginCreateResponse +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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = 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 googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) + + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + + 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 isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + + fun isAzureBlobStorage(): Boolean = azureBlobStorage != 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 asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + + 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): OriginCreateResponse = 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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() + } + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.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 OriginCreateResponse && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && + akeneoPim == other.akeneoPim + } + + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + googleCloudStorageGcs, + azureBlobStorage, + akeneoPim, + ) + + override fun toString(): String = + when { + s3 != null -> "OriginCreateResponse{s3=$s3}" + s3Compatible != null -> "OriginCreateResponse{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "OriginCreateResponse{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "OriginCreateResponse{webFolder=$webFolder}" + webProxy != null -> "OriginCreateResponse{webProxy=$webProxy}" + googleCloudStorageGcs != null -> + "OriginCreateResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "OriginCreateResponse{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "OriginCreateResponse{akeneoPim=$akeneoPim}" + _json != null -> "OriginCreateResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid OriginCreateResponse") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = OriginCreateResponse(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = + OriginCreateResponse(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + OriginCreateResponse(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic + fun ofWebFolder(webFolder: WebFolder) = OriginCreateResponse(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginCreateResponse(webProxy = webProxy) + + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + OriginCreateResponse(googleCloudStorageGcs = googleCloudStorageGcs) + + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + OriginCreateResponse(azureBlobStorage = azureBlobStorage) + + @JvmStatic + fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginCreateResponse(akeneoPim = akeneoPim) + } + + /** + * An interface that defines how to map each variant of [OriginCreateResponse] 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 visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): T + + /** + * Maps an unknown variant of [OriginCreateResponse] to a value of type [T]. + * + * An instance of [OriginCreateResponse] 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 OriginCreateResponse: $json") + } + } + + internal class Deserializer : + BaseDeserializer(OriginCreateResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): OriginCreateResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(akeneoPim = 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 -> OriginCreateResponse(_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(OriginCreateResponse::class) { + + override fun serialize( + value: OriginCreateResponse, + 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid OriginCreateResponse") + } + } + } + + class S3 + private constructor( + private val id: JsonField, + private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var type: JsonField? = null + 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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3 = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 S3 = of("S3") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3 + } + + /** + * 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 { + S3, + /** 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) { + S3 -> Value.S3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + 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 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: JsonValue, + private val s3ForcePathStyle: JsonField, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + s3ForcePathStyle: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var s3ForcePathStyle: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3Compatible = apply { + if (validated) { + return@apply + } + + id() + bucket() + endpoint() + includeCanonicalHeader() + name() + s3ForcePathStyle() + type().validate() + 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 (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3_COMPATIBLE + } + + /** + * 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 { + S3_COMPATIBLE, + /** 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) { + S3_COMPATIBLE -> Value.S3_COMPATIBLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3_COMPATIBLE -> Known.S3_COMPATIBLE + 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 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var type: JsonField? = null + 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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryBackup = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY_BACKUP + } + + /** + * 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 { + CLOUDINARY_BACKUP, + /** 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) { + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + 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 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: JsonValue, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = 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: JsonField = 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. */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebFolder]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonValue? = null + private var forwardHostHeaderToOrigin: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebFolder = apply { + if (validated) { + return@apply + } + + id() + forwardHostHeaderToOrigin() + includeCanonicalHeader() + name() + type().validate() + 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 (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_FOLDER = of("WEB_FOLDER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_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 { + WEB_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) { + WEB_FOLDER -> Value.WEB_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) { + WEB_FOLDER -> Known.WEB_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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebProxy = + WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebProxy = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_PROXY = of("WEB_PROXY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_PROXY + } + + /** + * 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 { + WEB_PROXY, + /** 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) { + WEB_PROXY -> Value.WEB_PROXY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_PROXY -> Known.WEB_PROXY + 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 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 GoogleCloudStorageGcs + 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [GoogleCloudStorageGcs]. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleCloudStorageGcs]. */ + 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: JsonValue? = null + private var type: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + id = googleCloudStorageGcs.id + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + name = googleCloudStorageGcs.name + prefix = googleCloudStorageGcs.prefix + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + additionalProperties = googleCloudStorageGcs.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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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 [GoogleCloudStorageGcs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( + checkRequired("id", id), + checkRequired("bucket", bucket), + checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } + + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 GCS = of("GCS") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GCS + } + + /** + * 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 { + GCS, + /** 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) { + GCS -> Value.GCS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GCS -> Known.GCS + 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 GoogleCloudStorageGcs && + 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() = + "GoogleCloudStorageGcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class AzureBlobStorage + 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [AzureBlobStorage]. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlobStorage]. */ + 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: JsonValue? = null + private var type: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + id = azureBlobStorage.id + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + name = azureBlobStorage.name + prefix = azureBlobStorage.prefix + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + additionalProperties = azureBlobStorage.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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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 [AzureBlobStorage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply + } + + id() + accountName() + container() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AZURE_BLOB = of("AZURE_BLOB") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AZURE_BLOB + } + + /** + * 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 { + AZURE_BLOB, + /** 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) { + AZURE_BLOB -> Value.AZURE_BLOB + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AZURE_BLOB -> Known.AZURE_BLOB + 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 AzureBlobStorage && + 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() = + "AzureBlobStorage{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: JsonValue, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkeneoPim]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonValue? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AkeneoPim = + AkeneoPim( + checkRequired("id", id), + checkRequired("baseUrl", baseUrl), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkeneoPim = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKENEO_PIM + } + + /** + * 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 { + AKENEO_PIM, + /** 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) { + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKENEO_PIM -> Known.AKENEO_PIM + 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 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/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/OriginGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt new file mode 100644 index 00000000..a087c751 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt @@ -0,0 +1,4586 @@ +// 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.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.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 = OriginGetResponse.Deserializer::class) +@JsonSerialize(using = OriginGetResponse.Serializer::class) +class OriginGetResponse +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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = 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 googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) + + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + + 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 isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + + fun isAzureBlobStorage(): Boolean = azureBlobStorage != 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 asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + + 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): OriginGetResponse = 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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() + } + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.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 OriginGetResponse && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && + akeneoPim == other.akeneoPim + } + + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + googleCloudStorageGcs, + azureBlobStorage, + akeneoPim, + ) + + override fun toString(): String = + when { + s3 != null -> "OriginGetResponse{s3=$s3}" + s3Compatible != null -> "OriginGetResponse{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "OriginGetResponse{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "OriginGetResponse{webFolder=$webFolder}" + webProxy != null -> "OriginGetResponse{webProxy=$webProxy}" + googleCloudStorageGcs != null -> + "OriginGetResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "OriginGetResponse{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "OriginGetResponse{akeneoPim=$akeneoPim}" + _json != null -> "OriginGetResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid OriginGetResponse") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = OriginGetResponse(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = + OriginGetResponse(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + OriginGetResponse(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = OriginGetResponse(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginGetResponse(webProxy = webProxy) + + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + OriginGetResponse(googleCloudStorageGcs = googleCloudStorageGcs) + + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + OriginGetResponse(azureBlobStorage = azureBlobStorage) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginGetResponse(akeneoPim = akeneoPim) + } + + /** + * An interface that defines how to map each variant of [OriginGetResponse] 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 visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): T + + /** + * Maps an unknown variant of [OriginGetResponse] to a value of type [T]. + * + * An instance of [OriginGetResponse] 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 OriginGetResponse: $json") + } + } + + internal class Deserializer : BaseDeserializer(OriginGetResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): OriginGetResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(akeneoPim = 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 -> OriginGetResponse(_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(OriginGetResponse::class) { + + override fun serialize( + value: OriginGetResponse, + 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid OriginGetResponse") + } + } + } + + class S3 + private constructor( + private val id: JsonField, + private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var type: JsonField? = null + 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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3 = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 S3 = of("S3") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3 + } + + /** + * 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 { + S3, + /** 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) { + S3 -> Value.S3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + 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 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: JsonValue, + private val s3ForcePathStyle: JsonField, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + s3ForcePathStyle: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var s3ForcePathStyle: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3Compatible = apply { + if (validated) { + return@apply + } + + id() + bucket() + endpoint() + includeCanonicalHeader() + name() + s3ForcePathStyle() + type().validate() + 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 (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3_COMPATIBLE + } + + /** + * 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 { + S3_COMPATIBLE, + /** 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) { + S3_COMPATIBLE -> Value.S3_COMPATIBLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3_COMPATIBLE -> Known.S3_COMPATIBLE + 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 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var type: JsonField? = null + 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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryBackup = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY_BACKUP + } + + /** + * 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 { + CLOUDINARY_BACKUP, + /** 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) { + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + 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 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: JsonValue, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = 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: JsonField = 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. */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebFolder]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonValue? = null + private var forwardHostHeaderToOrigin: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebFolder = apply { + if (validated) { + return@apply + } + + id() + forwardHostHeaderToOrigin() + includeCanonicalHeader() + name() + type().validate() + 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 (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_FOLDER = of("WEB_FOLDER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_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 { + WEB_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) { + WEB_FOLDER -> Value.WEB_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) { + WEB_FOLDER -> Known.WEB_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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebProxy = + WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebProxy = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_PROXY = of("WEB_PROXY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_PROXY + } + + /** + * 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 { + WEB_PROXY, + /** 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) { + WEB_PROXY -> Value.WEB_PROXY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_PROXY -> Known.WEB_PROXY + 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 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 GoogleCloudStorageGcs + 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [GoogleCloudStorageGcs]. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleCloudStorageGcs]. */ + 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: JsonValue? = null + private var type: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + id = googleCloudStorageGcs.id + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + name = googleCloudStorageGcs.name + prefix = googleCloudStorageGcs.prefix + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + additionalProperties = googleCloudStorageGcs.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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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 [GoogleCloudStorageGcs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( + checkRequired("id", id), + checkRequired("bucket", bucket), + checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } + + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 GCS = of("GCS") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GCS + } + + /** + * 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 { + GCS, + /** 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) { + GCS -> Value.GCS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GCS -> Known.GCS + 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 GoogleCloudStorageGcs && + 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() = + "GoogleCloudStorageGcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class AzureBlobStorage + 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [AzureBlobStorage]. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlobStorage]. */ + 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: JsonValue? = null + private var type: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + id = azureBlobStorage.id + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + name = azureBlobStorage.name + prefix = azureBlobStorage.prefix + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + additionalProperties = azureBlobStorage.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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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 [AzureBlobStorage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply + } + + id() + accountName() + container() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AZURE_BLOB = of("AZURE_BLOB") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AZURE_BLOB + } + + /** + * 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 { + AZURE_BLOB, + /** 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) { + AZURE_BLOB -> Value.AZURE_BLOB + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AZURE_BLOB -> Known.AZURE_BLOB + 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 AzureBlobStorage && + 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() = + "AzureBlobStorage{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: JsonValue, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkeneoPim]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonValue? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AkeneoPim = + AkeneoPim( + checkRequired("id", id), + checkRequired("baseUrl", baseUrl), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkeneoPim = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKENEO_PIM + } + + /** + * 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 { + AKENEO_PIM, + /** 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) { + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKENEO_PIM -> Known.AKENEO_PIM + 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 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/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/OriginListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt new file mode 100644 index 00000000..bc9bec7b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt @@ -0,0 +1,4586 @@ +// 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.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.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 = OriginListResponse.Deserializer::class) +@JsonSerialize(using = OriginListResponse.Serializer::class) +class OriginListResponse +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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = 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 googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) + + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + + 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 isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + + fun isAzureBlobStorage(): Boolean = azureBlobStorage != 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 asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + + 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): OriginListResponse = 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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() + } + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.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 OriginListResponse && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && + akeneoPim == other.akeneoPim + } + + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + googleCloudStorageGcs, + azureBlobStorage, + akeneoPim, + ) + + override fun toString(): String = + when { + s3 != null -> "OriginListResponse{s3=$s3}" + s3Compatible != null -> "OriginListResponse{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "OriginListResponse{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "OriginListResponse{webFolder=$webFolder}" + webProxy != null -> "OriginListResponse{webProxy=$webProxy}" + googleCloudStorageGcs != null -> + "OriginListResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "OriginListResponse{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "OriginListResponse{akeneoPim=$akeneoPim}" + _json != null -> "OriginListResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid OriginListResponse") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = OriginListResponse(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = + OriginListResponse(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + OriginListResponse(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = OriginListResponse(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginListResponse(webProxy = webProxy) + + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + OriginListResponse(googleCloudStorageGcs = googleCloudStorageGcs) + + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + OriginListResponse(azureBlobStorage = azureBlobStorage) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginListResponse(akeneoPim = akeneoPim) + } + + /** + * An interface that defines how to map each variant of [OriginListResponse] 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 visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): T + + /** + * Maps an unknown variant of [OriginListResponse] to a value of type [T]. + * + * An instance of [OriginListResponse] 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 OriginListResponse: $json") + } + } + + internal class Deserializer : BaseDeserializer(OriginListResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): OriginListResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(akeneoPim = 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 -> OriginListResponse(_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(OriginListResponse::class) { + + override fun serialize( + value: OriginListResponse, + 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid OriginListResponse") + } + } + } + + class S3 + private constructor( + private val id: JsonField, + private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var type: JsonField? = null + 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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3 = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 S3 = of("S3") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3 + } + + /** + * 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 { + S3, + /** 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) { + S3 -> Value.S3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + 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 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: JsonValue, + private val s3ForcePathStyle: JsonField, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + s3ForcePathStyle: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var s3ForcePathStyle: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3Compatible = apply { + if (validated) { + return@apply + } + + id() + bucket() + endpoint() + includeCanonicalHeader() + name() + s3ForcePathStyle() + type().validate() + 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 (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3_COMPATIBLE + } + + /** + * 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 { + S3_COMPATIBLE, + /** 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) { + S3_COMPATIBLE -> Value.S3_COMPATIBLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3_COMPATIBLE -> Known.S3_COMPATIBLE + 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 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var type: JsonField? = null + 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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryBackup = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY_BACKUP + } + + /** + * 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 { + CLOUDINARY_BACKUP, + /** 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) { + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + 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 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: JsonValue, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = 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: JsonField = 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. */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebFolder]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonValue? = null + private var forwardHostHeaderToOrigin: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebFolder = apply { + if (validated) { + return@apply + } + + id() + forwardHostHeaderToOrigin() + includeCanonicalHeader() + name() + type().validate() + 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 (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_FOLDER = of("WEB_FOLDER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_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 { + WEB_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) { + WEB_FOLDER -> Value.WEB_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) { + WEB_FOLDER -> Known.WEB_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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebProxy = + WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebProxy = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_PROXY = of("WEB_PROXY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_PROXY + } + + /** + * 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 { + WEB_PROXY, + /** 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) { + WEB_PROXY -> Value.WEB_PROXY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_PROXY -> Known.WEB_PROXY + 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 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 GoogleCloudStorageGcs + 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [GoogleCloudStorageGcs]. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleCloudStorageGcs]. */ + 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: JsonValue? = null + private var type: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + id = googleCloudStorageGcs.id + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + name = googleCloudStorageGcs.name + prefix = googleCloudStorageGcs.prefix + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + additionalProperties = googleCloudStorageGcs.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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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 [GoogleCloudStorageGcs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( + checkRequired("id", id), + checkRequired("bucket", bucket), + checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } + + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 GCS = of("GCS") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GCS + } + + /** + * 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 { + GCS, + /** 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) { + GCS -> Value.GCS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GCS -> Known.GCS + 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 GoogleCloudStorageGcs && + 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() = + "GoogleCloudStorageGcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class AzureBlobStorage + 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [AzureBlobStorage]. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlobStorage]. */ + 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: JsonValue? = null + private var type: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + id = azureBlobStorage.id + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + name = azureBlobStorage.name + prefix = azureBlobStorage.prefix + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + additionalProperties = azureBlobStorage.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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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 [AzureBlobStorage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply + } + + id() + accountName() + container() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AZURE_BLOB = of("AZURE_BLOB") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AZURE_BLOB + } + + /** + * 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 { + AZURE_BLOB, + /** 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) { + AZURE_BLOB -> Value.AZURE_BLOB + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AZURE_BLOB -> Known.AZURE_BLOB + 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 AzureBlobStorage && + 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() = + "AzureBlobStorage{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: JsonValue, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkeneoPim]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonValue? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AkeneoPim = + AkeneoPim( + checkRequired("id", id), + checkRequired("baseUrl", baseUrl), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkeneoPim = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKENEO_PIM + } + + /** + * 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 { + AKENEO_PIM, + /** 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) { + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKENEO_PIM -> Known.AKENEO_PIM + 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 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..c74ef0a2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt @@ -0,0 +1,5253 @@ +// 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.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.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.errors.ImageKitInvalidDataException +import java.util.Collections +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 body: Body, + 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 resources. */ + fun body(): Body = body + + /** 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 + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OriginUpdateParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var body: Body? = 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 + body = originUpdateParams.body + 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 resources. */ + fun body(body: Body) = apply { this.body = body } + + /** Alias for calling [body] with `Body.ofS3(s3)`. */ + fun body(s3: Body.S3) = body(Body.ofS3(s3)) + + /** Alias for calling [body] with `Body.ofS3Compatible(s3Compatible)`. */ + fun body(s3Compatible: Body.S3Compatible) = body(Body.ofS3Compatible(s3Compatible)) + + /** Alias for calling [body] with `Body.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun body(cloudinaryBackup: Body.CloudinaryBackup) = + body(Body.ofCloudinaryBackup(cloudinaryBackup)) + + /** Alias for calling [body] with `Body.ofWebFolder(webFolder)`. */ + fun body(webFolder: Body.WebFolder) = body(Body.ofWebFolder(webFolder)) + + /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ + fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) + + /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ + fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = + body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + + /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ + fun body(azureBlobStorage: Body.AzureBlobStorage) = + body(Body.ofAzureBlobStorage(azureBlobStorage)) + + /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ + fun body(akeneoPim: Body.AkeneoPim) = body(Body.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 + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OriginUpdateParams = + OriginUpdateParams( + id, + checkRequired("body", body), + 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 + + /** Schema for origin resources. */ + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = 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 googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) + + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + + 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 isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + + fun isAzureBlobStorage(): Boolean = azureBlobStorage != 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 asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + + 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Body = 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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() + } + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.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 Body && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && + akeneoPim == other.akeneoPim + } + + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + googleCloudStorageGcs, + azureBlobStorage, + akeneoPim, + ) + + override fun toString(): String = + when { + s3 != null -> "Body{s3=$s3}" + s3Compatible != null -> "Body{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "Body{webFolder=$webFolder}" + webProxy != null -> "Body{webProxy=$webProxy}" + googleCloudStorageGcs != null -> + "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = Body(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = Body(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + Body(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Body(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) + + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + Body(googleCloudStorageGcs = googleCloudStorageGcs) + + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + Body(azureBlobStorage = azureBlobStorage) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) + } + + /** An interface that defines how to map each variant of [Body] 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 visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): 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(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPim = 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.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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } + } + + class S3 + private constructor( + private val accessKey: JsonField, + private val bucket: JsonField, + private val name: JsonField, + private val secretKey: JsonField, + private val type: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): S3 = + S3( + checkRequired("accessKey", accessKey), + checkRequired("bucket", bucket), + checkRequired("name", name), + checkRequired("secretKey", secretKey), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3 = apply { + if (validated) { + return@apply + } + + accessKey() + bucket() + name() + secretKey() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + 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 S3 = of("S3") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3 + } + + /** + * 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 { + S3, + /** + * 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) { + S3 -> Value.S3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + 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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", 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().validate() + 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.asKnown().getOrNull()?.validity() ?: 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) + + 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 S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3_COMPATIBLE + } + + /** + * 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 { + S3_COMPATIBLE, + /** + * 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) { + S3_COMPATIBLE -> Value.S3_COMPATIBLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3_COMPATIBLE -> Known.S3_COMPATIBLE + 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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CloudinaryBackup = + CloudinaryBackup( + checkRequired("accessKey", accessKey), + checkRequired("bucket", bucket), + checkRequired("name", name), + checkRequired("secretKey", secretKey), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryBackup = apply { + if (validated) { + return@apply + } + + accessKey() + bucket() + name() + secretKey() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY_BACKUP + } + + /** + * 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 { + CLOUDINARY_BACKUP, + /** + * 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) { + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + 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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebFolder = + WebFolder( + checkRequired("baseUrl", baseUrl), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebFolder = apply { + if (validated) { + return@apply + } + + baseUrl() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_FOLDER = of("WEB_FOLDER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_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 { + WEB_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) { + WEB_FOLDER -> Value.WEB_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) { + WEB_FOLDER -> Known.WEB_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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebProxy]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var type: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebProxy = + WebProxy( + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebProxy = apply { + if (validated) { + return@apply + } + + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_PROXY = of("WEB_PROXY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_PROXY + } + + /** + * 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 { + WEB_PROXY, + /** + * 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) { + WEB_PROXY -> Value.WEB_PROXY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_PROXY -> Known.WEB_PROXY + 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 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 GoogleCloudStorageGcs + private constructor( + private val bucket: JsonField, + private val clientEmail: JsonField, + private val name: JsonField, + private val privateKey: JsonField, + private val type: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 + * [GoogleCloudStorageGcs]. + * + * The following fields are required: + * ```java + * .bucket() + * .clientEmail() + * .name() + * .privateKey() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleCloudStorageGcs]. */ + 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: JsonField? = null + 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.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 + } + + 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 } + + /** 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 [GoogleCloudStorageGcs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bucket() + * .clientEmail() + * .name() + * .privateKey() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( + checkRequired("bucket", bucket), + checkRequired("clientEmail", clientEmail), + checkRequired("name", name), + checkRequired("privateKey", privateKey), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } + + bucket() + clientEmail() + name() + privateKey() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + 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 GCS = of("GCS") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GCS + } + + /** + * 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 { + GCS, + /** + * 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) { + GCS -> Value.GCS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GCS -> Known.GCS + 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 GoogleCloudStorageGcs && + 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() = + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + } + + class AzureBlobStorage + private constructor( + private val accountName: JsonField, + private val container: JsonField, + private val name: JsonField, + private val sasToken: JsonField, + private val type: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [AzureBlobStorage]. + * + * The following fields are required: + * ```java + * .accountName() + * .container() + * .name() + * .sasToken() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlobStorage]. */ + 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: JsonField? = null + 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(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.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 } + + 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 } + + /** 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 [AzureBlobStorage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountName() + * .container() + * .name() + * .sasToken() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("name", name), + checkRequired("sasToken", sasToken), + checkRequired("type", type), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply + } + + accountName() + container() + name() + sasToken() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + 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 AZURE_BLOB = of("AZURE_BLOB") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AZURE_BLOB + } + + /** + * 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 { + AZURE_BLOB, + /** + * 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) { + AZURE_BLOB -> Value.AZURE_BLOB + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AZURE_BLOB -> Known.AZURE_BLOB + 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 AzureBlobStorage && + 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() = + "AzureBlobStorage{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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * .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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * .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), + checkRequired("type", 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().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (username.asKnown().isPresent) 1 else 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKENEO_PIM + } + + /** + * 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 { + AKENEO_PIM, + /** + * 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) { + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKENEO_PIM -> Known.AKENEO_PIM + 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 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}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OriginUpdateParams && + 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() = + "OriginUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt new file mode 100644 index 00000000..baa71f32 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt @@ -0,0 +1,4589 @@ +// 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.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.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 = OriginUpdateResponse.Deserializer::class) +@JsonSerialize(using = OriginUpdateResponse.Serializer::class) +class OriginUpdateResponse +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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = 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 googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) + + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + + 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 isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + + fun isAzureBlobStorage(): Boolean = azureBlobStorage != 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 asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + + 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): OriginUpdateResponse = 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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() + } + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.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 OriginUpdateResponse && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && + akeneoPim == other.akeneoPim + } + + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + googleCloudStorageGcs, + azureBlobStorage, + akeneoPim, + ) + + override fun toString(): String = + when { + s3 != null -> "OriginUpdateResponse{s3=$s3}" + s3Compatible != null -> "OriginUpdateResponse{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "OriginUpdateResponse{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "OriginUpdateResponse{webFolder=$webFolder}" + webProxy != null -> "OriginUpdateResponse{webProxy=$webProxy}" + googleCloudStorageGcs != null -> + "OriginUpdateResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "OriginUpdateResponse{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "OriginUpdateResponse{akeneoPim=$akeneoPim}" + _json != null -> "OriginUpdateResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid OriginUpdateResponse") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = OriginUpdateResponse(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = + OriginUpdateResponse(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + OriginUpdateResponse(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic + fun ofWebFolder(webFolder: WebFolder) = OriginUpdateResponse(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginUpdateResponse(webProxy = webProxy) + + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + OriginUpdateResponse(googleCloudStorageGcs = googleCloudStorageGcs) + + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + OriginUpdateResponse(azureBlobStorage = azureBlobStorage) + + @JvmStatic + fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginUpdateResponse(akeneoPim = akeneoPim) + } + + /** + * An interface that defines how to map each variant of [OriginUpdateResponse] 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 visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): T + + /** + * Maps an unknown variant of [OriginUpdateResponse] to a value of type [T]. + * + * An instance of [OriginUpdateResponse] 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 OriginUpdateResponse: $json") + } + } + + internal class Deserializer : + BaseDeserializer(OriginUpdateResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): OriginUpdateResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(akeneoPim = 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 -> OriginUpdateResponse(_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(OriginUpdateResponse::class) { + + override fun serialize( + value: OriginUpdateResponse, + 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid OriginUpdateResponse") + } + } + } + + class S3 + private constructor( + private val id: JsonField, + private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var type: JsonField? = null + 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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3 = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 S3 = of("S3") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3 + } + + /** + * 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 { + S3, + /** 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) { + S3 -> Value.S3 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + 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 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: JsonValue, + private val s3ForcePathStyle: JsonField, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + s3ForcePathStyle: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var s3ForcePathStyle: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3Compatible = apply { + if (validated) { + return@apply + } + + id() + bucket() + endpoint() + includeCanonicalHeader() + name() + s3ForcePathStyle() + type().validate() + 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 (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3_COMPATIBLE + } + + /** + * 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 { + S3_COMPATIBLE, + /** 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) { + S3_COMPATIBLE -> Value.S3_COMPATIBLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3_COMPATIBLE -> Known.S3_COMPATIBLE + 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 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonValue? = null + private var type: JsonField? = null + 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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryBackup = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY_BACKUP + } + + /** + * 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 { + CLOUDINARY_BACKUP, + /** 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) { + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + 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 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: JsonValue, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = 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: JsonField = 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. */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebFolder]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonValue? = null + private var forwardHostHeaderToOrigin: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @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), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebFolder = apply { + if (validated) { + return@apply + } + + id() + forwardHostHeaderToOrigin() + includeCanonicalHeader() + name() + type().validate() + 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 (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_FOLDER = of("WEB_FOLDER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_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 { + WEB_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) { + WEB_FOLDER -> Value.WEB_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) { + WEB_FOLDER -> Known.WEB_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 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebProxy = + WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebProxy = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 WEB_PROXY = of("WEB_PROXY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_PROXY + } + + /** + * 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 { + WEB_PROXY, + /** 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) { + WEB_PROXY -> Value.WEB_PROXY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_PROXY -> Known.WEB_PROXY + 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 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 GoogleCloudStorageGcs + 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [GoogleCloudStorageGcs]. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleCloudStorageGcs]. */ + 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: JsonValue? = null + private var type: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + id = googleCloudStorageGcs.id + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + name = googleCloudStorageGcs.name + prefix = googleCloudStorageGcs.prefix + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + additionalProperties = googleCloudStorageGcs.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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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 [GoogleCloudStorageGcs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( + checkRequired("id", id), + checkRequired("bucket", bucket), + checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } + + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 GCS = of("GCS") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GCS + } + + /** + * 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 { + GCS, + /** 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) { + GCS -> Value.GCS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GCS -> Known.GCS + 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 GoogleCloudStorageGcs && + 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() = + "GoogleCloudStorageGcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class AzureBlobStorage + 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: JsonValue, + private val type: JsonField, + 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: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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 [AzureBlobStorage]. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlobStorage]. */ + 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: JsonValue? = null + private var type: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + id = azureBlobStorage.id + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + name = azureBlobStorage.name + prefix = azureBlobStorage.prefix + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + additionalProperties = azureBlobStorage.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: JsonValue) = apply { this.prefix = prefix } + + 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 } + + /** 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 [AzureBlobStorage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply + } + + id() + accountName() + container() + includeCanonicalHeader() + name() + type().validate() + 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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AZURE_BLOB = of("AZURE_BLOB") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AZURE_BLOB + } + + /** + * 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 { + AZURE_BLOB, + /** 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) { + AZURE_BLOB -> Value.AZURE_BLOB + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AZURE_BLOB -> Known.AZURE_BLOB + 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 AzureBlobStorage && + 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() = + "AzureBlobStorage{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: JsonValue, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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. */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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 [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 [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() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkeneoPim]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonValue? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + 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: JsonValue) = 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 } + + 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 } + + /** 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AkeneoPim = + AkeneoPim( + checkRequired("id", id), + checkRequired("baseUrl", baseUrl), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("type", type), + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkeneoPim = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + 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 AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKENEO_PIM + } + + /** + * 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 { + AKENEO_PIM, + /** 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) { + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKENEO_PIM -> Known.AKENEO_PIM + 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 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/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..ee48d3bd --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt @@ -0,0 +1,1818 @@ +// 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.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 + +/** + * **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns the resulting + * object. + */ +class UrlEndpointCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * 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 = body.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> = body.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 = body.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 = body.urlRewriter() + + /** + * 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 [origins]. + * + * Unlike [origins], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _origins(): JsonField> = body._origins() + + /** + * Returns the raw JSON value of [urlPrefix]. + * + * Unlike [urlPrefix], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _urlPrefix(): JsonField = body._urlPrefix() + + /** + * Returns the raw JSON value of [urlRewriter]. + * + * Unlike [urlRewriter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _urlRewriter(): JsonField = body._urlRewriter() + + 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 [UrlEndpointCreateParams]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointCreateParams]. */ + 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(urlEndpointCreateParams: UrlEndpointCreateParams) = apply { + body = urlEndpointCreateParams.body.toBuilder() + additionalHeaders = urlEndpointCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = urlEndpointCreateParams.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: + * - [description] + * - [origins] + * - [urlPrefix] + * - [urlRewriter] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Description of the URL endpoint. */ + 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) } + + /** + * 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) = apply { body.origins(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 { body.origins(origins) } + + /** + * Adds a single [String] to [origins]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOrigin(origin: String) = apply { body.addOrigin(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) = apply { body.urlPrefix(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 { body.urlPrefix(urlPrefix) } + + /** Configuration for third-party URL rewriting. */ + fun urlRewriter(urlRewriter: UrlRewriter) = apply { body.urlRewriter(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 { + body.urlRewriter(urlRewriter) + } + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ + fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = apply { + body.urlRewriter(cloudinary) + } + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ + fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = apply { body.urlRewriter(imgix) } + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ + fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = apply { body.urlRewriter(akamai) } + + 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 [UrlEndpointCreateParams]. + * + * 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(): UrlEndpointCreateParams = + UrlEndpointCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Schema for URL endpoint resource. */ + class Body + 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 [Body]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + 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(body: Body) = apply { + description = body.description + origins = body.origins.map { it.toMutableList() } + urlPrefix = body.urlPrefix + urlRewriter = body.urlRewriter + additionalProperties = body.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.CloudinaryUrlRewriter) = + urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ + fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = + urlRewriter(UrlRewriter.ofImgix(imgix)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ + fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = + urlRewriter(UrlRewriter.ofAkamai(akamai)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .description() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("description", description), + (origins ?: JsonMissing.of()).map { it.toImmutable() }, + urlPrefix, + urlRewriter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + 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() = + "Body{description=$description, origins=$origins, urlPrefix=$urlPrefix, urlRewriter=$urlRewriter, additionalProperties=$additionalProperties}" + } + + /** Configuration for third-party URL rewriting. */ + @JsonDeserialize(using = UrlRewriter.Deserializer::class) + @JsonSerialize(using = UrlRewriter.Serializer::class) + class UrlRewriter + private constructor( + private val cloudinary: CloudinaryUrlRewriter? = null, + private val imgix: ImgixUrlRewriter? = null, + private val akamai: AkamaiUrlRewriter? = 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(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + + fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + + fun asAkamai(): AkamaiUrlRewriter = 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: CloudinaryUrlRewriter) { + cloudinary.validate() + } + + override fun visitImgix(imgix: ImgixUrlRewriter) { + imgix.validate() + } + + override fun visitAkamai(akamai: AkamaiUrlRewriter) { + akamai.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 visitCloudinary(cloudinary: CloudinaryUrlRewriter) = + cloudinary.validity() + + override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + + override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + + 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: CloudinaryUrlRewriter) = + UrlRewriter(cloudinary = cloudinary) + + @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + + @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + } + + /** + * An interface that defines how to map each variant of [UrlRewriter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + + fun visitImgix(imgix: ImgixUrlRewriter): T + + fun visitAkamai(akamai: AkamaiUrlRewriter): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(cloudinary = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(imgix = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(akamai = 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 -> UrlRewriter(_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(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 CloudinaryUrlRewriter + private constructor( + private val type: JsonField, + private val preserveAssetDeliveryTypes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), + ) : this(type, preserveAssetDeliveryTypes, 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 type(): Type = type.getRequired("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 [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 [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 + * [CloudinaryUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CloudinaryUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var preserveAssetDeliveryTypes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { + type = cloudinaryUrlRewriter.type + preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes + additionalProperties = cloudinaryUrlRewriter.additionalProperties.toMutableMap() + } + + 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 } + + /** 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 [CloudinaryUrlRewriter]. + * + * 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(): CloudinaryUrlRewriter = + CloudinaryUrlRewriter( + checkRequired("type", type), + preserveAssetDeliveryTypes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryUrlRewriter = apply { + if (validated) { + return@apply + } + + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + + 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 CLOUDINARY = of("CLOUDINARY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY + } + + /** + * 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 { + CLOUDINARY, + /** + * 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) { + CLOUDINARY -> Value.CLOUDINARY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY -> Known.CLOUDINARY + 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 CloudinaryUrlRewriter && + 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() = + "CloudinaryUrlRewriter{type=$type, preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, additionalProperties=$additionalProperties}" + } + + class ImgixUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [ImgixUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ImgixUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { + type = imgixUrlRewriter.type + additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [ImgixUrlRewriter]. + * + * 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(): ImgixUrlRewriter = + ImgixUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ImgixUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 IMGIX = of("IMGIX") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMGIX + } + + /** + * 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 { + IMGIX, + /** + * 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) { + IMGIX -> Value.IMGIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + IMGIX -> Known.IMGIX + 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 ImgixUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + + class AkamaiUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [AkamaiUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkamaiUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { + type = akamaiUrlRewriter.type + additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [AkamaiUrlRewriter]. + * + * 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(): AkamaiUrlRewriter = + AkamaiUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkamaiUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 AKAMAI = of("AKAMAI") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKAMAI + } + + /** + * 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 { + AKAMAI, + /** + * 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) { + AKAMAI -> Value.AKAMAI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKAMAI -> Known.AKAMAI + 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 AkamaiUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "UrlEndpointCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt new file mode 100644 index 00000000..d2bd5e61 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt @@ -0,0 +1,1497 @@ +// 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.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 + +/** URL‑endpoint object as returned by the API. */ +class UrlEndpointCreateResponse +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 [UrlEndpointCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .origins() + * .urlPrefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointCreateResponse]. */ + 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(urlEndpointCreateResponse: UrlEndpointCreateResponse) = apply { + id = urlEndpointCreateResponse.id + description = urlEndpointCreateResponse.description + origins = urlEndpointCreateResponse.origins.map { it.toMutableList() } + urlPrefix = urlEndpointCreateResponse.urlPrefix + urlRewriter = urlEndpointCreateResponse.urlRewriter + additionalProperties = urlEndpointCreateResponse.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.CloudinaryUrlRewriter) = + urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ + fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = + urlRewriter(UrlRewriter.ofImgix(imgix)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ + fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = + urlRewriter(UrlRewriter.ofAkamai(akamai)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlEndpointCreateResponse]. + * + * 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(): UrlEndpointCreateResponse = + UrlEndpointCreateResponse( + 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(): UrlEndpointCreateResponse = 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: CloudinaryUrlRewriter? = null, + private val imgix: ImgixUrlRewriter? = null, + private val akamai: AkamaiUrlRewriter? = 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(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + + fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + + fun asAkamai(): AkamaiUrlRewriter = 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: CloudinaryUrlRewriter) { + cloudinary.validate() + } + + override fun visitImgix(imgix: ImgixUrlRewriter) { + imgix.validate() + } + + override fun visitAkamai(akamai: AkamaiUrlRewriter) { + akamai.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 visitCloudinary(cloudinary: CloudinaryUrlRewriter) = + cloudinary.validity() + + override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + + override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + + 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: CloudinaryUrlRewriter) = + UrlRewriter(cloudinary = cloudinary) + + @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + + @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + } + + /** + * An interface that defines how to map each variant of [UrlRewriter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + + fun visitImgix(imgix: ImgixUrlRewriter): T + + fun visitAkamai(akamai: AkamaiUrlRewriter): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(cloudinary = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(imgix = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(akamai = 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 -> UrlRewriter(_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(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 CloudinaryUrlRewriter + private constructor( + private val preserveAssetDeliveryTypes: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [preserveAssetDeliveryTypes]. + * + * Unlike [preserveAssetDeliveryTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes + + /** + * 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 + * [CloudinaryUrlRewriter]. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CloudinaryUrlRewriter]. */ + class Builder internal constructor() { + + private var preserveAssetDeliveryTypes: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { + preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes + type = cloudinaryUrlRewriter.type + additionalProperties = cloudinaryUrlRewriter.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 + } + + 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 [CloudinaryUrlRewriter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CloudinaryUrlRewriter = + CloudinaryUrlRewriter( + checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryUrlRewriter = apply { + if (validated) { + return@apply + } + + preserveAssetDeliveryTypes() + type().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 (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + 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 CLOUDINARY = of("CLOUDINARY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY + } + + /** + * 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 { + CLOUDINARY, + /** + * 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) { + CLOUDINARY -> Value.CLOUDINARY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY -> Known.CLOUDINARY + 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 CloudinaryUrlRewriter && + 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() = + "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + } + + class ImgixUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [ImgixUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ImgixUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { + type = imgixUrlRewriter.type + additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [ImgixUrlRewriter]. + * + * 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(): ImgixUrlRewriter = + ImgixUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ImgixUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 IMGIX = of("IMGIX") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMGIX + } + + /** + * 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 { + IMGIX, + /** + * 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) { + IMGIX -> Value.IMGIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + IMGIX -> Known.IMGIX + 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 ImgixUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + + class AkamaiUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [AkamaiUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkamaiUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { + type = akamaiUrlRewriter.type + additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [AkamaiUrlRewriter]. + * + * 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(): AkamaiUrlRewriter = + AkamaiUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkamaiUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 AKAMAI = of("AKAMAI") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKAMAI + } + + /** + * 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 { + AKAMAI, + /** + * 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) { + AKAMAI -> Value.AKAMAI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKAMAI -> Known.AKAMAI + 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 AkamaiUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointCreateResponse && + 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() = + "UrlEndpointCreateResponse{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/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/UrlEndpointGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt new file mode 100644 index 00000000..7934a7c8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt @@ -0,0 +1,1497 @@ +// 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.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 + +/** URL‑endpoint object as returned by the API. */ +class UrlEndpointGetResponse +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 [UrlEndpointGetResponse]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .origins() + * .urlPrefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointGetResponse]. */ + 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(urlEndpointGetResponse: UrlEndpointGetResponse) = apply { + id = urlEndpointGetResponse.id + description = urlEndpointGetResponse.description + origins = urlEndpointGetResponse.origins.map { it.toMutableList() } + urlPrefix = urlEndpointGetResponse.urlPrefix + urlRewriter = urlEndpointGetResponse.urlRewriter + additionalProperties = urlEndpointGetResponse.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.CloudinaryUrlRewriter) = + urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ + fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = + urlRewriter(UrlRewriter.ofImgix(imgix)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ + fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = + urlRewriter(UrlRewriter.ofAkamai(akamai)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlEndpointGetResponse]. + * + * 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(): UrlEndpointGetResponse = + UrlEndpointGetResponse( + 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(): UrlEndpointGetResponse = 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: CloudinaryUrlRewriter? = null, + private val imgix: ImgixUrlRewriter? = null, + private val akamai: AkamaiUrlRewriter? = 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(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + + fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + + fun asAkamai(): AkamaiUrlRewriter = 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: CloudinaryUrlRewriter) { + cloudinary.validate() + } + + override fun visitImgix(imgix: ImgixUrlRewriter) { + imgix.validate() + } + + override fun visitAkamai(akamai: AkamaiUrlRewriter) { + akamai.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 visitCloudinary(cloudinary: CloudinaryUrlRewriter) = + cloudinary.validity() + + override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + + override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + + 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: CloudinaryUrlRewriter) = + UrlRewriter(cloudinary = cloudinary) + + @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + + @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + } + + /** + * An interface that defines how to map each variant of [UrlRewriter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + + fun visitImgix(imgix: ImgixUrlRewriter): T + + fun visitAkamai(akamai: AkamaiUrlRewriter): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(cloudinary = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(imgix = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(akamai = 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 -> UrlRewriter(_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(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 CloudinaryUrlRewriter + private constructor( + private val preserveAssetDeliveryTypes: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [preserveAssetDeliveryTypes]. + * + * Unlike [preserveAssetDeliveryTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes + + /** + * 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 + * [CloudinaryUrlRewriter]. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CloudinaryUrlRewriter]. */ + class Builder internal constructor() { + + private var preserveAssetDeliveryTypes: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { + preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes + type = cloudinaryUrlRewriter.type + additionalProperties = cloudinaryUrlRewriter.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 + } + + 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 [CloudinaryUrlRewriter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CloudinaryUrlRewriter = + CloudinaryUrlRewriter( + checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryUrlRewriter = apply { + if (validated) { + return@apply + } + + preserveAssetDeliveryTypes() + type().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 (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + 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 CLOUDINARY = of("CLOUDINARY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY + } + + /** + * 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 { + CLOUDINARY, + /** + * 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) { + CLOUDINARY -> Value.CLOUDINARY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY -> Known.CLOUDINARY + 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 CloudinaryUrlRewriter && + 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() = + "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + } + + class ImgixUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [ImgixUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ImgixUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { + type = imgixUrlRewriter.type + additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [ImgixUrlRewriter]. + * + * 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(): ImgixUrlRewriter = + ImgixUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ImgixUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 IMGIX = of("IMGIX") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMGIX + } + + /** + * 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 { + IMGIX, + /** + * 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) { + IMGIX -> Value.IMGIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + IMGIX -> Known.IMGIX + 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 ImgixUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + + class AkamaiUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [AkamaiUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkamaiUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { + type = akamaiUrlRewriter.type + additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [AkamaiUrlRewriter]. + * + * 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(): AkamaiUrlRewriter = + AkamaiUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkamaiUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 AKAMAI = of("AKAMAI") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKAMAI + } + + /** + * 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 { + AKAMAI, + /** + * 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) { + AKAMAI -> Value.AKAMAI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKAMAI -> Known.AKAMAI + 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 AkamaiUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointGetResponse && + 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() = + "UrlEndpointGetResponse{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/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/UrlEndpointListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt new file mode 100644 index 00000000..f5f5754d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt @@ -0,0 +1,1497 @@ +// 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.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 + +/** URL‑endpoint object as returned by the API. */ +class UrlEndpointListResponse +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 [UrlEndpointListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .origins() + * .urlPrefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointListResponse]. */ + 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(urlEndpointListResponse: UrlEndpointListResponse) = apply { + id = urlEndpointListResponse.id + description = urlEndpointListResponse.description + origins = urlEndpointListResponse.origins.map { it.toMutableList() } + urlPrefix = urlEndpointListResponse.urlPrefix + urlRewriter = urlEndpointListResponse.urlRewriter + additionalProperties = urlEndpointListResponse.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.CloudinaryUrlRewriter) = + urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ + fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = + urlRewriter(UrlRewriter.ofImgix(imgix)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ + fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = + urlRewriter(UrlRewriter.ofAkamai(akamai)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlEndpointListResponse]. + * + * 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(): UrlEndpointListResponse = + UrlEndpointListResponse( + 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(): UrlEndpointListResponse = 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: CloudinaryUrlRewriter? = null, + private val imgix: ImgixUrlRewriter? = null, + private val akamai: AkamaiUrlRewriter? = 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(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + + fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + + fun asAkamai(): AkamaiUrlRewriter = 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: CloudinaryUrlRewriter) { + cloudinary.validate() + } + + override fun visitImgix(imgix: ImgixUrlRewriter) { + imgix.validate() + } + + override fun visitAkamai(akamai: AkamaiUrlRewriter) { + akamai.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 visitCloudinary(cloudinary: CloudinaryUrlRewriter) = + cloudinary.validity() + + override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + + override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + + 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: CloudinaryUrlRewriter) = + UrlRewriter(cloudinary = cloudinary) + + @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + + @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + } + + /** + * An interface that defines how to map each variant of [UrlRewriter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + + fun visitImgix(imgix: ImgixUrlRewriter): T + + fun visitAkamai(akamai: AkamaiUrlRewriter): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(cloudinary = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(imgix = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(akamai = 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 -> UrlRewriter(_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(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 CloudinaryUrlRewriter + private constructor( + private val preserveAssetDeliveryTypes: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [preserveAssetDeliveryTypes]. + * + * Unlike [preserveAssetDeliveryTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes + + /** + * 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 + * [CloudinaryUrlRewriter]. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CloudinaryUrlRewriter]. */ + class Builder internal constructor() { + + private var preserveAssetDeliveryTypes: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { + preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes + type = cloudinaryUrlRewriter.type + additionalProperties = cloudinaryUrlRewriter.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 + } + + 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 [CloudinaryUrlRewriter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CloudinaryUrlRewriter = + CloudinaryUrlRewriter( + checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryUrlRewriter = apply { + if (validated) { + return@apply + } + + preserveAssetDeliveryTypes() + type().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 (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + 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 CLOUDINARY = of("CLOUDINARY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY + } + + /** + * 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 { + CLOUDINARY, + /** + * 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) { + CLOUDINARY -> Value.CLOUDINARY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY -> Known.CLOUDINARY + 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 CloudinaryUrlRewriter && + 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() = + "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + } + + class ImgixUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [ImgixUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ImgixUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { + type = imgixUrlRewriter.type + additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [ImgixUrlRewriter]. + * + * 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(): ImgixUrlRewriter = + ImgixUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ImgixUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 IMGIX = of("IMGIX") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMGIX + } + + /** + * 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 { + IMGIX, + /** + * 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) { + IMGIX -> Value.IMGIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + IMGIX -> Known.IMGIX + 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 ImgixUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + + class AkamaiUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [AkamaiUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkamaiUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { + type = akamaiUrlRewriter.type + additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [AkamaiUrlRewriter]. + * + * 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(): AkamaiUrlRewriter = + AkamaiUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkamaiUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 AKAMAI = of("AKAMAI") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKAMAI + } + + /** + * 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 { + AKAMAI, + /** + * 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) { + AKAMAI -> Value.AKAMAI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKAMAI -> Known.AKAMAI + 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 AkamaiUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointListResponse && + 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() = + "UrlEndpointListResponse{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..7fc0d953 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt @@ -0,0 +1,1844 @@ +// 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.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 + +/** + * **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 body: Body, + 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) + + /** + * 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 = body.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> = body.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 = body.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 = body.urlRewriter() + + /** + * 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 [origins]. + * + * Unlike [origins], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _origins(): JsonField> = body._origins() + + /** + * Returns the raw JSON value of [urlPrefix]. + * + * Unlike [urlPrefix], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _urlPrefix(): JsonField = body._urlPrefix() + + /** + * Returns the raw JSON value of [urlRewriter]. + * + * Unlike [urlRewriter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _urlRewriter(): JsonField = body._urlRewriter() + + 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 [UrlEndpointUpdateParams]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointUpdateParams]. */ + 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(urlEndpointUpdateParams: UrlEndpointUpdateParams) = apply { + id = urlEndpointUpdateParams.id + body = urlEndpointUpdateParams.body.toBuilder() + 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()) + + /** + * 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: + * - [description] + * - [origins] + * - [urlPrefix] + * - [urlRewriter] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Description of the URL endpoint. */ + 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) } + + /** + * 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) = apply { body.origins(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 { body.origins(origins) } + + /** + * Adds a single [String] to [origins]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOrigin(origin: String) = apply { body.addOrigin(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) = apply { body.urlPrefix(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 { body.urlPrefix(urlPrefix) } + + /** Configuration for third-party URL rewriting. */ + fun urlRewriter(urlRewriter: UrlRewriter) = apply { body.urlRewriter(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 { + body.urlRewriter(urlRewriter) + } + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ + fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = apply { + body.urlRewriter(cloudinary) + } + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ + fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = apply { body.urlRewriter(imgix) } + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ + fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = apply { body.urlRewriter(akamai) } + + 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 [UrlEndpointUpdateParams]. + * + * 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(): UrlEndpointUpdateParams = + UrlEndpointUpdateParams( + 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 + + /** Schema for URL endpoint resource. */ + class Body + 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 [Body]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + 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(body: Body) = apply { + description = body.description + origins = body.origins.map { it.toMutableList() } + urlPrefix = body.urlPrefix + urlRewriter = body.urlRewriter + additionalProperties = body.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.CloudinaryUrlRewriter) = + urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ + fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = + urlRewriter(UrlRewriter.ofImgix(imgix)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ + fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = + urlRewriter(UrlRewriter.ofAkamai(akamai)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .description() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("description", description), + (origins ?: JsonMissing.of()).map { it.toImmutable() }, + urlPrefix, + urlRewriter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + 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() = + "Body{description=$description, origins=$origins, urlPrefix=$urlPrefix, urlRewriter=$urlRewriter, additionalProperties=$additionalProperties}" + } + + /** Configuration for third-party URL rewriting. */ + @JsonDeserialize(using = UrlRewriter.Deserializer::class) + @JsonSerialize(using = UrlRewriter.Serializer::class) + class UrlRewriter + private constructor( + private val cloudinary: CloudinaryUrlRewriter? = null, + private val imgix: ImgixUrlRewriter? = null, + private val akamai: AkamaiUrlRewriter? = 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(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + + fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + + fun asAkamai(): AkamaiUrlRewriter = 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: CloudinaryUrlRewriter) { + cloudinary.validate() + } + + override fun visitImgix(imgix: ImgixUrlRewriter) { + imgix.validate() + } + + override fun visitAkamai(akamai: AkamaiUrlRewriter) { + akamai.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 visitCloudinary(cloudinary: CloudinaryUrlRewriter) = + cloudinary.validity() + + override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + + override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + + 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: CloudinaryUrlRewriter) = + UrlRewriter(cloudinary = cloudinary) + + @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + + @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + } + + /** + * An interface that defines how to map each variant of [UrlRewriter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + + fun visitImgix(imgix: ImgixUrlRewriter): T + + fun visitAkamai(akamai: AkamaiUrlRewriter): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(cloudinary = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(imgix = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(akamai = 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 -> UrlRewriter(_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(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 CloudinaryUrlRewriter + private constructor( + private val type: JsonField, + private val preserveAssetDeliveryTypes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), + ) : this(type, preserveAssetDeliveryTypes, 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 type(): Type = type.getRequired("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 [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 [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 + * [CloudinaryUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CloudinaryUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var preserveAssetDeliveryTypes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { + type = cloudinaryUrlRewriter.type + preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes + additionalProperties = cloudinaryUrlRewriter.additionalProperties.toMutableMap() + } + + 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 } + + /** 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 [CloudinaryUrlRewriter]. + * + * 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(): CloudinaryUrlRewriter = + CloudinaryUrlRewriter( + checkRequired("type", type), + preserveAssetDeliveryTypes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryUrlRewriter = apply { + if (validated) { + return@apply + } + + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + + 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 CLOUDINARY = of("CLOUDINARY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY + } + + /** + * 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 { + CLOUDINARY, + /** + * 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) { + CLOUDINARY -> Value.CLOUDINARY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY -> Known.CLOUDINARY + 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 CloudinaryUrlRewriter && + 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() = + "CloudinaryUrlRewriter{type=$type, preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, additionalProperties=$additionalProperties}" + } + + class ImgixUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [ImgixUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ImgixUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { + type = imgixUrlRewriter.type + additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [ImgixUrlRewriter]. + * + * 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(): ImgixUrlRewriter = + ImgixUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ImgixUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 IMGIX = of("IMGIX") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMGIX + } + + /** + * 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 { + IMGIX, + /** + * 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) { + IMGIX -> Value.IMGIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + IMGIX -> Known.IMGIX + 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 ImgixUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + + class AkamaiUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [AkamaiUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkamaiUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { + type = akamaiUrlRewriter.type + additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [AkamaiUrlRewriter]. + * + * 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(): AkamaiUrlRewriter = + AkamaiUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkamaiUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 AKAMAI = of("AKAMAI") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKAMAI + } + + /** + * 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 { + AKAMAI, + /** + * 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) { + AKAMAI -> Value.AKAMAI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKAMAI -> Known.AKAMAI + 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 AkamaiUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointUpdateParams && + 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() = + "UrlEndpointUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt new file mode 100644 index 00000000..9de2612a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt @@ -0,0 +1,1497 @@ +// 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.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 + +/** URL‑endpoint object as returned by the API. */ +class UrlEndpointUpdateResponse +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 [UrlEndpointUpdateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .origins() + * .urlPrefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointUpdateResponse]. */ + 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(urlEndpointUpdateResponse: UrlEndpointUpdateResponse) = apply { + id = urlEndpointUpdateResponse.id + description = urlEndpointUpdateResponse.description + origins = urlEndpointUpdateResponse.origins.map { it.toMutableList() } + urlPrefix = urlEndpointUpdateResponse.urlPrefix + urlRewriter = urlEndpointUpdateResponse.urlRewriter + additionalProperties = urlEndpointUpdateResponse.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.CloudinaryUrlRewriter) = + urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ + fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = + urlRewriter(UrlRewriter.ofImgix(imgix)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ + fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = + urlRewriter(UrlRewriter.ofAkamai(akamai)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlEndpointUpdateResponse]. + * + * 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(): UrlEndpointUpdateResponse = + UrlEndpointUpdateResponse( + 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(): UrlEndpointUpdateResponse = 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: CloudinaryUrlRewriter? = null, + private val imgix: ImgixUrlRewriter? = null, + private val akamai: AkamaiUrlRewriter? = 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(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + + fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + + fun asAkamai(): AkamaiUrlRewriter = 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: CloudinaryUrlRewriter) { + cloudinary.validate() + } + + override fun visitImgix(imgix: ImgixUrlRewriter) { + imgix.validate() + } + + override fun visitAkamai(akamai: AkamaiUrlRewriter) { + akamai.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 visitCloudinary(cloudinary: CloudinaryUrlRewriter) = + cloudinary.validity() + + override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + + override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + + 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: CloudinaryUrlRewriter) = + UrlRewriter(cloudinary = cloudinary) + + @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + + @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + } + + /** + * An interface that defines how to map each variant of [UrlRewriter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + + fun visitImgix(imgix: ImgixUrlRewriter): T + + fun visitAkamai(akamai: AkamaiUrlRewriter): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(cloudinary = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(imgix = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(akamai = 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 -> UrlRewriter(_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(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 CloudinaryUrlRewriter + private constructor( + private val preserveAssetDeliveryTypes: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [preserveAssetDeliveryTypes]. + * + * Unlike [preserveAssetDeliveryTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes + + /** + * 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 + * [CloudinaryUrlRewriter]. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CloudinaryUrlRewriter]. */ + class Builder internal constructor() { + + private var preserveAssetDeliveryTypes: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { + preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes + type = cloudinaryUrlRewriter.type + additionalProperties = cloudinaryUrlRewriter.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 + } + + 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 [CloudinaryUrlRewriter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CloudinaryUrlRewriter = + CloudinaryUrlRewriter( + checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryUrlRewriter = apply { + if (validated) { + return@apply + } + + preserveAssetDeliveryTypes() + type().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 (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + 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 CLOUDINARY = of("CLOUDINARY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY + } + + /** + * 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 { + CLOUDINARY, + /** + * 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) { + CLOUDINARY -> Value.CLOUDINARY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY -> Known.CLOUDINARY + 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 CloudinaryUrlRewriter && + 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() = + "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + } + + class ImgixUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [ImgixUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ImgixUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { + type = imgixUrlRewriter.type + additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [ImgixUrlRewriter]. + * + * 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(): ImgixUrlRewriter = + ImgixUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ImgixUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 IMGIX = of("IMGIX") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMGIX + } + + /** + * 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 { + IMGIX, + /** + * 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) { + IMGIX -> Value.IMGIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + IMGIX -> Known.IMGIX + 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 ImgixUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + + class AkamaiUrlRewriter + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, 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 type(): Type = type.getRequired("type") + + /** + * 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 [AkamaiUrlRewriter]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkamaiUrlRewriter]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { + type = akamaiUrlRewriter.type + additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() + } + + 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 [AkamaiUrlRewriter]. + * + * 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(): AkamaiUrlRewriter = + AkamaiUrlRewriter( + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkamaiUrlRewriter = apply { + if (validated) { + return@apply + } + + type().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) + + 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 AKAMAI = of("AKAMAI") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKAMAI + } + + /** + * 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 { + AKAMAI, + /** + * 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) { + AKAMAI -> Value.AKAMAI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKAMAI -> Known.AKAMAI + 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 AkamaiUrlRewriter && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointUpdateResponse && + 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() = + "UrlEndpointUpdateResponse{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/AccountGetUsageParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt index 5f85926e..a8e88bf6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts +package com.imagekit.api.models.accounts.usage import com.imagekit.api.core.Params import com.imagekit.api.core.checkRequired @@ -14,7 +14,7 @@ import java.util.Objects * 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 AccountGetUsageParams +class UsageGetParams private constructor( private val endDate: LocalDate, private val startDate: LocalDate, @@ -45,7 +45,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AccountGetUsageParams]. + * Returns a mutable builder for constructing an instance of [UsageGetParams]. * * The following fields are required: * ```java @@ -56,7 +56,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AccountGetUsageParams]. */ + /** A builder for [UsageGetParams]. */ class Builder internal constructor() { private var endDate: LocalDate? = null @@ -65,11 +65,11 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(accountGetUsageParams: AccountGetUsageParams) = apply { - endDate = accountGetUsageParams.endDate - startDate = accountGetUsageParams.startDate - additionalHeaders = accountGetUsageParams.additionalHeaders.toBuilder() - additionalQueryParams = accountGetUsageParams.additionalQueryParams.toBuilder() + internal fun from(usageGetParams: UsageGetParams) = apply { + endDate = usageGetParams.endDate + startDate = usageGetParams.startDate + additionalHeaders = usageGetParams.additionalHeaders.toBuilder() + additionalQueryParams = usageGetParams.additionalQueryParams.toBuilder() } /** @@ -183,7 +183,7 @@ private constructor( } /** - * Returns an immutable instance of [AccountGetUsageParams]. + * Returns an immutable instance of [UsageGetParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -195,8 +195,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AccountGetUsageParams = - AccountGetUsageParams( + fun build(): UsageGetParams = + UsageGetParams( checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalHeaders.build(), @@ -220,7 +220,7 @@ private constructor( return true } - return other is AccountGetUsageParams && + return other is UsageGetParams && endDate == other.endDate && startDate == other.startDate && additionalHeaders == other.additionalHeaders && @@ -231,5 +231,5 @@ private constructor( Objects.hash(endDate, startDate, additionalHeaders, additionalQueryParams) override fun toString() = - "AccountGetUsageParams{endDate=$endDate, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "UsageGetParams{endDate=$endDate, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt index 8ea6ef2a..3239c0ed 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts +package com.imagekit.api.models.accounts.usage import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -15,7 +15,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional -class AccountGetUsageResponse +class UsageGetResponse private constructor( private val bandwidthBytes: JsonField, private val extensionUnitsCount: JsonField, @@ -158,11 +158,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [AccountGetUsageResponse]. */ + /** Returns a mutable builder for constructing an instance of [UsageGetResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [AccountGetUsageResponse]. */ + /** A builder for [UsageGetResponse]. */ class Builder internal constructor() { private var bandwidthBytes: JsonField = JsonMissing.of() @@ -173,13 +173,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(accountGetUsageResponse: AccountGetUsageResponse) = apply { - bandwidthBytes = accountGetUsageResponse.bandwidthBytes - extensionUnitsCount = accountGetUsageResponse.extensionUnitsCount - mediaLibraryStorageBytes = accountGetUsageResponse.mediaLibraryStorageBytes - originalCacheStorageBytes = accountGetUsageResponse.originalCacheStorageBytes - videoProcessingUnitsCount = accountGetUsageResponse.videoProcessingUnitsCount - additionalProperties = accountGetUsageResponse.additionalProperties.toMutableMap() + 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. */ @@ -276,12 +276,12 @@ private constructor( } /** - * Returns an immutable instance of [AccountGetUsageResponse]. + * Returns an immutable instance of [UsageGetResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): AccountGetUsageResponse = - AccountGetUsageResponse( + fun build(): UsageGetResponse = + UsageGetResponse( bandwidthBytes, extensionUnitsCount, mediaLibraryStorageBytes, @@ -293,7 +293,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AccountGetUsageResponse = apply { + fun validate(): UsageGetResponse = apply { if (validated) { return@apply } @@ -332,7 +332,7 @@ private constructor( return true } - return other is AccountGetUsageResponse && + return other is UsageGetResponse && bandwidthBytes == other.bandwidthBytes && extensionUnitsCount == other.extensionUnitsCount && mediaLibraryStorageBytes == other.mediaLibraryStorageBytes && @@ -355,5 +355,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AccountGetUsageResponse{bandwidthBytes=$bandwidthBytes, extensionUnitsCount=$extensionUnitsCount, mediaLibraryStorageBytes=$mediaLibraryStorageBytes, originalCacheStorageBytes=$originalCacheStorageBytes, videoProcessingUnitsCount=$videoProcessingUnitsCount, additionalProperties=$additionalProperties}" + "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..266e31e8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListResponse.kt @@ -0,0 +1,2070 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.assets + +import 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 + +/** 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 fileDetails: FileDetails? = null, + private val folderDetails: FolderDetails? = null, + private val _json: JsonValue? = null, +) { + + /** Object containing details of a file or file version. */ + fun fileDetails(): Optional = Optional.ofNullable(fileDetails) + + fun folderDetails(): Optional = Optional.ofNullable(folderDetails) + + fun isFileDetails(): Boolean = fileDetails != null + + fun isFolderDetails(): Boolean = folderDetails != null + + /** Object containing details of a file or file version. */ + fun asFileDetails(): FileDetails = fileDetails.getOrThrow("fileDetails") + + fun asFolderDetails(): FolderDetails = folderDetails.getOrThrow("folderDetails") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + fileDetails != null -> visitor.visitFileDetails(fileDetails) + folderDetails != null -> visitor.visitFolderDetails(folderDetails) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AssetListResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitFileDetails(fileDetails: FileDetails) { + fileDetails.validate() + } + + override fun visitFolderDetails(folderDetails: FolderDetails) { + folderDetails.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: FileDetails) = fileDetails.validity() + + override fun visitFolderDetails(folderDetails: FolderDetails) = + folderDetails.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AssetListResponse && + fileDetails == other.fileDetails && + folderDetails == other.folderDetails + } + + override fun hashCode(): Int = Objects.hash(fileDetails, folderDetails) + + override fun toString(): String = + when { + fileDetails != null -> "AssetListResponse{fileDetails=$fileDetails}" + folderDetails != null -> "AssetListResponse{folderDetails=$folderDetails}" + _json != null -> "AssetListResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AssetListResponse") + } + + companion object { + + /** Object containing details of a file or file version. */ + @JvmStatic + fun ofFileDetails(fileDetails: FileDetails) = AssetListResponse(fileDetails = fileDetails) + + @JvmStatic + fun ofFolderDetails(folderDetails: FolderDetails) = + AssetListResponse(folderDetails = folderDetails) + } + + /** + * 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 visitFileDetails(fileDetails: FileDetails): T + + fun visitFolderDetails(folderDetails: FolderDetails): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + AssetListResponse(fileDetails = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AssetListResponse(folderDetails = 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 -> AssetListResponse(_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(AssetListResponse::class) { + + override fun serialize( + value: AssetListResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.fileDetails != null -> generator.writeObject(value.fileDetails) + value.folderDetails != null -> generator.writeObject(value.folderDetails) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AssetListResponse") + } + } + } + + /** Object containing details of a file or file version. */ + class FileDetails + private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonValue, + 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: JsonValue = 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, + 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. */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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 [FileDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileDetails]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonValue = 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(fileDetails: FileDetails) = apply { + aiTags = fileDetails.aiTags.map { it.toMutableList() } + createdAt = fileDetails.createdAt + customCoordinates = fileDetails.customCoordinates + customMetadata = fileDetails.customMetadata + fileId = fileDetails.fileId + filePath = fileDetails.filePath + fileType = fileDetails.fileType + hasAlpha = fileDetails.hasAlpha + height = fileDetails.height + isPrivateFile = fileDetails.isPrivateFile + isPublished = fileDetails.isPublished + mime = fileDetails.mime + name = fileDetails.name + size = fileDetails.size + tags = fileDetails.tags.map { it.toMutableList() } + thumbnail = fileDetails.thumbnail + type = fileDetails.type + updatedAt = fileDetails.updatedAt + url = fileDetails.url + versionInfo = fileDetails.versionInfo + width = fileDetails.width + additionalProperties = fileDetails.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: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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: 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 } + + /** + * Date and time when the file was last updated. The date and time is in ISO8601 format. + */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [FileDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileDetails = + FileDetails( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + 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(): FileDetails = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type() + 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) + + (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) + + (if (type.asKnown().isPresent) 1 else 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 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 FileDetails && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + 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, + 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() = + "FileDetails{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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}" + } + + class FolderDetails + 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 [FolderDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderDetails]. */ + 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(folderDetails: FolderDetails) = apply { + createdAt = folderDetails.createdAt + folderId = folderDetails.folderId + folderPath = folderDetails.folderPath + name = folderDetails.name + type = folderDetails.type + updatedAt = folderDetails.updatedAt + additionalProperties = folderDetails.additionalProperties.toMutableMap() + } + + /** + * Date and time when the folder was created. The date and time is in ISO8601 format. + */ + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] 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: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [FolderDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FolderDetails = + FolderDetails( + createdAt, + folderId, + folderPath, + name, + type, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FolderDetails = 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 FolderDetails && + 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() = + "FolderDetails{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/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..06713175 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -0,0 +1,5846 @@ +// 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.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.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 + +/** + * 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(file: Path) = apply { body.file(file) } + + /** 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.ofRemovedotBg(removedotBg)`. */ + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = apply { + body.addExtension(removedotBg) + } + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { + body.addExtension(autoTagging) + } + + /** Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = apply { + body.addExtension(autoDescription) + } + + /** + * 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(file: Path) = + file( + MultipartField.builder() + .value(file.inputStream()) + .filename(file.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.ofRemovedotBg(removedotBg)`. */ + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = + addExtension(Extension.ofRemovedotBg(removedotBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** + * Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. + */ + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = + addExtension(Extension.ofAutoDescription(autoDescription)) + + /** + * 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 removedotBg: RemovedotBgExtension? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val autoDescription: AutoDescriptionExtension? = null, + private val _json: JsonValue? = null, + ) { + + fun removedotBg(): Optional = Optional.ofNullable(removedotBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun autoDescription(): Optional = + Optional.ofNullable(autoDescription) + + fun isRemovedotBg(): Boolean = removedotBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAutoDescription(): Boolean = autoDescription != null + + fun asRemovedotBg(): RemovedotBgExtension = removedotBg.getOrThrow("removedotBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAutoDescription(): AutoDescriptionExtension = + autoDescription.getOrThrow("autoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removedotBg != null -> visitor.visitRemovedotBg(removedotBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + autoDescription != null -> visitor.visitAutoDescription(autoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) { + removedotBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAutoDescription(autoDescription: AutoDescriptionExtension) { + autoDescription.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 visitRemovedotBg(removedotBg: RemovedotBgExtension) = + removedotBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAutoDescription(autoDescription: AutoDescriptionExtension) = + autoDescription.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removedotBg == other.removedotBg && + autoTagging == other.autoTagging && + autoDescription == other.autoDescription + } + + override fun hashCode(): Int = Objects.hash(removedotBg, autoTagging, autoDescription) + + override fun toString(): String = + when { + removedotBg != null -> "Extension{removedotBg=$removedotBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + autoDescription != null -> "Extension{autoDescription=$autoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic + fun ofRemovedotBg(removedotBg: RemovedotBgExtension) = + Extension(removedotBg = removedotBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAutoDescription(autoDescription: AutoDescriptionExtension) = + Extension(autoDescription = autoDescription) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of type [T]. + */ + interface Visitor { + + fun visitRemovedotBg(removedotBg: RemovedotBgExtension): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAutoDescription(autoDescription: AutoDescriptionExtension): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removedotBg = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoDescription = 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 -> Extension(_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(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removedotBg != null -> generator.writeObject(value.removedotBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.autoDescription != null -> generator.writeObject(value.autoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } + + class RemovedotBgExtension + private constructor( + private val name: MultipartField, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the background removal 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(): Name = name.value.getRequired("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 [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + /** + * 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 [RemovedotBgExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovedotBgExtension]. */ + class Builder internal constructor() { + + private var name: MultipartField? = null + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { + name = removedotBgExtension.name + options = removedotBgExtension.options + additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() + } + + /** Specifies the background removal extension. */ + 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 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 [RemovedotBgExtension]. + * + * 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(): RemovedotBgExtension = + RemovedotBgExtension( + checkRequired("name", name), + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovedotBgExtension = apply { + if (validated) { + return@apply + } + + name().validate() + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the background removal extension. */ + 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 REMOVE_BG = of("remove-bg") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + REMOVE_BG + } + + /** + * 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 { + REMOVE_BG, + /** + * 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) { + REMOVE_BG -> Value.REMOVE_BG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + REMOVE_BG -> Known.REMOVE_BG + 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() + } + + 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 RemovedotBgExtension && + 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() = + "RemovedotBgExtension{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 AutoDescriptionExtension + private constructor( + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the auto description 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(): Name = name.value.getRequired("name") + + /** + * 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 + * [AutoDescriptionExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoDescriptionExtension]. */ + class Builder internal constructor() { + + private var name: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { + name = autoDescriptionExtension.name + additionalProperties = + autoDescriptionExtension.additionalProperties.toMutableMap() + } + + /** Specifies the auto description extension. */ + 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 [AutoDescriptionExtension]. + * + * 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(): AutoDescriptionExtension = + AutoDescriptionExtension( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoDescriptionExtension = apply { + if (validated) { + return@apply + } + + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the auto description extension. */ + 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + AI_AUTO_DESCRIPTION + } + + /** + * 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 { + AI_AUTO_DESCRIPTION, + /** + * 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) { + AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION + 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 AutoDescriptionExtension && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoDescriptionExtension{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.ofSimplePostTransformation(simplePostTransformation)`. + */ + fun addPost(simplePostTransformation: Post.SimplePostTransformation) = + addPost(Post.ofSimplePostTransformation(simplePostTransformation)) + + /** Alias for calling [addPost] with `Post.ofConvertGifToVideo(convertGifToVideo)`. */ + fun addPost(convertGifToVideo: Post.ConvertGifToVideo) = + addPost(Post.ofConvertGifToVideo(convertGifToVideo)) + + /** Alias for calling [addPost] with `Post.ofGenerateAThumbnail(generateAThumbnail)`. */ + fun addPost(generateAThumbnail: Post.GenerateAThumbnail) = + addPost(Post.ofGenerateAThumbnail(generateAThumbnail)) + + /** + * Alias for calling [addPost] with + * `Post.ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming)`. + */ + fun addPost(adaptiveBitrateStreaming: Post.AdaptiveBitrateStreaming) = + addPost(Post.ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming)) + + /** + * 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 simplePostTransformation: SimplePostTransformation? = null, + private val convertGifToVideo: ConvertGifToVideo? = null, + private val generateAThumbnail: GenerateAThumbnail? = null, + private val adaptiveBitrateStreaming: AdaptiveBitrateStreaming? = null, + private val _json: JsonValue? = null, + ) { + + fun simplePostTransformation(): Optional = + Optional.ofNullable(simplePostTransformation) + + fun convertGifToVideo(): Optional = + Optional.ofNullable(convertGifToVideo) + + fun generateAThumbnail(): Optional = + Optional.ofNullable(generateAThumbnail) + + fun adaptiveBitrateStreaming(): Optional = + Optional.ofNullable(adaptiveBitrateStreaming) + + fun isSimplePostTransformation(): Boolean = simplePostTransformation != null + + fun isConvertGifToVideo(): Boolean = convertGifToVideo != null + + fun isGenerateAThumbnail(): Boolean = generateAThumbnail != null + + fun isAdaptiveBitrateStreaming(): Boolean = adaptiveBitrateStreaming != null + + fun asSimplePostTransformation(): SimplePostTransformation = + simplePostTransformation.getOrThrow("simplePostTransformation") + + fun asConvertGifToVideo(): ConvertGifToVideo = + convertGifToVideo.getOrThrow("convertGifToVideo") + + fun asGenerateAThumbnail(): GenerateAThumbnail = + generateAThumbnail.getOrThrow("generateAThumbnail") + + fun asAdaptiveBitrateStreaming(): AdaptiveBitrateStreaming = + adaptiveBitrateStreaming.getOrThrow("adaptiveBitrateStreaming") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + simplePostTransformation != null -> + visitor.visitSimplePostTransformation(simplePostTransformation) + convertGifToVideo != null -> visitor.visitConvertGifToVideo(convertGifToVideo) + generateAThumbnail != null -> + visitor.visitGenerateAThumbnail(generateAThumbnail) + adaptiveBitrateStreaming != null -> + visitor.visitAdaptiveBitrateStreaming(adaptiveBitrateStreaming) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Post = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSimplePostTransformation( + simplePostTransformation: SimplePostTransformation + ) { + simplePostTransformation.validate() + } + + override fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) { + convertGifToVideo.validate() + } + + override fun visitGenerateAThumbnail( + generateAThumbnail: GenerateAThumbnail + ) { + generateAThumbnail.validate() + } + + override fun visitAdaptiveBitrateStreaming( + adaptiveBitrateStreaming: AdaptiveBitrateStreaming + ) { + adaptiveBitrateStreaming.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 visitSimplePostTransformation( + simplePostTransformation: SimplePostTransformation + ) = simplePostTransformation.validity() + + override fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) = + convertGifToVideo.validity() + + override fun visitGenerateAThumbnail( + generateAThumbnail: GenerateAThumbnail + ) = generateAThumbnail.validity() + + override fun visitAdaptiveBitrateStreaming( + adaptiveBitrateStreaming: AdaptiveBitrateStreaming + ) = adaptiveBitrateStreaming.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Post && + simplePostTransformation == other.simplePostTransformation && + convertGifToVideo == other.convertGifToVideo && + generateAThumbnail == other.generateAThumbnail && + adaptiveBitrateStreaming == other.adaptiveBitrateStreaming + } + + override fun hashCode(): Int = + Objects.hash( + simplePostTransformation, + convertGifToVideo, + generateAThumbnail, + adaptiveBitrateStreaming, + ) + + override fun toString(): String = + when { + simplePostTransformation != null -> + "Post{simplePostTransformation=$simplePostTransformation}" + convertGifToVideo != null -> "Post{convertGifToVideo=$convertGifToVideo}" + generateAThumbnail != null -> "Post{generateAThumbnail=$generateAThumbnail}" + adaptiveBitrateStreaming != null -> + "Post{adaptiveBitrateStreaming=$adaptiveBitrateStreaming}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } + + companion object { + + @JvmStatic + fun ofSimplePostTransformation(simplePostTransformation: SimplePostTransformation) = + Post(simplePostTransformation = simplePostTransformation) + + @JvmStatic + fun ofConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) = + Post(convertGifToVideo = convertGifToVideo) + + @JvmStatic + fun ofGenerateAThumbnail(generateAThumbnail: GenerateAThumbnail) = + Post(generateAThumbnail = generateAThumbnail) + + @JvmStatic + fun ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming: AdaptiveBitrateStreaming) = + Post(adaptiveBitrateStreaming = adaptiveBitrateStreaming) + } + + /** + * An interface that defines how to map each variant of [Post] to a value of type [T]. + */ + interface Visitor { + + fun visitSimplePostTransformation( + simplePostTransformation: SimplePostTransformation + ): T + + fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo): T + + fun visitGenerateAThumbnail(generateAThumbnail: GenerateAThumbnail): T + + fun visitAdaptiveBitrateStreaming( + adaptiveBitrateStreaming: AdaptiveBitrateStreaming + ): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Post(simplePostTransformation = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Post(convertGifToVideo = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Post(generateAThumbnail = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Post(adaptiveBitrateStreaming = 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 -> Post(_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(Post::class) { + + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.simplePostTransformation != null -> + generator.writeObject(value.simplePostTransformation) + value.convertGifToVideo != null -> + generator.writeObject(value.convertGifToVideo) + value.generateAThumbnail != null -> + generator.writeObject(value.generateAThumbnail) + value.adaptiveBitrateStreaming != null -> + generator.writeObject(value.adaptiveBitrateStreaming) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } + } + } + + class SimplePostTransformation + private constructor( + private val type: MultipartField, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Transformation 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 type(): Type = type.value.getRequired("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 [type]. + * + * Unlike [type], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type + + /** + * 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 + * [SimplePostTransformation]. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SimplePostTransformation]. */ + class Builder internal constructor() { + + private var type: MultipartField? = null + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(simplePostTransformation: SimplePostTransformation) = apply { + type = simplePostTransformation.type + value = simplePostTransformation.value + additionalProperties = + simplePostTransformation.additionalProperties.toMutableMap() + } + + /** Transformation type. */ + fun type(type: Type) = type(MultipartField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary multipart 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: MultipartField) = 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 [SimplePostTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SimplePostTransformation = + SimplePostTransformation( + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SimplePostTransformation = apply { + if (validated) { + return@apply + } + + type().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Transformation type. */ + 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") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TRANSFORMATION + } + + /** + * 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, + /** + * 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 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + 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 SimplePostTransformation && + 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() = + "SimplePostTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class ConvertGifToVideo + private constructor( + private val type: MultipartField, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Converts an animated GIF into an MP4. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun type(): Type = type.value.getRequired("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 [type]. + * + * Unlike [type], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type + + /** + * 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 + * [ConvertGifToVideo]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConvertGifToVideo]. */ + class Builder internal constructor() { + + private var type: MultipartField? = null + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(convertGifToVideo: ConvertGifToVideo) = apply { + type = convertGifToVideo.type + value = convertGifToVideo.value + additionalProperties = convertGifToVideo.additionalProperties.toMutableMap() + } + + /** Converts an animated GIF into an MP4. */ + fun type(type: Type) = type(MultipartField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary multipart 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: MultipartField) = 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 [ConvertGifToVideo]. + * + * 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(): ConvertGifToVideo = + ConvertGifToVideo( + checkRequired("type", type), + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConvertGifToVideo = apply { + if (validated) { + return@apply + } + + type().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Converts an animated GIF into an MP4. */ + 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 GIF_TO_VIDEO = of("gif-to-video") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GIF_TO_VIDEO + } + + /** + * 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 { + GIF_TO_VIDEO, + /** + * 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) { + GIF_TO_VIDEO -> Value.GIF_TO_VIDEO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GIF_TO_VIDEO -> Known.GIF_TO_VIDEO + 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 ConvertGifToVideo && + 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() = + "ConvertGifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class GenerateAThumbnail + private constructor( + private val type: MultipartField, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Generates a thumbnail 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 type(): Type = type.value.getRequired("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 [type]. + * + * Unlike [type], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type + + /** + * 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 + * [GenerateAThumbnail]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GenerateAThumbnail]. */ + class Builder internal constructor() { + + private var type: MultipartField? = null + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(generateAThumbnail: GenerateAThumbnail) = apply { + type = generateAThumbnail.type + value = generateAThumbnail.value + additionalProperties = + generateAThumbnail.additionalProperties.toMutableMap() + } + + /** Generates a thumbnail image. */ + fun type(type: Type) = type(MultipartField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary multipart 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: MultipartField) = 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 [GenerateAThumbnail]. + * + * 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(): GenerateAThumbnail = + GenerateAThumbnail( + checkRequired("type", type), + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GenerateAThumbnail = apply { + if (validated) { + return@apply + } + + type().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Generates a thumbnail image. */ + 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 THUMBNAIL = of("thumbnail") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + 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 { + 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) { + 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) { + 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() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GenerateAThumbnail && + 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() = + "GenerateAThumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class AdaptiveBitrateStreaming + private constructor( + private val protocol: MultipartField, + private val type: MultipartField, + 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. + * + * @throws ImageKitInvalidDataException if 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.value.getRequired("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 [type]. + * + * Unlike [type], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type + + /** + * 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 + * [AdaptiveBitrateStreaming]. + * + * The following fields are required: + * ```java + * .protocol() + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdaptiveBitrateStreaming]. */ + class Builder internal constructor() { + + private var protocol: MultipartField? = null + private var type: MultipartField? = null + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adaptiveBitrateStreaming: AdaptiveBitrateStreaming) = apply { + protocol = adaptiveBitrateStreaming.protocol + type = adaptiveBitrateStreaming.type + value = adaptiveBitrateStreaming.value + additionalProperties = + adaptiveBitrateStreaming.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 + } + + /** Adaptive Bitrate Streaming (ABS) setup. */ + fun type(type: Type) = type(MultipartField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary multipart 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: MultipartField) = 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 [AdaptiveBitrateStreaming]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .protocol() + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AdaptiveBitrateStreaming = + AdaptiveBitrateStreaming( + checkRequired("protocol", protocol), + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AdaptiveBitrateStreaming = apply { + if (validated) { + return@apply + } + + protocol().validate() + type().validate() + 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() + } + + /** Adaptive Bitrate Streaming (ABS) setup. */ + 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 ABS = of("abs") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ABS + } + + /** + * 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 { + ABS, + /** + * 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) { + ABS -> Value.ABS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + ABS -> Known.ABS + 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 AdaptiveBitrateStreaming && + 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() = + "AdaptiveBitrateStreaming{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..f4565a2d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -0,0 +1,5880 @@ +// 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 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: JsonValue, + 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: JsonValue = 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, + 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. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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: JsonValue = 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 + 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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, + 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() + 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) + + (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}" + } + + /** + * 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 awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @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(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 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 [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 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 { + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + 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( + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + 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 = + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + 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 && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the + * upload API response. + */ + 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}" + } + + /** 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 && + 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, + 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, 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/purge/PurgeExecuteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt index afca8f49..1fe6f16e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.purge +package com.imagekit.api.models.cache.invalidation import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,7 +22,7 @@ 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 PurgeExecuteParams +class InvalidationCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -57,7 +57,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [PurgeExecuteParams]. + * Returns a mutable builder for constructing an instance of [InvalidationCreateParams]. * * The following fields are required: * ```java @@ -67,7 +67,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PurgeExecuteParams]. */ + /** A builder for [InvalidationCreateParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -75,10 +75,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(purgeExecuteParams: PurgeExecuteParams) = apply { - body = purgeExecuteParams.body.toBuilder() - additionalHeaders = purgeExecuteParams.additionalHeaders.toBuilder() - additionalQueryParams = purgeExecuteParams.additionalQueryParams.toBuilder() + internal fun from(invalidationCreateParams: InvalidationCreateParams) = apply { + body = invalidationCreateParams.body.toBuilder() + additionalHeaders = invalidationCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = invalidationCreateParams.additionalQueryParams.toBuilder() } /** @@ -219,7 +219,7 @@ private constructor( } /** - * Returns an immutable instance of [PurgeExecuteParams]. + * Returns an immutable instance of [InvalidationCreateParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -230,8 +230,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PurgeExecuteParams = - PurgeExecuteParams( + fun build(): InvalidationCreateParams = + InvalidationCreateParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -402,7 +402,7 @@ private constructor( return true } - return other is PurgeExecuteParams && + return other is InvalidationCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -411,5 +411,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "PurgeExecuteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InvalidationCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt index e38f0dc4..51e74c57 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.purge +package com.imagekit.api.models.cache.invalidation import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -15,7 +15,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional -class PurgeExecuteResponse +class InvalidationCreateResponse private constructor( private val requestId: JsonField, private val additionalProperties: MutableMap, @@ -56,20 +56,22 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PurgeExecuteResponse]. */ + /** + * Returns a mutable builder for constructing an instance of [InvalidationCreateResponse]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [PurgeExecuteResponse]. */ + /** A builder for [InvalidationCreateResponse]. */ class Builder internal constructor() { private var requestId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(purgeExecuteResponse: PurgeExecuteResponse) = apply { - requestId = purgeExecuteResponse.requestId - additionalProperties = purgeExecuteResponse.additionalProperties.toMutableMap() + internal fun from(invalidationCreateResponse: InvalidationCreateResponse) = apply { + requestId = invalidationCreateResponse.requestId + additionalProperties = invalidationCreateResponse.additionalProperties.toMutableMap() } /** @@ -107,17 +109,17 @@ private constructor( } /** - * Returns an immutable instance of [PurgeExecuteResponse]. + * Returns an immutable instance of [InvalidationCreateResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): PurgeExecuteResponse = - PurgeExecuteResponse(requestId, additionalProperties.toMutableMap()) + fun build(): InvalidationCreateResponse = + InvalidationCreateResponse(requestId, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): PurgeExecuteResponse = apply { + fun validate(): InvalidationCreateResponse = apply { if (validated) { return@apply } @@ -146,7 +148,7 @@ private constructor( return true } - return other is PurgeExecuteResponse && + return other is InvalidationCreateResponse && requestId == other.requestId && additionalProperties == other.additionalProperties } @@ -156,5 +158,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PurgeExecuteResponse{requestId=$requestId, additionalProperties=$additionalProperties}" + "InvalidationCreateResponse{requestId=$requestId, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt index 16dc7bf7..38accc77 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.purge +package com.imagekit.api.models.cache.invalidation import com.imagekit.api.core.Params import com.imagekit.api.core.http.Headers @@ -10,7 +10,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** This API returns the status of a purge cache request. */ -class PurgeStatusParams +class InvalidationGetParams private constructor( private val requestId: String?, private val additionalHeaders: Headers, @@ -29,13 +29,13 @@ private constructor( companion object { - @JvmStatic fun none(): PurgeStatusParams = builder().build() + @JvmStatic fun none(): InvalidationGetParams = builder().build() - /** Returns a mutable builder for constructing an instance of [PurgeStatusParams]. */ + /** Returns a mutable builder for constructing an instance of [InvalidationGetParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [PurgeStatusParams]. */ + /** A builder for [InvalidationGetParams]. */ class Builder internal constructor() { private var requestId: String? = null @@ -43,10 +43,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(purgeStatusParams: PurgeStatusParams) = apply { - requestId = purgeStatusParams.requestId - additionalHeaders = purgeStatusParams.additionalHeaders.toBuilder() - additionalQueryParams = purgeStatusParams.additionalQueryParams.toBuilder() + 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 } @@ -153,12 +153,16 @@ private constructor( } /** - * Returns an immutable instance of [PurgeStatusParams]. + * Returns an immutable instance of [InvalidationGetParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): PurgeStatusParams = - PurgeStatusParams(requestId, additionalHeaders.build(), additionalQueryParams.build()) + fun build(): InvalidationGetParams = + InvalidationGetParams( + requestId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) } fun _pathParam(index: Int): String = @@ -176,7 +180,7 @@ private constructor( return true } - return other is PurgeStatusParams && + return other is InvalidationGetParams && requestId == other.requestId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -185,5 +189,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(requestId, additionalHeaders, additionalQueryParams) override fun toString() = - "PurgeStatusParams{requestId=$requestId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InvalidationGetParams{requestId=$requestId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt index 515e3f10..74befb58 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.purge +package com.imagekit.api.models.cache.invalidation import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -17,7 +17,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class PurgeStatusResponse +class InvalidationGetResponse private constructor( private val status: JsonField, private val additionalProperties: MutableMap, @@ -57,20 +57,20 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PurgeStatusResponse]. */ + /** Returns a mutable builder for constructing an instance of [InvalidationGetResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [PurgeStatusResponse]. */ + /** A builder for [InvalidationGetResponse]. */ class Builder internal constructor() { private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(purgeStatusResponse: PurgeStatusResponse) = apply { - status = purgeStatusResponse.status - additionalProperties = purgeStatusResponse.additionalProperties.toMutableMap() + internal fun from(invalidationGetResponse: InvalidationGetResponse) = apply { + status = invalidationGetResponse.status + additionalProperties = invalidationGetResponse.additionalProperties.toMutableMap() } /** Status of the purge request. */ @@ -104,17 +104,17 @@ private constructor( } /** - * Returns an immutable instance of [PurgeStatusResponse]. + * Returns an immutable instance of [InvalidationGetResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): PurgeStatusResponse = - PurgeStatusResponse(status, additionalProperties.toMutableMap()) + fun build(): InvalidationGetResponse = + InvalidationGetResponse(status, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): PurgeStatusResponse = apply { + fun validate(): InvalidationGetResponse = apply { if (validated) { return@apply } @@ -271,7 +271,7 @@ private constructor( return true } - return other is PurgeStatusResponse && + return other is InvalidationGetResponse && status == other.status && additionalProperties == other.additionalProperties } @@ -281,5 +281,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PurgeStatusResponse{status=$status, additionalProperties=$additionalProperties}" + "InvalidationGetResponse{status=$status, 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 index 9d950bf8..cdc7d3fb 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 @@ -1101,7 +1101,7 @@ private constructor( @JvmField val TEXT = of("Text") - @JvmField val TEXT_AREA = of("TextArea") + @JvmField val TEXTAREA = of("Textarea") @JvmField val NUMBER = of("Number") @@ -1119,7 +1119,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { TEXT, - TEXT_AREA, + TEXTAREA, NUMBER, DATE, BOOLEAN, @@ -1138,7 +1138,7 @@ private constructor( */ enum class Value { TEXT, - TEXT_AREA, + TEXTAREA, NUMBER, DATE, BOOLEAN, @@ -1158,7 +1158,7 @@ private constructor( fun value(): Value = when (this) { TEXT -> Value.TEXT - TEXT_AREA -> Value.TEXT_AREA + TEXTAREA -> Value.TEXTAREA NUMBER -> Value.NUMBER DATE -> Value.DATE BOOLEAN -> Value.BOOLEAN @@ -1179,7 +1179,7 @@ private constructor( fun known(): Known = when (this) { TEXT -> Known.TEXT - TEXT_AREA -> Known.TEXT_AREA + TEXTAREA -> Known.TEXTAREA NUMBER -> Known.NUMBER DATE -> Known.DATE BOOLEAN -> Known.BOOLEAN diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt index 62d1b09c..0b38db4f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt @@ -797,7 +797,7 @@ private constructor( @JvmField val TEXT = of("Text") - @JvmField val TEXT_AREA = of("TextArea") + @JvmField val TEXTAREA = of("Textarea") @JvmField val NUMBER = of("Number") @@ -815,7 +815,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { TEXT, - TEXT_AREA, + TEXTAREA, NUMBER, DATE, BOOLEAN, @@ -834,7 +834,7 @@ private constructor( */ enum class Value { TEXT, - TEXT_AREA, + TEXTAREA, NUMBER, DATE, BOOLEAN, @@ -854,7 +854,7 @@ private constructor( fun value(): Value = when (this) { TEXT -> Value.TEXT - TEXT_AREA -> Value.TEXT_AREA + TEXTAREA -> Value.TEXTAREA NUMBER -> Value.NUMBER DATE -> Value.DATE BOOLEAN -> Value.BOOLEAN @@ -875,7 +875,7 @@ private constructor( fun known(): Known = when (this) { TEXT -> Known.TEXT - TEXT_AREA -> Known.TEXT_AREA + TEXTAREA -> Known.TEXTAREA NUMBER -> Known.NUMBER DATE -> Known.DATE BOOLEAN -> Known.BOOLEAN 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 545434fd..8ae404f5 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 @@ -20,10 +20,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** - * Set it to `true` to include deleted field objects in the API response. Default value is - * `false`. - */ + /** 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. */ @@ -59,10 +56,7 @@ private constructor( additionalQueryParams = customMetadataFieldListParams.additionalQueryParams.toBuilder() } - /** - * Set it to `true` to include deleted field objects in the API response. Default value is - * `false`. - */ + /** Set it to `true` to include deleted field objects in the API response. */ fun includeDeleted(includeDeleted: Boolean?) = apply { this.includeDeleted = includeDeleted } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt index 85ed99cb..8e4fd30f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt @@ -797,7 +797,7 @@ private constructor( @JvmField val TEXT = of("Text") - @JvmField val TEXT_AREA = of("TextArea") + @JvmField val TEXTAREA = of("Textarea") @JvmField val NUMBER = of("Number") @@ -815,7 +815,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { TEXT, - TEXT_AREA, + TEXTAREA, NUMBER, DATE, BOOLEAN, @@ -834,7 +834,7 @@ private constructor( */ enum class Value { TEXT, - TEXT_AREA, + TEXTAREA, NUMBER, DATE, BOOLEAN, @@ -854,7 +854,7 @@ private constructor( fun value(): Value = when (this) { TEXT -> Value.TEXT - TEXT_AREA -> Value.TEXT_AREA + TEXTAREA -> Value.TEXTAREA NUMBER -> Value.NUMBER DATE -> Value.DATE BOOLEAN -> Value.BOOLEAN @@ -875,7 +875,7 @@ private constructor( fun known(): Known = when (this) { TEXT -> Known.TEXT - TEXT_AREA -> Known.TEXT_AREA + TEXTAREA -> Known.TEXTAREA NUMBER -> Known.NUMBER DATE -> Known.DATE BOOLEAN -> Known.BOOLEAN diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt index 934e3321..29d241ff 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt @@ -797,7 +797,7 @@ private constructor( @JvmField val TEXT = of("Text") - @JvmField val TEXT_AREA = of("TextArea") + @JvmField val TEXTAREA = of("Textarea") @JvmField val NUMBER = of("Number") @@ -815,7 +815,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { TEXT, - TEXT_AREA, + TEXTAREA, NUMBER, DATE, BOOLEAN, @@ -834,7 +834,7 @@ private constructor( */ enum class Value { TEXT, - TEXT_AREA, + TEXTAREA, NUMBER, DATE, BOOLEAN, @@ -854,7 +854,7 @@ private constructor( fun value(): Value = when (this) { TEXT -> Value.TEXT - TEXT_AREA -> Value.TEXT_AREA + TEXTAREA -> Value.TEXTAREA NUMBER -> Value.NUMBER DATE -> Value.DATE BOOLEAN -> Value.BOOLEAN @@ -875,7 +875,7 @@ private constructor( fun known(): Known = when (this) { TEXT -> Known.TEXT - TEXT_AREA -> Known.TEXT_AREA + TEXTAREA -> Known.TEXTAREA NUMBER -> Known.NUMBER DATE -> Known.DATE BOOLEAN -> Known.BOOLEAN diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifDetails.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifDetails.kt deleted file mode 100644 index 7d10aeb9..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifDetails.kt +++ /dev/null @@ -1,1142 +0,0 @@ -// 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 - -/** Object containing Exif details. */ -class ExifDetails -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 [ExifDetails]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExifDetails]. */ - 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(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) = 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 [ExifDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ExifDetails = - ExifDetails( - 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(): ExifDetails = 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 ExifDetails && - 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() = - "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}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifImage.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifImage.kt deleted file mode 100644 index 40bef130..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/ExifImage.kt +++ /dev/null @@ -1,522 +0,0 @@ -// 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 - -/** Object containing EXIF image information. */ -class ExifImage -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 [ExifImage]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExifImage]. */ - 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(exifImage: ExifImage) = apply { - exifOffset = exifImage.exifOffset - gpsInfo = exifImage.gpsInfo - make = exifImage.make - model = exifImage.model - modifyDate = exifImage.modifyDate - orientation = exifImage.orientation - resolutionUnit = exifImage.resolutionUnit - software = exifImage.software - xResolution = exifImage.xResolution - yCbCrPositioning = exifImage.yCbCrPositioning - yResolution = exifImage.yResolution - additionalProperties = exifImage.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 [ExifImage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ExifImage = - ExifImage( - exifOffset, - gpsInfo, - make, - model, - modifyDate, - orientation, - resolutionUnit, - software, - xResolution, - yCbCrPositioning, - yResolution, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ExifImage = 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 ExifImage && - 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() = - "ExifImage{exifOffset=$exifOffset, gpsInfo=$gpsInfo, make=$make, model=$model, modifyDate=$modifyDate, orientation=$orientation, resolutionUnit=$resolutionUnit, software=$software, xResolution=$xResolution, yCbCrPositioning=$yCbCrPositioning, yResolution=$yResolution, additionalProperties=$additionalProperties}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt index e95066a3..e5a88219 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.details +package com.imagekit.api.models.files import com.imagekit.api.core.Params import com.imagekit.api.core.http.Headers @@ -10,7 +10,7 @@ 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 DetailRetrieveParams +class FileGetParams private constructor( private val fileId: String?, private val additionalHeaders: Headers, @@ -29,13 +29,13 @@ private constructor( companion object { - @JvmStatic fun none(): DetailRetrieveParams = builder().build() + @JvmStatic fun none(): FileGetParams = builder().build() - /** Returns a mutable builder for constructing an instance of [DetailRetrieveParams]. */ + /** Returns a mutable builder for constructing an instance of [FileGetParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [DetailRetrieveParams]. */ + /** A builder for [FileGetParams]. */ class Builder internal constructor() { private var fileId: String? = null @@ -43,10 +43,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(detailRetrieveParams: DetailRetrieveParams) = apply { - fileId = detailRetrieveParams.fileId - additionalHeaders = detailRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = detailRetrieveParams.additionalQueryParams.toBuilder() + 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 } @@ -153,12 +153,12 @@ private constructor( } /** - * Returns an immutable instance of [DetailRetrieveParams]. + * Returns an immutable instance of [FileGetParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): DetailRetrieveParams = - DetailRetrieveParams(fileId, additionalHeaders.build(), additionalQueryParams.build()) + fun build(): FileGetParams = + FileGetParams(fileId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = @@ -176,7 +176,7 @@ private constructor( return true } - return other is DetailRetrieveParams && + return other is FileGetParams && fileId == other.fileId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -185,5 +185,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(fileId, additionalHeaders, additionalQueryParams) override fun toString() = - "DetailRetrieveParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileGetParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt index 83cb3a96..7fac5db3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt @@ -19,7 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Object containing details of a file or file version. */ -class FileListResponse +class FileGetResponse private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, @@ -434,11 +434,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [FileListResponse]. */ + /** Returns a mutable builder for constructing an instance of [FileGetResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [FileListResponse]. */ + /** A builder for [FileGetResponse]. */ class Builder internal constructor() { private var aiTags: JsonField>? = null @@ -465,29 +465,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileListResponse: FileListResponse) = apply { - aiTags = fileListResponse.aiTags.map { it.toMutableList() } - createdAt = fileListResponse.createdAt - customCoordinates = fileListResponse.customCoordinates - customMetadata = fileListResponse.customMetadata - fileId = fileListResponse.fileId - filePath = fileListResponse.filePath - fileType = fileListResponse.fileType - hasAlpha = fileListResponse.hasAlpha - height = fileListResponse.height - isPrivateFile = fileListResponse.isPrivateFile - isPublished = fileListResponse.isPublished - mime = fileListResponse.mime - name = fileListResponse.name - size = fileListResponse.size - tags = fileListResponse.tags.map { it.toMutableList() } - thumbnail = fileListResponse.thumbnail - type = fileListResponse.type - updatedAt = fileListResponse.updatedAt - url = fileListResponse.url - versionInfo = fileListResponse.versionInfo - width = fileListResponse.width - additionalProperties = fileListResponse.additionalProperties.toMutableMap() + internal fun from(fileGetResponse: FileGetResponse) = apply { + aiTags = fileGetResponse.aiTags.map { it.toMutableList() } + createdAt = fileGetResponse.createdAt + customCoordinates = fileGetResponse.customCoordinates + customMetadata = fileGetResponse.customMetadata + fileId = fileGetResponse.fileId + filePath = fileGetResponse.filePath + fileType = fileGetResponse.fileType + hasAlpha = fileGetResponse.hasAlpha + height = fileGetResponse.height + isPrivateFile = fileGetResponse.isPrivateFile + isPublished = fileGetResponse.isPublished + mime = fileGetResponse.mime + name = fileGetResponse.name + size = fileGetResponse.size + tags = fileGetResponse.tags.map { it.toMutableList() } + thumbnail = fileGetResponse.thumbnail + type = fileGetResponse.type + updatedAt = fileGetResponse.updatedAt + url = fileGetResponse.url + versionInfo = fileGetResponse.versionInfo + width = fileGetResponse.width + additionalProperties = fileGetResponse.additionalProperties.toMutableMap() } /** An array of tags assigned to the file by auto tagging. */ @@ -797,12 +797,12 @@ private constructor( } /** - * Returns an immutable instance of [FileListResponse]. + * Returns an immutable instance of [FileGetResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): FileListResponse = - FileListResponse( + fun build(): FileGetResponse = + FileGetResponse( (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, createdAt, customCoordinates, @@ -830,7 +830,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileListResponse = apply { + fun validate(): FileGetResponse = apply { if (validated) { return@apply } @@ -1294,7 +1294,7 @@ private constructor( return true } - return other is FileListResponse && + return other is FileGetResponse && aiTags == other.aiTags && createdAt == other.createdAt && customCoordinates == other.customCoordinates && @@ -1349,5 +1349,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileListResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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}" + "FileGetResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/FileListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListParams.kt deleted file mode 100644 index 74812123..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileListParams.kt +++ /dev/null @@ -1,553 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files - -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 FileListParams -private constructor( - private val fileType: String?, - private val limit: String?, - private val path: String?, - private val searchQuery: String?, - private val skip: String?, - private val sort: String?, - private val type: Type?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * Type of files to include in the result set. Accepts three values: - * - * `all` - include all types of files in the result set. `image` - only search in image type - * files. `non-image` - only search in files that are not images, e.g., JS or CSS or video - * files. - * - * Default value - `all` - */ - fun fileType(): Optional = Optional.ofNullable(fileType) - - /** - * The maximum number of results to return in response: - * - * Minimum value - 1 - * - * Maximum value - 1000 - * - * Default value - 1000 - */ - 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. - */ - 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: - * - * Minimum value - 0 - * - * Default value - 0 - */ - fun skip(): Optional = Optional.ofNullable(skip) - - /** - * You can sort based on the following fields: - * 1. name - `ASC_NAME` or `DESC_NAME` - * 2. createdAt - `ASC_CREATED` or `DESC_CREATED` - * 3. updatedAt - `ASC_UPDATED` or `DESC_UPDATED` - * 4. height - `ASC_HEIGHT` or `DESC_HEIGHT` - * 5. width - `ASC_WIDTH` or `DESC_WIDTH` - * 6. size - `ASC_SIZE` or `DESC_SIZE` - * - * Default value - `ASC_CREATED` - */ - fun sort(): Optional = Optional.ofNullable(sort) - - /** - * Limit search to one of `file`, `file-version`, or `folder`. Pass `all` to include `files` and - * `folders` in search results (`file-version` will not be included in this case). - * - * Default value - `file` - */ - 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(): FileListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [FileListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileListParams]. */ - class Builder internal constructor() { - - private var fileType: String? = null - private var limit: String? = null - private var path: String? = null - private var searchQuery: String? = null - private var skip: String? = null - private var sort: String? = null - private var type: Type? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(fileListParams: FileListParams) = apply { - fileType = fileListParams.fileType - limit = fileListParams.limit - path = fileListParams.path - searchQuery = fileListParams.searchQuery - skip = fileListParams.skip - sort = fileListParams.sort - type = fileListParams.type - additionalHeaders = fileListParams.additionalHeaders.toBuilder() - additionalQueryParams = fileListParams.additionalQueryParams.toBuilder() - } - - /** - * Type of files to include in the result set. Accepts three values: - * - * `all` - include all types of files in the result set. `image` - only search in image type - * files. `non-image` - only search in files that are not images, e.g., JS or CSS or video - * files. - * - * Default value - `all` - */ - fun fileType(fileType: String?) = 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: - * - * Minimum value - 1 - * - * Maximum value - 1000 - * - * Default value - 1000 - */ - fun limit(limit: String?) = apply { this.limit = limit } - - /** 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. - */ - 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: - * - * Minimum value - 0 - * - * Default value - 0 - */ - fun skip(skip: String?) = apply { this.skip = skip } - - /** Alias for calling [Builder.skip] with `skip.orElse(null)`. */ - fun skip(skip: Optional) = skip(skip.getOrNull()) - - /** - * You can sort based on the following fields: - * 1. name - `ASC_NAME` or `DESC_NAME` - * 2. createdAt - `ASC_CREATED` or `DESC_CREATED` - * 3. updatedAt - `ASC_UPDATED` or `DESC_UPDATED` - * 4. height - `ASC_HEIGHT` or `DESC_HEIGHT` - * 5. width - `ASC_WIDTH` or `DESC_WIDTH` - * 6. size - `ASC_SIZE` or `DESC_SIZE` - * - * Default value - `ASC_CREATED` - */ - fun sort(sort: String?) = apply { this.sort = sort } - - /** Alias for calling [Builder.sort] with `sort.orElse(null)`. */ - fun sort(sort: Optional) = sort(sort.getOrNull()) - - /** - * Limit search to one of `file`, `file-version`, or `folder`. Pass `all` to include `files` - * and `folders` in search results (`file-version` will not be included in this case). - * - * Default value - `file` - */ - 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 [FileListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FileListParams = - FileListParams( - 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) } - limit?.let { put("limit", it) } - path?.let { put("path", it) } - searchQuery?.let { put("searchQuery", it) } - skip?.let { put("skip", it) } - sort?.let { put("sort", it) } - type?.let { put("type", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - /** - * Limit search to one of `file`, `file-version`, or `folder`. Pass `all` to include `files` and - * `folders` in search results (`file-version` will not be included in this case). - * - * Default value - `file` - */ - 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 FileListParams && - 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() = - "FileListParams{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/files/details/DetailUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt index 240f2ebd..3e40a9a8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.details +package com.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -39,7 +39,7 @@ import kotlin.jvm.optionals.getOrNull * `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` and * apply extensions using this API. */ -class DetailUpdateParams +class FileUpdateParams private constructor( private val fileId: String?, private val body: Body?, @@ -61,13 +61,13 @@ private constructor( companion object { - @JvmStatic fun none(): DetailUpdateParams = builder().build() + @JvmStatic fun none(): FileUpdateParams = builder().build() - /** Returns a mutable builder for constructing an instance of [DetailUpdateParams]. */ + /** Returns a mutable builder for constructing an instance of [FileUpdateParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [DetailUpdateParams]. */ + /** A builder for [FileUpdateParams]. */ class Builder internal constructor() { private var fileId: String? = null @@ -76,11 +76,11 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(detailUpdateParams: DetailUpdateParams) = apply { - fileId = detailUpdateParams.fileId - body = detailUpdateParams.body - additionalHeaders = detailUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = detailUpdateParams.additionalQueryParams.toBuilder() + internal fun from(fileUpdateParams: FileUpdateParams) = apply { + fileId = fileUpdateParams.fileId + body = fileUpdateParams.body + additionalHeaders = fileUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = fileUpdateParams.additionalQueryParams.toBuilder() } fun fileId(fileId: String?) = apply { this.fileId = fileId } @@ -202,17 +202,12 @@ private constructor( } /** - * Returns an immutable instance of [DetailUpdateParams]. + * Returns an immutable instance of [FileUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): DetailUpdateParams = - DetailUpdateParams( - fileId, - body, - additionalHeaders.build(), - additionalQueryParams.build(), - ) + fun build(): FileUpdateParams = + FileUpdateParams(fileId, body, additionalHeaders.build(), additionalQueryParams.build()) } fun _body(): Optional = Optional.ofNullable(body) @@ -419,6 +414,7 @@ private constructor( private constructor( private val customCoordinates: JsonField, private val customMetadata: JsonValue, + private val description: JsonField, private val extensions: JsonField>, private val removeAiTags: JsonField, private val tags: JsonField>, @@ -434,6 +430,9 @@ private constructor( @JsonProperty("customMetadata") @ExcludeMissing customMetadata: JsonValue = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), @JsonProperty("extensions") @ExcludeMissing extensions: JsonField> = JsonMissing.of(), @@ -449,6 +448,7 @@ private constructor( ) : this( customCoordinates, customMetadata, + description, extensions, removeAiTags, tags, @@ -475,6 +475,14 @@ private constructor( @ExcludeMissing fun _customMetadata(): JsonValue = 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. @@ -528,6 +536,16 @@ private constructor( @ExcludeMissing fun _customCoordinates(): JsonField = customCoordinates + /** + * 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]. * @@ -590,6 +608,7 @@ private constructor( private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonValue = JsonMissing.of() + private var description: JsonField = JsonMissing.of() private var extensions: JsonField>? = null private var removeAiTags: JsonField = JsonMissing.of() private var tags: JsonField>? = null @@ -600,6 +619,7 @@ private constructor( 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() } @@ -641,6 +661,20 @@ private constructor( 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. @@ -678,6 +712,13 @@ private constructor( fun addExtension(autoTagging: Extension.AutoTaggingExtension) = addExtension(Extension.ofAutoTagging(autoTagging)) + /** + * Alias for calling [addExtension] with + * `Extension.ofAutoDescription(autoDescription)`. + */ + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = + addExtension(Extension.ofAutoDescription(autoDescription)) + /** * An array of AITags associated with the file that you want to remove, e.g. * `["car", "vehicle", "motorsports"]`. @@ -794,6 +835,7 @@ private constructor( UpdateFileDetails( customCoordinates, customMetadata, + description, (extensions ?: JsonMissing.of()).map { it.toImmutable() }, removeAiTags, (tags ?: JsonMissing.of()).map { it.toImmutable() }, @@ -810,6 +852,7 @@ private constructor( } customCoordinates() + description() extensions().ifPresent { it.forEach { it.validate() } } removeAiTags().ifPresent { it.validate() } tags() @@ -834,6 +877,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (customCoordinates.asKnown().isPresent) 1 else 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) + @@ -845,6 +889,7 @@ private constructor( private constructor( private val removedotBg: RemovedotBgExtension? = null, private val autoTagging: AutoTaggingExtension? = null, + private val autoDescription: AutoDescriptionExtension? = null, private val _json: JsonValue? = null, ) { @@ -852,20 +897,29 @@ private constructor( fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + fun autoDescription(): Optional = + Optional.ofNullable(autoDescription) + fun isRemovedotBg(): Boolean = removedotBg != null fun isAutoTagging(): Boolean = autoTagging != null + fun isAutoDescription(): Boolean = autoDescription != null + fun asRemovedotBg(): RemovedotBgExtension = removedotBg.getOrThrow("removedotBg") fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + fun asAutoDescription(): AutoDescriptionExtension = + autoDescription.getOrThrow("autoDescription") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { removedotBg != null -> visitor.visitRemovedotBg(removedotBg) autoTagging != null -> visitor.visitAutoTagging(autoTagging) + autoDescription != null -> visitor.visitAutoDescription(autoDescription) else -> visitor.unknown(_json) } @@ -885,6 +939,12 @@ private constructor( override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { autoTagging.validate() } + + override fun visitAutoDescription( + autoDescription: AutoDescriptionExtension + ) { + autoDescription.validate() + } } ) validated = true @@ -914,6 +974,10 @@ private constructor( override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = autoTagging.validity() + override fun visitAutoDescription( + autoDescription: AutoDescriptionExtension + ) = autoDescription.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -925,15 +989,18 @@ private constructor( return other is Extension && removedotBg == other.removedotBg && - autoTagging == other.autoTagging + autoTagging == other.autoTagging && + autoDescription == other.autoDescription } - override fun hashCode(): Int = Objects.hash(removedotBg, autoTagging) + override fun hashCode(): Int = + Objects.hash(removedotBg, autoTagging, autoDescription) override fun toString(): String = when { removedotBg != null -> "Extension{removedotBg=$removedotBg}" autoTagging != null -> "Extension{autoTagging=$autoTagging}" + autoDescription != null -> "Extension{autoDescription=$autoDescription}" _json != null -> "Extension{_unknown=$_json}" else -> throw IllegalStateException("Invalid Extension") } @@ -947,6 +1014,10 @@ private constructor( @JvmStatic fun ofAutoTagging(autoTagging: AutoTaggingExtension) = Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAutoDescription(autoDescription: AutoDescriptionExtension) = + Extension(autoDescription = autoDescription) } /** @@ -959,6 +1030,8 @@ private constructor( fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + fun visitAutoDescription(autoDescription: AutoDescriptionExtension): T + /** * Maps an unknown variant of [Extension] to a value of type [T]. * @@ -985,6 +1058,8 @@ private constructor( ?.let { Extension(removedotBg = it, _json = json) }, tryDeserialize(node, jacksonTypeRef()) ?.let { Extension(autoTagging = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(autoDescription = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1013,6 +1088,8 @@ private constructor( when { value.removedotBg != null -> generator.writeObject(value.removedotBg) value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.autoDescription != null -> + generator.writeObject(value.autoDescription) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Extension") } @@ -2069,6 +2146,306 @@ private constructor( override fun toString() = "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } + + class AutoDescriptionExtension + private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * Specifies the auto description 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(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value 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 + * [AutoDescriptionExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoDescriptionExtension]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = + apply { + name = autoDescriptionExtension.name + additionalProperties = + autoDescriptionExtension.additionalProperties.toMutableMap() + } + + /** Specifies the auto description extension. */ + 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 [AutoDescriptionExtension]. + * + * 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(): AutoDescriptionExtension = + AutoDescriptionExtension( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoDescriptionExtension = apply { + if (validated) { + return@apply + } + + 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 = (name.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the auto description extension. */ + 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + AI_AUTO_DESCRIPTION + } + + /** + * 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 { + AI_AUTO_DESCRIPTION, + /** + * 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) { + AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION + 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 AutoDescriptionExtension && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoDescriptionExtension{name=$name, additionalProperties=$additionalProperties}" + } } /** @@ -2399,6 +2776,7 @@ private constructor( return other is UpdateFileDetails && customCoordinates == other.customCoordinates && customMetadata == other.customMetadata && + description == other.description && extensions == other.extensions && removeAiTags == other.removeAiTags && tags == other.tags && @@ -2410,6 +2788,7 @@ private constructor( Objects.hash( customCoordinates, customMetadata, + description, extensions, removeAiTags, tags, @@ -2421,7 +2800,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UpdateFileDetails{customCoordinates=$customCoordinates, customMetadata=$customMetadata, extensions=$extensions, removeAiTags=$removeAiTags, tags=$tags, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + "UpdateFileDetails{customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, removeAiTags=$removeAiTags, tags=$tags, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } class ChangePublicationStatus @@ -2803,7 +3182,7 @@ private constructor( return true } - return other is DetailUpdateParams && + return other is FileUpdateParams && fileId == other.fileId && body == other.body && additionalHeaders == other.additionalHeaders && @@ -2814,5 +3193,5 @@ private constructor( Objects.hash(fileId, body, additionalHeaders, additionalQueryParams) override fun toString() = - "DetailUpdateParams{fileId=$fileId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileUpdateParams{fileId=$fileId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index 9c18cc9e..8b730e52 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.details +package com.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,7 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class DetailUpdateResponse +class FileUpdateResponse private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, @@ -455,11 +455,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [DetailUpdateResponse]. */ + /** Returns a mutable builder for constructing an instance of [FileUpdateResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [DetailUpdateResponse]. */ + /** A builder for [FileUpdateResponse]. */ class Builder internal constructor() { private var aiTags: JsonField>? = null @@ -487,30 +487,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(detailUpdateResponse: DetailUpdateResponse) = apply { - aiTags = detailUpdateResponse.aiTags.map { it.toMutableList() } - createdAt = detailUpdateResponse.createdAt - customCoordinates = detailUpdateResponse.customCoordinates - customMetadata = detailUpdateResponse.customMetadata - extensionStatus = detailUpdateResponse.extensionStatus - fileId = detailUpdateResponse.fileId - filePath = detailUpdateResponse.filePath - fileType = detailUpdateResponse.fileType - hasAlpha = detailUpdateResponse.hasAlpha - height = detailUpdateResponse.height - isPrivateFile = detailUpdateResponse.isPrivateFile - isPublished = detailUpdateResponse.isPublished - mime = detailUpdateResponse.mime - name = detailUpdateResponse.name - size = detailUpdateResponse.size - tags = detailUpdateResponse.tags.map { it.toMutableList() } - thumbnail = detailUpdateResponse.thumbnail - type = detailUpdateResponse.type - updatedAt = detailUpdateResponse.updatedAt - url = detailUpdateResponse.url - versionInfo = detailUpdateResponse.versionInfo - width = detailUpdateResponse.width - additionalProperties = detailUpdateResponse.additionalProperties.toMutableMap() + internal fun from(fileUpdateResponse: FileUpdateResponse) = apply { + aiTags = fileUpdateResponse.aiTags.map { it.toMutableList() } + createdAt = fileUpdateResponse.createdAt + customCoordinates = fileUpdateResponse.customCoordinates + customMetadata = fileUpdateResponse.customMetadata + extensionStatus = fileUpdateResponse.extensionStatus + 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 + additionalProperties = fileUpdateResponse.additionalProperties.toMutableMap() } /** An array of tags assigned to the file by auto tagging. */ @@ -834,12 +834,12 @@ private constructor( } /** - * Returns an immutable instance of [DetailUpdateResponse]. + * Returns an immutable instance of [FileUpdateResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): DetailUpdateResponse = - DetailUpdateResponse( + fun build(): FileUpdateResponse = + FileUpdateResponse( (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, createdAt, customCoordinates, @@ -868,7 +868,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DetailUpdateResponse = apply { + fun validate(): FileUpdateResponse = apply { if (validated) { return@apply } @@ -1155,6 +1155,7 @@ private constructor( class ExtensionStatus private constructor( + private val aiAutoDescription: JsonField, private val awsAutoTagging: JsonField, private val googleAutoTagging: JsonField, private val removeBg: JsonField, @@ -1163,6 +1164,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("ai-auto-description") + @ExcludeMissing + aiAutoDescription: JsonField = JsonMissing.of(), @JsonProperty("aws-auto-tagging") @ExcludeMissing awsAutoTagging: JsonField = JsonMissing.of(), @@ -1172,7 +1176,14 @@ private constructor( @JsonProperty("remove-bg") @ExcludeMissing removeBg: JsonField = JsonMissing.of(), - ) : this(awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + ) : 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 @@ -1194,6 +1205,16 @@ private constructor( */ 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]. * @@ -1242,6 +1263,7 @@ private constructor( /** 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() @@ -1249,12 +1271,27 @@ private constructor( @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)) @@ -1320,6 +1357,7 @@ private constructor( */ fun build(): ExtensionStatus = ExtensionStatus( + aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, @@ -1334,6 +1372,7 @@ private constructor( return@apply } + aiAutoDescription().ifPresent { it.validate() } awsAutoTagging().ifPresent { it.validate() } googleAutoTagging().ifPresent { it.validate() } removeBg().ifPresent { it.validate() } @@ -1356,10 +1395,150 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (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 { @@ -1779,6 +1958,7 @@ private constructor( } return other is ExtensionStatus && + aiAutoDescription == other.aiAutoDescription && awsAutoTagging == other.awsAutoTagging && googleAutoTagging == other.googleAutoTagging && removeBg == other.removeBg && @@ -1786,13 +1966,19 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + Objects.hash( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } /** An object with details of the file version. */ @@ -1976,7 +2162,7 @@ private constructor( return true } - return other is DetailUpdateResponse && + return other is FileUpdateResponse && aiTags == other.aiTags && createdAt == other.createdAt && customCoordinates == other.customCoordinates && @@ -2033,5 +2219,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DetailUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, extensionStatus=$extensionStatus, 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}" + "FileUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, extensionStatus=$extensionStatus, 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/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt new file mode 100644 index 00000000..2227724a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -0,0 +1,6112 @@ +// 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.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.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 + +/** + * 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 `expiration` 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(file: Path) = apply { body.file(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 `_` + */ + 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.ofRemovedotBg(removedotBg)`. */ + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = apply { + body.addExtension(removedotBg) + } + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { + body.addExtension(autoTagging) + } + + /** Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = apply { + body.addExtension(autoDescription) + } + + /** + * 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(file: Path) = + file( + MultipartField.builder() + .value(file.inputStream()) + .filename(file.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.ofRemovedotBg(removedotBg)`. */ + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = + addExtension(Extension.ofRemovedotBg(removedotBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** + * Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. + */ + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = + addExtension(Extension.ofAutoDescription(autoDescription)) + + /** + * 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 removedotBg: RemovedotBgExtension? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val autoDescription: AutoDescriptionExtension? = null, + private val _json: JsonValue? = null, + ) { + + fun removedotBg(): Optional = Optional.ofNullable(removedotBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun autoDescription(): Optional = + Optional.ofNullable(autoDescription) + + fun isRemovedotBg(): Boolean = removedotBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAutoDescription(): Boolean = autoDescription != null + + fun asRemovedotBg(): RemovedotBgExtension = removedotBg.getOrThrow("removedotBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAutoDescription(): AutoDescriptionExtension = + autoDescription.getOrThrow("autoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removedotBg != null -> visitor.visitRemovedotBg(removedotBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + autoDescription != null -> visitor.visitAutoDescription(autoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) { + removedotBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAutoDescription(autoDescription: AutoDescriptionExtension) { + autoDescription.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 visitRemovedotBg(removedotBg: RemovedotBgExtension) = + removedotBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAutoDescription(autoDescription: AutoDescriptionExtension) = + autoDescription.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removedotBg == other.removedotBg && + autoTagging == other.autoTagging && + autoDescription == other.autoDescription + } + + override fun hashCode(): Int = Objects.hash(removedotBg, autoTagging, autoDescription) + + override fun toString(): String = + when { + removedotBg != null -> "Extension{removedotBg=$removedotBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + autoDescription != null -> "Extension{autoDescription=$autoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic + fun ofRemovedotBg(removedotBg: RemovedotBgExtension) = + Extension(removedotBg = removedotBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAutoDescription(autoDescription: AutoDescriptionExtension) = + Extension(autoDescription = autoDescription) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of type [T]. + */ + interface Visitor { + + fun visitRemovedotBg(removedotBg: RemovedotBgExtension): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAutoDescription(autoDescription: AutoDescriptionExtension): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removedotBg = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoDescription = 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 -> Extension(_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(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removedotBg != null -> generator.writeObject(value.removedotBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.autoDescription != null -> generator.writeObject(value.autoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } + + class RemovedotBgExtension + private constructor( + private val name: MultipartField, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the background removal 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(): Name = name.value.getRequired("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 [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + /** + * 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 [RemovedotBgExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovedotBgExtension]. */ + class Builder internal constructor() { + + private var name: MultipartField? = null + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { + name = removedotBgExtension.name + options = removedotBgExtension.options + additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() + } + + /** Specifies the background removal extension. */ + 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 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 [RemovedotBgExtension]. + * + * 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(): RemovedotBgExtension = + RemovedotBgExtension( + checkRequired("name", name), + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovedotBgExtension = apply { + if (validated) { + return@apply + } + + name().validate() + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the background removal extension. */ + 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 REMOVE_BG = of("remove-bg") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + REMOVE_BG + } + + /** + * 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 { + REMOVE_BG, + /** + * 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) { + REMOVE_BG -> Value.REMOVE_BG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + REMOVE_BG -> Known.REMOVE_BG + 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() + } + + 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 RemovedotBgExtension && + 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() = + "RemovedotBgExtension{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 AutoDescriptionExtension + private constructor( + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the auto description 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(): Name = name.value.getRequired("name") + + /** + * 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 + * [AutoDescriptionExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoDescriptionExtension]. */ + class Builder internal constructor() { + + private var name: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { + name = autoDescriptionExtension.name + additionalProperties = + autoDescriptionExtension.additionalProperties.toMutableMap() + } + + /** Specifies the auto description extension. */ + 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 [AutoDescriptionExtension]. + * + * 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(): AutoDescriptionExtension = + AutoDescriptionExtension( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoDescriptionExtension = apply { + if (validated) { + return@apply + } + + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the auto description extension. */ + 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + AI_AUTO_DESCRIPTION + } + + /** + * 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 { + AI_AUTO_DESCRIPTION, + /** + * 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) { + AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION + 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 AutoDescriptionExtension && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoDescriptionExtension{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.ofSimplePostTransformation(simplePostTransformation)`. + */ + fun addPost(simplePostTransformation: Post.SimplePostTransformation) = + addPost(Post.ofSimplePostTransformation(simplePostTransformation)) + + /** Alias for calling [addPost] with `Post.ofConvertGifToVideo(convertGifToVideo)`. */ + fun addPost(convertGifToVideo: Post.ConvertGifToVideo) = + addPost(Post.ofConvertGifToVideo(convertGifToVideo)) + + /** Alias for calling [addPost] with `Post.ofGenerateAThumbnail(generateAThumbnail)`. */ + fun addPost(generateAThumbnail: Post.GenerateAThumbnail) = + addPost(Post.ofGenerateAThumbnail(generateAThumbnail)) + + /** + * Alias for calling [addPost] with + * `Post.ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming)`. + */ + fun addPost(adaptiveBitrateStreaming: Post.AdaptiveBitrateStreaming) = + addPost(Post.ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming)) + + /** + * 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 simplePostTransformation: SimplePostTransformation? = null, + private val convertGifToVideo: ConvertGifToVideo? = null, + private val generateAThumbnail: GenerateAThumbnail? = null, + private val adaptiveBitrateStreaming: AdaptiveBitrateStreaming? = null, + private val _json: JsonValue? = null, + ) { + + fun simplePostTransformation(): Optional = + Optional.ofNullable(simplePostTransformation) + + fun convertGifToVideo(): Optional = + Optional.ofNullable(convertGifToVideo) + + fun generateAThumbnail(): Optional = + Optional.ofNullable(generateAThumbnail) + + fun adaptiveBitrateStreaming(): Optional = + Optional.ofNullable(adaptiveBitrateStreaming) + + fun isSimplePostTransformation(): Boolean = simplePostTransformation != null + + fun isConvertGifToVideo(): Boolean = convertGifToVideo != null + + fun isGenerateAThumbnail(): Boolean = generateAThumbnail != null + + fun isAdaptiveBitrateStreaming(): Boolean = adaptiveBitrateStreaming != null + + fun asSimplePostTransformation(): SimplePostTransformation = + simplePostTransformation.getOrThrow("simplePostTransformation") + + fun asConvertGifToVideo(): ConvertGifToVideo = + convertGifToVideo.getOrThrow("convertGifToVideo") + + fun asGenerateAThumbnail(): GenerateAThumbnail = + generateAThumbnail.getOrThrow("generateAThumbnail") + + fun asAdaptiveBitrateStreaming(): AdaptiveBitrateStreaming = + adaptiveBitrateStreaming.getOrThrow("adaptiveBitrateStreaming") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + simplePostTransformation != null -> + visitor.visitSimplePostTransformation(simplePostTransformation) + convertGifToVideo != null -> visitor.visitConvertGifToVideo(convertGifToVideo) + generateAThumbnail != null -> + visitor.visitGenerateAThumbnail(generateAThumbnail) + adaptiveBitrateStreaming != null -> + visitor.visitAdaptiveBitrateStreaming(adaptiveBitrateStreaming) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Post = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSimplePostTransformation( + simplePostTransformation: SimplePostTransformation + ) { + simplePostTransformation.validate() + } + + override fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) { + convertGifToVideo.validate() + } + + override fun visitGenerateAThumbnail( + generateAThumbnail: GenerateAThumbnail + ) { + generateAThumbnail.validate() + } + + override fun visitAdaptiveBitrateStreaming( + adaptiveBitrateStreaming: AdaptiveBitrateStreaming + ) { + adaptiveBitrateStreaming.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 visitSimplePostTransformation( + simplePostTransformation: SimplePostTransformation + ) = simplePostTransformation.validity() + + override fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) = + convertGifToVideo.validity() + + override fun visitGenerateAThumbnail( + generateAThumbnail: GenerateAThumbnail + ) = generateAThumbnail.validity() + + override fun visitAdaptiveBitrateStreaming( + adaptiveBitrateStreaming: AdaptiveBitrateStreaming + ) = adaptiveBitrateStreaming.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Post && + simplePostTransformation == other.simplePostTransformation && + convertGifToVideo == other.convertGifToVideo && + generateAThumbnail == other.generateAThumbnail && + adaptiveBitrateStreaming == other.adaptiveBitrateStreaming + } + + override fun hashCode(): Int = + Objects.hash( + simplePostTransformation, + convertGifToVideo, + generateAThumbnail, + adaptiveBitrateStreaming, + ) + + override fun toString(): String = + when { + simplePostTransformation != null -> + "Post{simplePostTransformation=$simplePostTransformation}" + convertGifToVideo != null -> "Post{convertGifToVideo=$convertGifToVideo}" + generateAThumbnail != null -> "Post{generateAThumbnail=$generateAThumbnail}" + adaptiveBitrateStreaming != null -> + "Post{adaptiveBitrateStreaming=$adaptiveBitrateStreaming}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } + + companion object { + + @JvmStatic + fun ofSimplePostTransformation(simplePostTransformation: SimplePostTransformation) = + Post(simplePostTransformation = simplePostTransformation) + + @JvmStatic + fun ofConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) = + Post(convertGifToVideo = convertGifToVideo) + + @JvmStatic + fun ofGenerateAThumbnail(generateAThumbnail: GenerateAThumbnail) = + Post(generateAThumbnail = generateAThumbnail) + + @JvmStatic + fun ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming: AdaptiveBitrateStreaming) = + Post(adaptiveBitrateStreaming = adaptiveBitrateStreaming) + } + + /** + * An interface that defines how to map each variant of [Post] to a value of type [T]. + */ + interface Visitor { + + fun visitSimplePostTransformation( + simplePostTransformation: SimplePostTransformation + ): T + + fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo): T + + fun visitGenerateAThumbnail(generateAThumbnail: GenerateAThumbnail): T + + fun visitAdaptiveBitrateStreaming( + adaptiveBitrateStreaming: AdaptiveBitrateStreaming + ): 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 bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Post(simplePostTransformation = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Post(convertGifToVideo = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Post(generateAThumbnail = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Post(adaptiveBitrateStreaming = 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 -> Post(_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(Post::class) { + + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.simplePostTransformation != null -> + generator.writeObject(value.simplePostTransformation) + value.convertGifToVideo != null -> + generator.writeObject(value.convertGifToVideo) + value.generateAThumbnail != null -> + generator.writeObject(value.generateAThumbnail) + value.adaptiveBitrateStreaming != null -> + generator.writeObject(value.adaptiveBitrateStreaming) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } + } + } + + class SimplePostTransformation + private constructor( + private val type: MultipartField, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Transformation 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 type(): Type = type.value.getRequired("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 [type]. + * + * Unlike [type], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type + + /** + * 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 + * [SimplePostTransformation]. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SimplePostTransformation]. */ + class Builder internal constructor() { + + private var type: MultipartField? = null + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(simplePostTransformation: SimplePostTransformation) = apply { + type = simplePostTransformation.type + value = simplePostTransformation.value + additionalProperties = + simplePostTransformation.additionalProperties.toMutableMap() + } + + /** Transformation type. */ + fun type(type: Type) = type(MultipartField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary multipart 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: MultipartField) = 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 [SimplePostTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SimplePostTransformation = + SimplePostTransformation( + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SimplePostTransformation = apply { + if (validated) { + return@apply + } + + type().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Transformation type. */ + 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") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TRANSFORMATION + } + + /** + * 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, + /** + * 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 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + 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 SimplePostTransformation && + 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() = + "SimplePostTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class ConvertGifToVideo + private constructor( + private val type: MultipartField, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Converts an animated GIF into an MP4. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun type(): Type = type.value.getRequired("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 [type]. + * + * Unlike [type], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type + + /** + * 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 + * [ConvertGifToVideo]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConvertGifToVideo]. */ + class Builder internal constructor() { + + private var type: MultipartField? = null + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(convertGifToVideo: ConvertGifToVideo) = apply { + type = convertGifToVideo.type + value = convertGifToVideo.value + additionalProperties = convertGifToVideo.additionalProperties.toMutableMap() + } + + /** Converts an animated GIF into an MP4. */ + fun type(type: Type) = type(MultipartField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary multipart 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: MultipartField) = 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 [ConvertGifToVideo]. + * + * 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(): ConvertGifToVideo = + ConvertGifToVideo( + checkRequired("type", type), + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConvertGifToVideo = apply { + if (validated) { + return@apply + } + + type().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Converts an animated GIF into an MP4. */ + 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 GIF_TO_VIDEO = of("gif-to-video") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GIF_TO_VIDEO + } + + /** + * 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 { + GIF_TO_VIDEO, + /** + * 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) { + GIF_TO_VIDEO -> Value.GIF_TO_VIDEO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GIF_TO_VIDEO -> Known.GIF_TO_VIDEO + 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 ConvertGifToVideo && + 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() = + "ConvertGifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class GenerateAThumbnail + private constructor( + private val type: MultipartField, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Generates a thumbnail 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 type(): Type = type.value.getRequired("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 [type]. + * + * Unlike [type], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type + + /** + * 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 + * [GenerateAThumbnail]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GenerateAThumbnail]. */ + class Builder internal constructor() { + + private var type: MultipartField? = null + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(generateAThumbnail: GenerateAThumbnail) = apply { + type = generateAThumbnail.type + value = generateAThumbnail.value + additionalProperties = + generateAThumbnail.additionalProperties.toMutableMap() + } + + /** Generates a thumbnail image. */ + fun type(type: Type) = type(MultipartField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary multipart 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: MultipartField) = 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 [GenerateAThumbnail]. + * + * 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(): GenerateAThumbnail = + GenerateAThumbnail( + checkRequired("type", type), + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GenerateAThumbnail = apply { + if (validated) { + return@apply + } + + type().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Generates a thumbnail image. */ + 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 THUMBNAIL = of("thumbnail") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + 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 { + 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) { + 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) { + 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() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GenerateAThumbnail && + 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() = + "GenerateAThumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class AdaptiveBitrateStreaming + private constructor( + private val protocol: MultipartField, + private val type: MultipartField, + 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. + * + * @throws ImageKitInvalidDataException if 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.value.getRequired("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 [type]. + * + * Unlike [type], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type + + /** + * 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 + * [AdaptiveBitrateStreaming]. + * + * The following fields are required: + * ```java + * .protocol() + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdaptiveBitrateStreaming]. */ + class Builder internal constructor() { + + private var protocol: MultipartField? = null + private var type: MultipartField? = null + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adaptiveBitrateStreaming: AdaptiveBitrateStreaming) = apply { + protocol = adaptiveBitrateStreaming.protocol + type = adaptiveBitrateStreaming.type + value = adaptiveBitrateStreaming.value + additionalProperties = + adaptiveBitrateStreaming.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 + } + + /** Adaptive Bitrate Streaming (ABS) setup. */ + fun type(type: Type) = type(MultipartField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary multipart 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: MultipartField) = 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 [AdaptiveBitrateStreaming]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .protocol() + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AdaptiveBitrateStreaming = + AdaptiveBitrateStreaming( + checkRequired("protocol", protocol), + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AdaptiveBitrateStreaming = apply { + if (validated) { + return@apply + } + + protocol().validate() + type().validate() + 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() + } + + /** Adaptive Bitrate Streaming (ABS) setup. */ + 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 ABS = of("abs") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ABS + } + + /** + * 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 { + ABS, + /** + * 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) { + ABS -> Value.ABS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + ABS -> Known.ABS + 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 AdaptiveBitrateStreaming && + 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() = + "AdaptiveBitrateStreaming{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..53422ce1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt @@ -0,0 +1,5880 @@ +// 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: JsonValue, + 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: JsonValue = 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, + 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. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonValue = customMetadata + + /** + * 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 [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: JsonValue = 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 + 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: JsonValue) = apply { + this.customMetadata = customMetadata + } + + /** 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, + 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() + 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) + + (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}" + } + + /** + * 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 awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @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(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 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 [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 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 { + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + 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( + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + 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 = + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + 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 && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the + * upload API response. + */ + 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}" + } + + /** 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 && + 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, + 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, 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/FileUploadV1Params.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Params.kt deleted file mode 100644 index 9e452bcb..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Params.kt +++ /dev/null @@ -1,3127 +0,0 @@ -// 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.JsonValue -import com.imagekit.api.core.MultipartField -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 com.imagekit.api.errors.ImageKitInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional - -/** - * 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 `expiration` 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 FileUploadV1Params -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please ensure - * that our servers can access the URL. In case ImageKit is unable to download the file from the - * specified URL, a `400` error response is returned. This will also result in a `400` error if - * the file download request is aborted if response headers are not received in 8 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 file(): String = 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() - - /** - * Stringified JSON key-value data to be associated with the asset. - * - * @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() - - /** - * 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() - - /** - * Stringified JSON object with an array of extensions to be applied to the image. Refer to - * extensions schema in - * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). - * - * @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() - - /** - * Comma-separated values of the fields that you want the API to return in the response. - * - * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get the - * value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. - * - * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, - * `isPublished`, `customMetadata`, and `metadata`. - * - * @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. - * - * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all - * characters should not exceed 500. `%` is not allowed. - * - * If this field is not specified and the file is overwritten then the 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() - - /** - * Stringified JSON object with properties for pre and post transformations: - * - * `pre` - Accepts a "string" containing a valid transformation used for requesting a - * pre-transformation for an image or a video file. - * - * `post` - Accepts an array of objects with properties: - * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive bitrate - * streaming). - * - `value`: A "string" corresponding to the required transformation. Required if `type` is - * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. - * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. - * - * Read more about [Adaptive bitrate streaming (ABS)](/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 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 [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 [FileUploadV1Params]. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileUploadV1Params]. */ - 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(fileUploadV1Params: FileUploadV1Params) = apply { - body = fileUploadV1Params.body.toBuilder() - additionalHeaders = fileUploadV1Params.additionalHeaders.toBuilder() - additionalQueryParams = fileUploadV1Params.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() } - - /** - * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please - * ensure that our servers can access the URL. In case ImageKit is unable to download the - * file from the specified URL, a `400` error response is returned. This will also result in - * a `400` error if the file download request is aborted if response headers are not - * received in 8 seconds. - */ - 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 [String] 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 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) - } - - /** Stringified JSON key-value data to be associated with the asset. */ - fun customMetadata(customMetadata: String) = apply { body.customMetadata(customMetadata) } - - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed [String] 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) - } - - /** - * 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: String) = apply { body.expire(expire) } - - /** - * Sets [Builder.expire] to an arbitrary multipart value. - * - * You should usually call [Builder.expire] with a well-typed [String] 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) } - - /** - * Stringified JSON object with an array of extensions to be applied to the image. Refer to - * extensions schema in - * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). - */ - fun extensions(extensions: String) = apply { body.extensions(extensions) } - - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed [String] 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) } - - /** - * 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: IsPrivateFile) = apply { - body.isPrivateFile(isPrivateFile) - } - - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [IsPrivateFile] 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: IsPublished) = apply { body.isPublished(isPublished) } - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [IsPublished] 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: OverwriteAiTags) = apply { - body.overwriteAiTags(overwriteAiTags) - } - - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [OverwriteAiTags] - * 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: OverwriteCustomMetadata) = apply { - body.overwriteCustomMetadata(overwriteCustomMetadata) - } - - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed - * [OverwriteCustomMetadata] 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: String) = apply { body.overwriteFile(overwriteFile) } - - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [String] 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: OverwriteTags) = apply { - body.overwriteTags(overwriteTags) - } - - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [OverwriteTags] 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) } - - /** - * Comma-separated values of the fields that you want the API to return in the response. - * - * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get - * the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. - * - * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, - * `isPublished`, `customMetadata`, and `metadata`. - */ - fun responseFields(responseFields: String) = apply { body.responseFields(responseFields) } - - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] 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(responseFields: MultipartField) = apply { - body.responseFields(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. - */ - 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. - * - * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all - * characters should not exceed 500. `%` is not allowed. - * - * If this field is not specified and the file is overwritten then the tags will be removed. - */ - fun tags(tags: String) = apply { body.tags(tags) } - - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed [String] 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) } - - /** - * Stringified JSON object with properties for pre and post transformations: - * - * `pre` - Accepts a "string" containing a valid transformation used for requesting a - * pre-transformation for an image or a video file. - * - * `post` - Accepts an array of objects with properties: - * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive - * bitrate streaming). - * - `value`: A "string" corresponding to the required transformation. Required if `type` is - * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. - * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. - * - * Read more about [Adaptive bitrate streaming (ABS)](/docs/adaptive-bitrate-streaming). - */ - fun transformation(transformation: String) = apply { body.transformation(transformation) } - - /** - * Sets [Builder.transformation] to an arbitrary multipart 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: 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: UseUniqueFileName) = apply { - body.useUniqueFileName(useUniqueFileName) - } - - /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. - * - * You should usually call [Builder.useUniqueFileName] with a well-typed [UseUniqueFileName] - * 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 [FileUploadV1Params]. - * - * 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(): FileUploadV1Params = - FileUploadV1Params( - 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(), - "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 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, - ) { - - /** - * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please - * ensure that our servers can access the URL. In case ImageKit is unable to download the - * file from the specified URL, a `400` error response is returned. This will also result in - * a `400` error if the file download request is aborted if response headers are not - * received in 8 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 file(): String = 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") - - /** - * Stringified JSON key-value data to be associated with the asset. - * - * @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") - - /** - * 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") - - /** - * Stringified JSON object with an array of extensions to be applied to the image. Refer to - * extensions schema in - * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). - * - * @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") - - /** - * Comma-separated values of the fields that you want the API to return in the response. - * - * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get - * the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. - * - * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, - * `isPublished`, `customMetadata`, and `metadata`. - * - * @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. - * - * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all - * characters should not exceed 500. `%` is not allowed. - * - * If this field is not specified and the file is overwritten then the 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") - - /** - * Stringified JSON object with properties for pre and post transformations: - * - * `pre` - Accepts a "string" containing a valid transformation used for requesting a - * pre-transformation for an image or a video file. - * - * `post` - Accepts an array of objects with properties: - * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive - * bitrate streaming). - * - `value`: A "string" corresponding to the required transformation. Required if `type` is - * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. - * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. - * - * Read more about [Adaptive bitrate streaming (ABS)](/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 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 [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 expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField = MultipartField.of(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 = MultipartField.of(null) - private var signature: MultipartField = MultipartField.of(null) - private var tags: 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() - - @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 - expire = body.expire - extensions = body.extensions - 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 - signature = body.signature - tags = body.tags - transformation = body.transformation - useUniqueFileName = body.useUniqueFileName - webhookUrl = body.webhookUrl - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please - * ensure that our servers can access the URL. In case ImageKit is unable to download - * the file from the specified URL, a `400` error response is returned. This will also - * result in a `400` error if the file download request is aborted if response headers - * are not received in 8 seconds. - */ - 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 [String] 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 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 - } - - /** Stringified JSON key-value data to be associated with the asset. */ - fun customMetadata(customMetadata: String) = - customMetadata(MultipartField.of(customMetadata)) - - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed [String] 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 - } - - /** - * 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: String) = expire(MultipartField.of(expire)) - - /** - * Sets [Builder.expire] to an arbitrary multipart value. - * - * You should usually call [Builder.expire] with a well-typed [String] 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 } - - /** - * Stringified JSON object with an array of extensions to be applied to the image. Refer - * to extensions schema in - * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). - */ - fun extensions(extensions: String) = extensions(MultipartField.of(extensions)) - - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed [String] 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 - } - - /** - * 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: IsPrivateFile) = - isPrivateFile(MultipartField.of(isPrivateFile)) - - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [IsPrivateFile] - * 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: IsPublished) = isPublished(MultipartField.of(isPublished)) - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [IsPublished] 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: OverwriteAiTags) = - overwriteAiTags(MultipartField.of(overwriteAiTags)) - - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [OverwriteAiTags] - * 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: OverwriteCustomMetadata) = - overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) - - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed - * [OverwriteCustomMetadata] 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: String) = - overwriteFile(MultipartField.of(overwriteFile)) - - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [String] 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: OverwriteTags) = - overwriteTags(MultipartField.of(overwriteTags)) - - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [OverwriteTags] - * 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 } - - /** - * Comma-separated values of the fields that you want the API to return in the response. - * - * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to - * get the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. - * - * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, - * `embeddedMetadata`, `isPublished`, `customMetadata`, and `metadata`. - */ - fun responseFields(responseFields: String) = - responseFields(MultipartField.of(responseFields)) - - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] 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(responseFields: MultipartField) = apply { - this.responseFields = 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. - */ - 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. - * - * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of - * all characters should not exceed 500. `%` is not allowed. - * - * If this field is not specified and the file is overwritten then the tags will be - * removed. - */ - fun tags(tags: String) = tags(MultipartField.of(tags)) - - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed [String] 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 } - - /** - * Stringified JSON object with properties for pre and post transformations: - * - * `pre` - Accepts a "string" containing a valid transformation used for requesting a - * pre-transformation for an image or a video file. - * - * `post` - Accepts an array of objects with properties: - * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive - * bitrate streaming). - * - `value`: A "string" corresponding to the required transformation. Required if - * `type` is `transformation` or `abs`. Optional if `type` is `gif-to-video` or - * `thumbnail`. - * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. - * - * Read more about [Adaptive bitrate streaming (ABS)](/docs/adaptive-bitrate-streaming). - */ - fun transformation(transformation: String) = - transformation(MultipartField.of(transformation)) - - /** - * Sets [Builder.transformation] to an arbitrary multipart 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: 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: UseUniqueFileName) = - useUniqueFileName(MultipartField.of(useUniqueFileName)) - - /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. - * - * You should usually call [Builder.useUniqueFileName] with a well-typed - * [UseUniqueFileName] 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, - expire, - extensions, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - responseFields, - signature, - tags, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - file() - fileName() - token() - checks() - customCoordinates() - customMetadata() - expire() - extensions() - folder() - isPrivateFile().ifPresent { it.validate() } - isPublished().ifPresent { it.validate() } - overwriteAiTags().ifPresent { it.validate() } - overwriteCustomMetadata().ifPresent { it.validate() } - overwriteFile() - overwriteTags().ifPresent { it.validate() } - publicKey() - responseFields() - signature() - tags() - transformation() - useUniqueFileName().ifPresent { it.validate() } - 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 && - 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, - 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, 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}" - } - - /** - * 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. - */ - class IsPrivateFile @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = IsPrivateFile(JsonField.of(value)) - } - - /** An enum containing [IsPrivateFile]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [IsPrivateFile]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [IsPrivateFile] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [IsPrivateFile] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown IsPrivateFile: $value") - } - - /** - * Returns this class 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(): IsPrivateFile = 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 IsPrivateFile && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * 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. - */ - class IsPublished @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = IsPublished(JsonField.of(value)) - } - - /** An enum containing [IsPublished]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [IsPublished]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [IsPublished] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [IsPublished] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown IsPublished: $value") - } - - /** - * Returns this class 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(): IsPublished = 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 IsPublished && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * 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. - */ - class OverwriteAiTags @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = OverwriteAiTags(JsonField.of(value)) - } - - /** An enum containing [OverwriteAiTags]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [OverwriteAiTags]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [OverwriteAiTags] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [OverwriteAiTags] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown OverwriteAiTags: $value") - } - - /** - * Returns this class 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(): OverwriteAiTags = 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 OverwriteAiTags && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - */ - class OverwriteCustomMetadata - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = OverwriteCustomMetadata(JsonField.of(value)) - } - - /** An enum containing [OverwriteCustomMetadata]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [OverwriteCustomMetadata]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [OverwriteCustomMetadata] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [OverwriteCustomMetadata] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> - throw ImageKitInvalidDataException("Unknown OverwriteCustomMetadata: $value") - } - - /** - * Returns this class 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(): OverwriteCustomMetadata = 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 OverwriteCustomMetadata && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - */ - class OverwriteTags @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = OverwriteTags(JsonField.of(value)) - } - - /** An enum containing [OverwriteTags]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [OverwriteTags]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [OverwriteTags] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [OverwriteTags] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown OverwriteTags: $value") - } - - /** - * Returns this class 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(): OverwriteTags = 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 OverwriteTags && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * 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. - */ - class UseUniqueFileName @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = UseUniqueFileName(JsonField.of(value)) - } - - /** An enum containing [UseUniqueFileName]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [UseUniqueFileName]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UseUniqueFileName] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [UseUniqueFileName] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown UseUniqueFileName: $value") - } - - /** - * Returns this class 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(): UseUniqueFileName = 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 UseUniqueFileName && 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 FileUploadV1Params && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "FileUploadV1Params{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Response.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Response.kt deleted file mode 100644 index 29242de7..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV1Response.kt +++ /dev/null @@ -1,11793 +0,0 @@ -// 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 successful upload. */ -class FileUploadV1Response -private constructor( - private val aiTags: JsonField>, - private val audioCodec: JsonField, - private val bitRate: JsonField, - private val customCoordinates: JsonField, - private val customMetadata: JsonValue, - 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: JsonValue = 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, - 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. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata - - /** - * 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 [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 [FileUploadV1Response]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileUploadV1Response]. */ - 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: JsonValue = 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(fileUploadV1Response: FileUploadV1Response) = apply { - aiTags = fileUploadV1Response.aiTags.map { it.toMutableList() } - audioCodec = fileUploadV1Response.audioCodec - bitRate = fileUploadV1Response.bitRate - customCoordinates = fileUploadV1Response.customCoordinates - customMetadata = fileUploadV1Response.customMetadata - duration = fileUploadV1Response.duration - embeddedMetadata = fileUploadV1Response.embeddedMetadata - extensionStatus = fileUploadV1Response.extensionStatus - fileId = fileUploadV1Response.fileId - filePath = fileUploadV1Response.filePath - fileType = fileUploadV1Response.fileType - height = fileUploadV1Response.height - isPrivateFile = fileUploadV1Response.isPrivateFile - isPublished = fileUploadV1Response.isPublished - metadata = fileUploadV1Response.metadata - name = fileUploadV1Response.name - size = fileUploadV1Response.size - tags = fileUploadV1Response.tags.map { it.toMutableList() } - thumbnailUrl = fileUploadV1Response.thumbnailUrl - url = fileUploadV1Response.url - versionInfo = fileUploadV1Response.versionInfo - videoCodec = fileUploadV1Response.videoCodec - width = fileUploadV1Response.width - additionalProperties = fileUploadV1Response.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: JsonValue) = apply { - this.customMetadata = customMetadata - } - - /** 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 [FileUploadV1Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FileUploadV1Response = - FileUploadV1Response( - (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, - audioCodec, - bitRate, - customCoordinates, - customMetadata, - 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(): FileUploadV1Response = apply { - if (validated) { - return@apply - } - - aiTags().ifPresent { it.forEach { it.validate() } } - audioCodec() - bitRate() - customCoordinates() - 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) + - (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}" - } - - /** - * 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 - private constructor( - private val aboutCvTermCvId: JsonField, - private val aboutCvTermId: JsonField, - private val aboutCvTermName: JsonField, - private val aboutCvTermRefinedAbout: JsonField, - private val additionalModelInformation: JsonField, - private val applicationRecordVersion: JsonField, - private val artist: JsonField, - private val artworkCircaDateCreated: JsonField, - private val artworkContentDescription: JsonField, - private val artworkContributionDescription: JsonField, - private val artworkCopyrightNotice: JsonField, - private val artworkCopyrightOwnerId: JsonField, - private val artworkCopyrightOwnerName: JsonField, - private val artworkCreator: JsonField>, - private val artworkCreatorId: JsonField>, - private val artworkDateCreated: JsonField, - private val artworkLicensorId: JsonField, - private val artworkLicensorName: JsonField, - private val artworkPhysicalDescription: JsonField, - private val artworkSource: JsonField, - private val artworkSourceInventoryNo: JsonField, - private val artworkSourceInvUrl: JsonField, - private val artworkStylePeriod: JsonField>, - private val artworkTitle: JsonField, - private val authorsPosition: JsonField, - private val byline: JsonField, - private val bylineTitle: JsonField, - private val caption: JsonField, - private val captionAbstract: JsonField, - private val captionWriter: JsonField, - private val city: JsonField, - private val colorSpace: JsonField, - private val componentsConfiguration: JsonField, - private val copyright: JsonField, - private val copyrightNotice: JsonField, - private val copyrightOwnerId: JsonField>, - private val copyrightOwnerName: JsonField>, - private val country: JsonField, - private val countryCode: JsonField, - private val countryPrimaryLocationCode: JsonField, - private val countryPrimaryLocationName: JsonField, - private val creator: JsonField, - private val creatorAddress: JsonField, - private val creatorCity: JsonField, - private val creatorCountry: JsonField, - private val creatorPostalCode: JsonField, - private val creatorRegion: JsonField, - private val creatorWorkEmail: JsonField, - private val creatorWorkTelephone: JsonField, - private val creatorWorkUrl: JsonField, - private val credit: JsonField, - private val dateCreated: JsonField, - private val dateTimeCreated: JsonField, - private val dateTimeOriginal: JsonField, - private val description: JsonField, - private val digitalImageGuid: JsonField, - private val digitalSourceType: JsonField, - private val embeddedEncodedRightsExpr: JsonField, - private val embeddedEncodedRightsExprLangId: JsonField, - private val embeddedEncodedRightsExprType: JsonField, - private val event: JsonField, - private val exifVersion: JsonField, - private val flashpixVersion: JsonField, - private val genreCvId: JsonField, - private val genreCvTermId: JsonField, - private val genreCvTermName: JsonField, - private val genreCvTermRefinedAbout: JsonField, - private val headline: JsonField, - private val imageCreatorId: JsonField, - private val imageCreatorImageId: JsonField, - private val imageCreatorName: JsonField, - private val imageDescription: JsonField, - private val imageRegionBoundaryH: JsonField>, - private val imageRegionBoundaryRx: JsonField>, - private val imageRegionBoundaryShape: JsonField>, - private val imageRegionBoundaryUnit: JsonField>, - private val imageRegionBoundaryVerticesX: JsonField>, - private val imageRegionBoundaryVerticesY: JsonField>, - private val imageRegionBoundaryW: JsonField>, - private val imageRegionBoundaryX: JsonField>, - private val imageRegionBoundaryY: JsonField>, - private val imageRegionCtypeIdentifier: JsonField>, - private val imageRegionCtypeName: JsonField>, - private val imageRegionId: JsonField>, - private val imageRegionName: JsonField>, - private val imageRegionOrganisationInImageName: JsonField>, - private val imageRegionPersonInImage: JsonField>, - private val imageRegionRoleIdentifier: JsonField>, - private val imageRegionRoleName: JsonField>, - private val imageSupplierId: JsonField, - private val imageSupplierImageId: JsonField, - private val imageSupplierName: JsonField, - private val instructions: JsonField, - private val intellectualGenre: JsonField, - private val keywords: JsonField>, - private val licensorCity: JsonField>, - private val licensorCountry: JsonField>, - private val licensorEmail: JsonField>, - private val licensorExtendedAddress: JsonField>, - private val licensorId: JsonField>, - private val licensorName: JsonField>, - private val licensorPostalCode: JsonField>, - private val licensorRegion: JsonField>, - private val licensorStreetAddress: JsonField>, - private val licensorTelephone1: JsonField>, - private val licensorTelephone2: JsonField>, - private val licensorUrl: JsonField>, - private val linkedEncodedRightsExpr: JsonField, - private val linkedEncodedRightsExprLangId: JsonField, - private val linkedEncodedRightsExprType: JsonField, - private val location: JsonField, - private val locationCreatedCity: JsonField, - private val locationCreatedCountryCode: JsonField, - private val locationCreatedCountryName: JsonField, - private val locationCreatedGpsAltitude: JsonField, - private val locationCreatedGpsLatitude: JsonField, - private val locationCreatedGpsLongitude: JsonField, - private val locationCreatedLocationId: JsonField, - private val locationCreatedLocationName: JsonField, - private val locationCreatedProvinceState: JsonField, - private val locationCreatedSublocation: JsonField, - private val locationCreatedWorldRegion: JsonField, - private val locationShownCity: JsonField>, - private val locationShownCountryCode: JsonField>, - private val locationShownCountryName: JsonField>, - private val locationShownGpsAltitude: JsonField>, - private val locationShownGpsLatitude: JsonField>, - private val locationShownGpsLongitude: JsonField>, - private val locationShownLocationId: JsonField>, - private val locationShownLocationName: JsonField>, - private val locationShownProvinceState: JsonField>, - private val locationShownSublocation: JsonField>, - private val locationShownWorldRegion: JsonField>, - private val maxAvailHeight: JsonField, - private val maxAvailWidth: JsonField, - private val modelAge: JsonField>, - private val modelReleaseId: JsonField>, - private val objectAttributeReference: JsonField, - private val objectName: JsonField, - private val offsetTimeOriginal: JsonField, - private val organisationInImageCode: JsonField>, - private val organisationInImageName: JsonField>, - private val orientation: JsonField, - private val originalTransmissionReference: JsonField, - private val personInImage: JsonField>, - private val personInImageCvTermCvId: JsonField>, - private val personInImageCvTermId: JsonField>, - private val personInImageCvTermName: JsonField>, - private val personInImageCvTermRefinedAbout: JsonField>, - private val personInImageDescription: JsonField>, - private val personInImageId: JsonField>, - private val personInImageName: JsonField>, - private val productInImageDescription: JsonField>, - private val productInImageGtin: JsonField>, - private val productInImageName: JsonField>, - private val propertyReleaseId: JsonField>, - private val provinceState: JsonField, - private val rating: JsonField, - private val registryEntryRole: JsonField>, - private val registryItemId: JsonField>, - private val registryOrganisationId: JsonField>, - private val resolutionUnit: JsonField, - private val rights: JsonField, - private val scene: JsonField>, - private val source: JsonField, - private val specialInstructions: JsonField, - private val state: JsonField, - private val subject: JsonField>, - private val subjectCode: JsonField>, - private val subjectReference: JsonField>, - private val sublocation: JsonField, - private val timeCreated: JsonField, - private val title: JsonField, - private val transmissionReference: JsonField, - private val usageTerms: JsonField, - private val webStatement: JsonField, - private val writer: JsonField, - private val writerEditor: JsonField, - private val xResolution: JsonField, - private val yResolution: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("AboutCvTermCvId") - @ExcludeMissing - aboutCvTermCvId: JsonField = JsonMissing.of(), - @JsonProperty("AboutCvTermId") - @ExcludeMissing - aboutCvTermId: JsonField = JsonMissing.of(), - @JsonProperty("AboutCvTermName") - @ExcludeMissing - aboutCvTermName: JsonField = JsonMissing.of(), - @JsonProperty("AboutCvTermRefinedAbout") - @ExcludeMissing - aboutCvTermRefinedAbout: JsonField = JsonMissing.of(), - @JsonProperty("AdditionalModelInformation") - @ExcludeMissing - additionalModelInformation: JsonField = JsonMissing.of(), - @JsonProperty("ApplicationRecordVersion") - @ExcludeMissing - applicationRecordVersion: JsonField = JsonMissing.of(), - @JsonProperty("Artist") @ExcludeMissing artist: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCircaDateCreated") - @ExcludeMissing - artworkCircaDateCreated: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkContentDescription") - @ExcludeMissing - artworkContentDescription: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkContributionDescription") - @ExcludeMissing - artworkContributionDescription: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCopyrightNotice") - @ExcludeMissing - artworkCopyrightNotice: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCopyrightOwnerID") - @ExcludeMissing - artworkCopyrightOwnerId: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCopyrightOwnerName") - @ExcludeMissing - artworkCopyrightOwnerName: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCreator") - @ExcludeMissing - artworkCreator: JsonField> = JsonMissing.of(), - @JsonProperty("ArtworkCreatorID") - @ExcludeMissing - artworkCreatorId: JsonField> = JsonMissing.of(), - @JsonProperty("ArtworkDateCreated") - @ExcludeMissing - artworkDateCreated: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkLicensorID") - @ExcludeMissing - artworkLicensorId: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkLicensorName") - @ExcludeMissing - artworkLicensorName: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkPhysicalDescription") - @ExcludeMissing - artworkPhysicalDescription: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkSource") - @ExcludeMissing - artworkSource: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkSourceInventoryNo") - @ExcludeMissing - artworkSourceInventoryNo: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkSourceInvURL") - @ExcludeMissing - artworkSourceInvUrl: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkStylePeriod") - @ExcludeMissing - artworkStylePeriod: JsonField> = JsonMissing.of(), - @JsonProperty("ArtworkTitle") - @ExcludeMissing - artworkTitle: JsonField = JsonMissing.of(), - @JsonProperty("AuthorsPosition") - @ExcludeMissing - authorsPosition: JsonField = JsonMissing.of(), - @JsonProperty("Byline") @ExcludeMissing byline: JsonField = JsonMissing.of(), - @JsonProperty("BylineTitle") - @ExcludeMissing - bylineTitle: JsonField = JsonMissing.of(), - @JsonProperty("Caption") @ExcludeMissing caption: JsonField = JsonMissing.of(), - @JsonProperty("CaptionAbstract") - @ExcludeMissing - captionAbstract: JsonField = JsonMissing.of(), - @JsonProperty("CaptionWriter") - @ExcludeMissing - captionWriter: JsonField = JsonMissing.of(), - @JsonProperty("City") @ExcludeMissing city: JsonField = JsonMissing.of(), - @JsonProperty("ColorSpace") - @ExcludeMissing - colorSpace: JsonField = JsonMissing.of(), - @JsonProperty("ComponentsConfiguration") - @ExcludeMissing - componentsConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("Copyright") - @ExcludeMissing - copyright: JsonField = JsonMissing.of(), - @JsonProperty("CopyrightNotice") - @ExcludeMissing - copyrightNotice: JsonField = JsonMissing.of(), - @JsonProperty("CopyrightOwnerID") - @ExcludeMissing - copyrightOwnerId: JsonField> = JsonMissing.of(), - @JsonProperty("CopyrightOwnerName") - @ExcludeMissing - copyrightOwnerName: JsonField> = JsonMissing.of(), - @JsonProperty("Country") @ExcludeMissing country: JsonField = JsonMissing.of(), - @JsonProperty("CountryCode") - @ExcludeMissing - countryCode: JsonField = JsonMissing.of(), - @JsonProperty("CountryPrimaryLocationCode") - @ExcludeMissing - countryPrimaryLocationCode: JsonField = JsonMissing.of(), - @JsonProperty("CountryPrimaryLocationName") - @ExcludeMissing - countryPrimaryLocationName: JsonField = JsonMissing.of(), - @JsonProperty("Creator") @ExcludeMissing creator: JsonField = JsonMissing.of(), - @JsonProperty("CreatorAddress") - @ExcludeMissing - creatorAddress: JsonField = JsonMissing.of(), - @JsonProperty("CreatorCity") - @ExcludeMissing - creatorCity: JsonField = JsonMissing.of(), - @JsonProperty("CreatorCountry") - @ExcludeMissing - creatorCountry: JsonField = JsonMissing.of(), - @JsonProperty("CreatorPostalCode") - @ExcludeMissing - creatorPostalCode: JsonField = JsonMissing.of(), - @JsonProperty("CreatorRegion") - @ExcludeMissing - creatorRegion: JsonField = JsonMissing.of(), - @JsonProperty("CreatorWorkEmail") - @ExcludeMissing - creatorWorkEmail: JsonField = JsonMissing.of(), - @JsonProperty("CreatorWorkTelephone") - @ExcludeMissing - creatorWorkTelephone: JsonField = JsonMissing.of(), - @JsonProperty("CreatorWorkURL") - @ExcludeMissing - creatorWorkUrl: JsonField = JsonMissing.of(), - @JsonProperty("Credit") @ExcludeMissing credit: JsonField = JsonMissing.of(), - @JsonProperty("DateCreated") - @ExcludeMissing - dateCreated: JsonField = JsonMissing.of(), - @JsonProperty("DateTimeCreated") - @ExcludeMissing - dateTimeCreated: JsonField = JsonMissing.of(), - @JsonProperty("DateTimeOriginal") - @ExcludeMissing - dateTimeOriginal: JsonField = JsonMissing.of(), - @JsonProperty("Description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("DigitalImageGUID") - @ExcludeMissing - digitalImageGuid: JsonField = JsonMissing.of(), - @JsonProperty("DigitalSourceType") - @ExcludeMissing - digitalSourceType: JsonField = JsonMissing.of(), - @JsonProperty("EmbeddedEncodedRightsExpr") - @ExcludeMissing - embeddedEncodedRightsExpr: JsonField = JsonMissing.of(), - @JsonProperty("EmbeddedEncodedRightsExprLangID") - @ExcludeMissing - embeddedEncodedRightsExprLangId: JsonField = JsonMissing.of(), - @JsonProperty("EmbeddedEncodedRightsExprType") - @ExcludeMissing - embeddedEncodedRightsExprType: JsonField = JsonMissing.of(), - @JsonProperty("Event") @ExcludeMissing event: JsonField = JsonMissing.of(), - @JsonProperty("ExifVersion") - @ExcludeMissing - exifVersion: JsonField = JsonMissing.of(), - @JsonProperty("FlashpixVersion") - @ExcludeMissing - flashpixVersion: JsonField = JsonMissing.of(), - @JsonProperty("GenreCvId") - @ExcludeMissing - genreCvId: JsonField = JsonMissing.of(), - @JsonProperty("GenreCvTermId") - @ExcludeMissing - genreCvTermId: JsonField = JsonMissing.of(), - @JsonProperty("GenreCvTermName") - @ExcludeMissing - genreCvTermName: JsonField = JsonMissing.of(), - @JsonProperty("GenreCvTermRefinedAbout") - @ExcludeMissing - genreCvTermRefinedAbout: JsonField = JsonMissing.of(), - @JsonProperty("Headline") - @ExcludeMissing - headline: JsonField = JsonMissing.of(), - @JsonProperty("ImageCreatorID") - @ExcludeMissing - imageCreatorId: JsonField = JsonMissing.of(), - @JsonProperty("ImageCreatorImageID") - @ExcludeMissing - imageCreatorImageId: JsonField = JsonMissing.of(), - @JsonProperty("ImageCreatorName") - @ExcludeMissing - imageCreatorName: JsonField = JsonMissing.of(), - @JsonProperty("ImageDescription") - @ExcludeMissing - imageDescription: JsonField = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryH") - @ExcludeMissing - imageRegionBoundaryH: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryRx") - @ExcludeMissing - imageRegionBoundaryRx: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryShape") - @ExcludeMissing - imageRegionBoundaryShape: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryUnit") - @ExcludeMissing - imageRegionBoundaryUnit: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryVerticesX") - @ExcludeMissing - imageRegionBoundaryVerticesX: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryVerticesY") - @ExcludeMissing - imageRegionBoundaryVerticesY: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryW") - @ExcludeMissing - imageRegionBoundaryW: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryX") - @ExcludeMissing - imageRegionBoundaryX: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryY") - @ExcludeMissing - imageRegionBoundaryY: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionCtypeIdentifier") - @ExcludeMissing - imageRegionCtypeIdentifier: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionCtypeName") - @ExcludeMissing - imageRegionCtypeName: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionID") - @ExcludeMissing - imageRegionId: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionName") - @ExcludeMissing - imageRegionName: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionOrganisationInImageName") - @ExcludeMissing - imageRegionOrganisationInImageName: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionPersonInImage") - @ExcludeMissing - imageRegionPersonInImage: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionRoleIdentifier") - @ExcludeMissing - imageRegionRoleIdentifier: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionRoleName") - @ExcludeMissing - imageRegionRoleName: JsonField> = JsonMissing.of(), - @JsonProperty("ImageSupplierID") - @ExcludeMissing - imageSupplierId: JsonField = JsonMissing.of(), - @JsonProperty("ImageSupplierImageID") - @ExcludeMissing - imageSupplierImageId: JsonField = JsonMissing.of(), - @JsonProperty("ImageSupplierName") - @ExcludeMissing - imageSupplierName: JsonField = JsonMissing.of(), - @JsonProperty("Instructions") - @ExcludeMissing - instructions: JsonField = JsonMissing.of(), - @JsonProperty("IntellectualGenre") - @ExcludeMissing - intellectualGenre: JsonField = JsonMissing.of(), - @JsonProperty("Keywords") - @ExcludeMissing - keywords: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorCity") - @ExcludeMissing - licensorCity: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorCountry") - @ExcludeMissing - licensorCountry: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorEmail") - @ExcludeMissing - licensorEmail: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorExtendedAddress") - @ExcludeMissing - licensorExtendedAddress: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorID") - @ExcludeMissing - licensorId: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorName") - @ExcludeMissing - licensorName: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorPostalCode") - @ExcludeMissing - licensorPostalCode: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorRegion") - @ExcludeMissing - licensorRegion: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorStreetAddress") - @ExcludeMissing - licensorStreetAddress: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorTelephone1") - @ExcludeMissing - licensorTelephone1: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorTelephone2") - @ExcludeMissing - licensorTelephone2: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorURL") - @ExcludeMissing - licensorUrl: JsonField> = JsonMissing.of(), - @JsonProperty("LinkedEncodedRightsExpr") - @ExcludeMissing - linkedEncodedRightsExpr: JsonField = JsonMissing.of(), - @JsonProperty("LinkedEncodedRightsExprLangID") - @ExcludeMissing - linkedEncodedRightsExprLangId: JsonField = JsonMissing.of(), - @JsonProperty("LinkedEncodedRightsExprType") - @ExcludeMissing - linkedEncodedRightsExprType: JsonField = JsonMissing.of(), - @JsonProperty("Location") - @ExcludeMissing - location: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedCity") - @ExcludeMissing - locationCreatedCity: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedCountryCode") - @ExcludeMissing - locationCreatedCountryCode: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedCountryName") - @ExcludeMissing - locationCreatedCountryName: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedGPSAltitude") - @ExcludeMissing - locationCreatedGpsAltitude: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedGPSLatitude") - @ExcludeMissing - locationCreatedGpsLatitude: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedGPSLongitude") - @ExcludeMissing - locationCreatedGpsLongitude: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedLocationId") - @ExcludeMissing - locationCreatedLocationId: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedLocationName") - @ExcludeMissing - locationCreatedLocationName: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedProvinceState") - @ExcludeMissing - locationCreatedProvinceState: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedSublocation") - @ExcludeMissing - locationCreatedSublocation: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedWorldRegion") - @ExcludeMissing - locationCreatedWorldRegion: JsonField = JsonMissing.of(), - @JsonProperty("LocationShownCity") - @ExcludeMissing - locationShownCity: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownCountryCode") - @ExcludeMissing - locationShownCountryCode: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownCountryName") - @ExcludeMissing - locationShownCountryName: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownGPSAltitude") - @ExcludeMissing - locationShownGpsAltitude: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownGPSLatitude") - @ExcludeMissing - locationShownGpsLatitude: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownGPSLongitude") - @ExcludeMissing - locationShownGpsLongitude: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownLocationId") - @ExcludeMissing - locationShownLocationId: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownLocationName") - @ExcludeMissing - locationShownLocationName: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownProvinceState") - @ExcludeMissing - locationShownProvinceState: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownSublocation") - @ExcludeMissing - locationShownSublocation: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownWorldRegion") - @ExcludeMissing - locationShownWorldRegion: JsonField> = JsonMissing.of(), - @JsonProperty("MaxAvailHeight") - @ExcludeMissing - maxAvailHeight: JsonField = JsonMissing.of(), - @JsonProperty("MaxAvailWidth") - @ExcludeMissing - maxAvailWidth: JsonField = JsonMissing.of(), - @JsonProperty("ModelAge") - @ExcludeMissing - modelAge: JsonField> = JsonMissing.of(), - @JsonProperty("ModelReleaseID") - @ExcludeMissing - modelReleaseId: JsonField> = JsonMissing.of(), - @JsonProperty("ObjectAttributeReference") - @ExcludeMissing - objectAttributeReference: JsonField = JsonMissing.of(), - @JsonProperty("ObjectName") - @ExcludeMissing - objectName: JsonField = JsonMissing.of(), - @JsonProperty("OffsetTimeOriginal") - @ExcludeMissing - offsetTimeOriginal: JsonField = JsonMissing.of(), - @JsonProperty("OrganisationInImageCode") - @ExcludeMissing - organisationInImageCode: JsonField> = JsonMissing.of(), - @JsonProperty("OrganisationInImageName") - @ExcludeMissing - organisationInImageName: JsonField> = JsonMissing.of(), - @JsonProperty("Orientation") - @ExcludeMissing - orientation: JsonField = JsonMissing.of(), - @JsonProperty("OriginalTransmissionReference") - @ExcludeMissing - originalTransmissionReference: JsonField = JsonMissing.of(), - @JsonProperty("PersonInImage") - @ExcludeMissing - personInImage: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageCvTermCvId") - @ExcludeMissing - personInImageCvTermCvId: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageCvTermId") - @ExcludeMissing - personInImageCvTermId: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageCvTermName") - @ExcludeMissing - personInImageCvTermName: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageCvTermRefinedAbout") - @ExcludeMissing - personInImageCvTermRefinedAbout: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageDescription") - @ExcludeMissing - personInImageDescription: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageId") - @ExcludeMissing - personInImageId: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageName") - @ExcludeMissing - personInImageName: JsonField> = JsonMissing.of(), - @JsonProperty("ProductInImageDescription") - @ExcludeMissing - productInImageDescription: JsonField> = JsonMissing.of(), - @JsonProperty("ProductInImageGTIN") - @ExcludeMissing - productInImageGtin: JsonField> = JsonMissing.of(), - @JsonProperty("ProductInImageName") - @ExcludeMissing - productInImageName: JsonField> = JsonMissing.of(), - @JsonProperty("PropertyReleaseID") - @ExcludeMissing - propertyReleaseId: JsonField> = JsonMissing.of(), - @JsonProperty("ProvinceState") - @ExcludeMissing - provinceState: JsonField = JsonMissing.of(), - @JsonProperty("Rating") @ExcludeMissing rating: JsonField = JsonMissing.of(), - @JsonProperty("RegistryEntryRole") - @ExcludeMissing - registryEntryRole: JsonField> = JsonMissing.of(), - @JsonProperty("RegistryItemID") - @ExcludeMissing - registryItemId: JsonField> = JsonMissing.of(), - @JsonProperty("RegistryOrganisationID") - @ExcludeMissing - registryOrganisationId: JsonField> = JsonMissing.of(), - @JsonProperty("ResolutionUnit") - @ExcludeMissing - resolutionUnit: JsonField = JsonMissing.of(), - @JsonProperty("Rights") @ExcludeMissing rights: JsonField = JsonMissing.of(), - @JsonProperty("Scene") - @ExcludeMissing - scene: JsonField> = JsonMissing.of(), - @JsonProperty("Source") @ExcludeMissing source: JsonField = JsonMissing.of(), - @JsonProperty("SpecialInstructions") - @ExcludeMissing - specialInstructions: JsonField = JsonMissing.of(), - @JsonProperty("State") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("Subject") - @ExcludeMissing - subject: JsonField> = JsonMissing.of(), - @JsonProperty("SubjectCode") - @ExcludeMissing - subjectCode: JsonField> = JsonMissing.of(), - @JsonProperty("SubjectReference") - @ExcludeMissing - subjectReference: JsonField> = JsonMissing.of(), - @JsonProperty("Sublocation") - @ExcludeMissing - sublocation: JsonField = JsonMissing.of(), - @JsonProperty("TimeCreated") - @ExcludeMissing - timeCreated: JsonField = JsonMissing.of(), - @JsonProperty("Title") @ExcludeMissing title: JsonField = JsonMissing.of(), - @JsonProperty("TransmissionReference") - @ExcludeMissing - transmissionReference: JsonField = JsonMissing.of(), - @JsonProperty("UsageTerms") - @ExcludeMissing - usageTerms: JsonField = JsonMissing.of(), - @JsonProperty("WebStatement") - @ExcludeMissing - webStatement: JsonField = JsonMissing.of(), - @JsonProperty("Writer") @ExcludeMissing writer: JsonField = JsonMissing.of(), - @JsonProperty("WriterEditor") - @ExcludeMissing - writerEditor: JsonField = JsonMissing.of(), - @JsonProperty("XResolution") - @ExcludeMissing - xResolution: JsonField = JsonMissing.of(), - @JsonProperty("YResolution") - @ExcludeMissing - yResolution: JsonField = JsonMissing.of(), - ) : this( - aboutCvTermCvId, - aboutCvTermId, - aboutCvTermName, - aboutCvTermRefinedAbout, - additionalModelInformation, - applicationRecordVersion, - artist, - artworkCircaDateCreated, - artworkContentDescription, - artworkContributionDescription, - artworkCopyrightNotice, - artworkCopyrightOwnerId, - artworkCopyrightOwnerName, - artworkCreator, - artworkCreatorId, - artworkDateCreated, - artworkLicensorId, - artworkLicensorName, - artworkPhysicalDescription, - artworkSource, - artworkSourceInventoryNo, - artworkSourceInvUrl, - artworkStylePeriod, - artworkTitle, - authorsPosition, - byline, - bylineTitle, - caption, - captionAbstract, - captionWriter, - city, - colorSpace, - componentsConfiguration, - copyright, - copyrightNotice, - copyrightOwnerId, - copyrightOwnerName, - country, - countryCode, - countryPrimaryLocationCode, - countryPrimaryLocationName, - creator, - creatorAddress, - creatorCity, - creatorCountry, - creatorPostalCode, - creatorRegion, - creatorWorkEmail, - creatorWorkTelephone, - creatorWorkUrl, - credit, - dateCreated, - dateTimeCreated, - dateTimeOriginal, - description, - digitalImageGuid, - digitalSourceType, - embeddedEncodedRightsExpr, - embeddedEncodedRightsExprLangId, - embeddedEncodedRightsExprType, - event, - exifVersion, - flashpixVersion, - genreCvId, - genreCvTermId, - genreCvTermName, - genreCvTermRefinedAbout, - headline, - imageCreatorId, - imageCreatorImageId, - imageCreatorName, - imageDescription, - imageRegionBoundaryH, - imageRegionBoundaryRx, - imageRegionBoundaryShape, - imageRegionBoundaryUnit, - imageRegionBoundaryVerticesX, - imageRegionBoundaryVerticesY, - imageRegionBoundaryW, - imageRegionBoundaryX, - imageRegionBoundaryY, - imageRegionCtypeIdentifier, - imageRegionCtypeName, - imageRegionId, - imageRegionName, - imageRegionOrganisationInImageName, - imageRegionPersonInImage, - imageRegionRoleIdentifier, - imageRegionRoleName, - imageSupplierId, - imageSupplierImageId, - imageSupplierName, - instructions, - intellectualGenre, - keywords, - licensorCity, - licensorCountry, - licensorEmail, - licensorExtendedAddress, - licensorId, - licensorName, - licensorPostalCode, - licensorRegion, - licensorStreetAddress, - licensorTelephone1, - licensorTelephone2, - licensorUrl, - linkedEncodedRightsExpr, - linkedEncodedRightsExprLangId, - linkedEncodedRightsExprType, - location, - locationCreatedCity, - locationCreatedCountryCode, - locationCreatedCountryName, - locationCreatedGpsAltitude, - locationCreatedGpsLatitude, - locationCreatedGpsLongitude, - locationCreatedLocationId, - locationCreatedLocationName, - locationCreatedProvinceState, - locationCreatedSublocation, - locationCreatedWorldRegion, - locationShownCity, - locationShownCountryCode, - locationShownCountryName, - locationShownGpsAltitude, - locationShownGpsLatitude, - locationShownGpsLongitude, - locationShownLocationId, - locationShownLocationName, - locationShownProvinceState, - locationShownSublocation, - locationShownWorldRegion, - maxAvailHeight, - maxAvailWidth, - modelAge, - modelReleaseId, - objectAttributeReference, - objectName, - offsetTimeOriginal, - organisationInImageCode, - organisationInImageName, - orientation, - originalTransmissionReference, - personInImage, - personInImageCvTermCvId, - personInImageCvTermId, - personInImageCvTermName, - personInImageCvTermRefinedAbout, - personInImageDescription, - personInImageId, - personInImageName, - productInImageDescription, - productInImageGtin, - productInImageName, - propertyReleaseId, - provinceState, - rating, - registryEntryRole, - registryItemId, - registryOrganisationId, - resolutionUnit, - rights, - scene, - source, - specialInstructions, - state, - subject, - subjectCode, - subjectReference, - sublocation, - timeCreated, - title, - transmissionReference, - usageTerms, - webStatement, - writer, - writerEditor, - xResolution, - yResolution, - mutableMapOf(), - ) - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun aboutCvTermCvId(): Optional = aboutCvTermCvId.getOptional("AboutCvTermCvId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun aboutCvTermId(): Optional = aboutCvTermId.getOptional("AboutCvTermId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun aboutCvTermName(): Optional = aboutCvTermName.getOptional("AboutCvTermName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun aboutCvTermRefinedAbout(): Optional = - aboutCvTermRefinedAbout.getOptional("AboutCvTermRefinedAbout") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun additionalModelInformation(): Optional = - additionalModelInformation.getOptional("AdditionalModelInformation") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicationRecordVersion(): Optional = - applicationRecordVersion.getOptional("ApplicationRecordVersion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artist(): Optional = artist.getOptional("Artist") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCircaDateCreated(): Optional = - artworkCircaDateCreated.getOptional("ArtworkCircaDateCreated") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkContentDescription(): Optional = - artworkContentDescription.getOptional("ArtworkContentDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkContributionDescription(): Optional = - artworkContributionDescription.getOptional("ArtworkContributionDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCopyrightNotice(): Optional = - artworkCopyrightNotice.getOptional("ArtworkCopyrightNotice") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCopyrightOwnerId(): Optional = - artworkCopyrightOwnerId.getOptional("ArtworkCopyrightOwnerID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCopyrightOwnerName(): Optional = - artworkCopyrightOwnerName.getOptional("ArtworkCopyrightOwnerName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCreator(): Optional> = artworkCreator.getOptional("ArtworkCreator") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCreatorId(): Optional> = - artworkCreatorId.getOptional("ArtworkCreatorID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkDateCreated(): Optional = - artworkDateCreated.getOptional("ArtworkDateCreated") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkLicensorId(): Optional = - artworkLicensorId.getOptional("ArtworkLicensorID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkLicensorName(): Optional = - artworkLicensorName.getOptional("ArtworkLicensorName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkPhysicalDescription(): Optional = - artworkPhysicalDescription.getOptional("ArtworkPhysicalDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkSource(): Optional = artworkSource.getOptional("ArtworkSource") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkSourceInventoryNo(): Optional = - artworkSourceInventoryNo.getOptional("ArtworkSourceInventoryNo") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkSourceInvUrl(): Optional = - artworkSourceInvUrl.getOptional("ArtworkSourceInvURL") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkStylePeriod(): Optional> = - artworkStylePeriod.getOptional("ArtworkStylePeriod") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkTitle(): Optional = artworkTitle.getOptional("ArtworkTitle") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun authorsPosition(): Optional = authorsPosition.getOptional("AuthorsPosition") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun byline(): Optional = byline.getOptional("Byline") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun bylineTitle(): Optional = bylineTitle.getOptional("BylineTitle") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun caption(): Optional = caption.getOptional("Caption") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun captionAbstract(): Optional = captionAbstract.getOptional("CaptionAbstract") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun captionWriter(): Optional = captionWriter.getOptional("CaptionWriter") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun city(): Optional = city.getOptional("City") - - /** - * @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 componentsConfiguration(): Optional = - componentsConfiguration.getOptional("ComponentsConfiguration") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun copyright(): Optional = copyright.getOptional("Copyright") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun copyrightNotice(): Optional = copyrightNotice.getOptional("CopyrightNotice") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun copyrightOwnerId(): Optional> = - copyrightOwnerId.getOptional("CopyrightOwnerID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun copyrightOwnerName(): Optional> = - copyrightOwnerName.getOptional("CopyrightOwnerName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun country(): Optional = country.getOptional("Country") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun countryCode(): Optional = countryCode.getOptional("CountryCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun countryPrimaryLocationCode(): Optional = - countryPrimaryLocationCode.getOptional("CountryPrimaryLocationCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun countryPrimaryLocationName(): Optional = - countryPrimaryLocationName.getOptional("CountryPrimaryLocationName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creator(): Optional = creator.getOptional("Creator") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorAddress(): Optional = creatorAddress.getOptional("CreatorAddress") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorCity(): Optional = creatorCity.getOptional("CreatorCity") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorCountry(): Optional = creatorCountry.getOptional("CreatorCountry") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorPostalCode(): Optional = - creatorPostalCode.getOptional("CreatorPostalCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorRegion(): Optional = creatorRegion.getOptional("CreatorRegion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorWorkEmail(): Optional = creatorWorkEmail.getOptional("CreatorWorkEmail") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorWorkTelephone(): Optional = - creatorWorkTelephone.getOptional("CreatorWorkTelephone") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorWorkUrl(): Optional = creatorWorkUrl.getOptional("CreatorWorkURL") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun credit(): Optional = credit.getOptional("Credit") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dateCreated(): Optional = dateCreated.getOptional("DateCreated") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dateTimeCreated(): Optional = - dateTimeCreated.getOptional("DateTimeCreated") - - /** - * @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 description(): Optional = description.getOptional("Description") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun digitalImageGuid(): Optional = digitalImageGuid.getOptional("DigitalImageGUID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun digitalSourceType(): Optional = - digitalSourceType.getOptional("DigitalSourceType") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun embeddedEncodedRightsExpr(): Optional = - embeddedEncodedRightsExpr.getOptional("EmbeddedEncodedRightsExpr") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun embeddedEncodedRightsExprLangId(): Optional = - embeddedEncodedRightsExprLangId.getOptional("EmbeddedEncodedRightsExprLangID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun embeddedEncodedRightsExprType(): Optional = - embeddedEncodedRightsExprType.getOptional("EmbeddedEncodedRightsExprType") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun event(): Optional = event.getOptional("Event") - - /** - * @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 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 genreCvId(): Optional = genreCvId.getOptional("GenreCvId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun genreCvTermId(): Optional = genreCvTermId.getOptional("GenreCvTermId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun genreCvTermName(): Optional = genreCvTermName.getOptional("GenreCvTermName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun genreCvTermRefinedAbout(): Optional = - genreCvTermRefinedAbout.getOptional("GenreCvTermRefinedAbout") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun headline(): Optional = headline.getOptional("Headline") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageCreatorId(): Optional = imageCreatorId.getOptional("ImageCreatorID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageCreatorImageId(): Optional = - imageCreatorImageId.getOptional("ImageCreatorImageID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageCreatorName(): Optional = imageCreatorName.getOptional("ImageCreatorName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageDescription(): Optional = imageDescription.getOptional("ImageDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryH(): Optional> = - imageRegionBoundaryH.getOptional("ImageRegionBoundaryH") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryRx(): Optional> = - imageRegionBoundaryRx.getOptional("ImageRegionBoundaryRx") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryShape(): Optional> = - imageRegionBoundaryShape.getOptional("ImageRegionBoundaryShape") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryUnit(): Optional> = - imageRegionBoundaryUnit.getOptional("ImageRegionBoundaryUnit") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryVerticesX(): Optional> = - imageRegionBoundaryVerticesX.getOptional("ImageRegionBoundaryVerticesX") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryVerticesY(): Optional> = - imageRegionBoundaryVerticesY.getOptional("ImageRegionBoundaryVerticesY") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryW(): Optional> = - imageRegionBoundaryW.getOptional("ImageRegionBoundaryW") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryX(): Optional> = - imageRegionBoundaryX.getOptional("ImageRegionBoundaryX") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryY(): Optional> = - imageRegionBoundaryY.getOptional("ImageRegionBoundaryY") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionCtypeIdentifier(): Optional> = - imageRegionCtypeIdentifier.getOptional("ImageRegionCtypeIdentifier") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionCtypeName(): Optional> = - imageRegionCtypeName.getOptional("ImageRegionCtypeName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionId(): Optional> = imageRegionId.getOptional("ImageRegionID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionName(): Optional> = - imageRegionName.getOptional("ImageRegionName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionOrganisationInImageName(): Optional> = - imageRegionOrganisationInImageName.getOptional("ImageRegionOrganisationInImageName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionPersonInImage(): Optional> = - imageRegionPersonInImage.getOptional("ImageRegionPersonInImage") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionRoleIdentifier(): Optional> = - imageRegionRoleIdentifier.getOptional("ImageRegionRoleIdentifier") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionRoleName(): Optional> = - imageRegionRoleName.getOptional("ImageRegionRoleName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageSupplierId(): Optional = imageSupplierId.getOptional("ImageSupplierID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageSupplierImageId(): Optional = - imageSupplierImageId.getOptional("ImageSupplierImageID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageSupplierName(): Optional = - imageSupplierName.getOptional("ImageSupplierName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun instructions(): Optional = instructions.getOptional("Instructions") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun intellectualGenre(): Optional = - intellectualGenre.getOptional("IntellectualGenre") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun keywords(): Optional> = keywords.getOptional("Keywords") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorCity(): Optional> = licensorCity.getOptional("LicensorCity") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorCountry(): Optional> = - licensorCountry.getOptional("LicensorCountry") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorEmail(): Optional> = licensorEmail.getOptional("LicensorEmail") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorExtendedAddress(): Optional> = - licensorExtendedAddress.getOptional("LicensorExtendedAddress") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorId(): Optional> = licensorId.getOptional("LicensorID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorName(): Optional> = licensorName.getOptional("LicensorName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorPostalCode(): Optional> = - licensorPostalCode.getOptional("LicensorPostalCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorRegion(): Optional> = licensorRegion.getOptional("LicensorRegion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorStreetAddress(): Optional> = - licensorStreetAddress.getOptional("LicensorStreetAddress") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorTelephone1(): Optional> = - licensorTelephone1.getOptional("LicensorTelephone1") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorTelephone2(): Optional> = - licensorTelephone2.getOptional("LicensorTelephone2") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorUrl(): Optional> = licensorUrl.getOptional("LicensorURL") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun linkedEncodedRightsExpr(): Optional = - linkedEncodedRightsExpr.getOptional("LinkedEncodedRightsExpr") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun linkedEncodedRightsExprLangId(): Optional = - linkedEncodedRightsExprLangId.getOptional("LinkedEncodedRightsExprLangID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun linkedEncodedRightsExprType(): Optional = - linkedEncodedRightsExprType.getOptional("LinkedEncodedRightsExprType") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun location(): Optional = location.getOptional("Location") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedCity(): Optional = - locationCreatedCity.getOptional("LocationCreatedCity") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedCountryCode(): Optional = - locationCreatedCountryCode.getOptional("LocationCreatedCountryCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedCountryName(): Optional = - locationCreatedCountryName.getOptional("LocationCreatedCountryName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedGpsAltitude(): Optional = - locationCreatedGpsAltitude.getOptional("LocationCreatedGPSAltitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedGpsLatitude(): Optional = - locationCreatedGpsLatitude.getOptional("LocationCreatedGPSLatitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedGpsLongitude(): Optional = - locationCreatedGpsLongitude.getOptional("LocationCreatedGPSLongitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedLocationId(): Optional = - locationCreatedLocationId.getOptional("LocationCreatedLocationId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedLocationName(): Optional = - locationCreatedLocationName.getOptional("LocationCreatedLocationName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedProvinceState(): Optional = - locationCreatedProvinceState.getOptional("LocationCreatedProvinceState") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedSublocation(): Optional = - locationCreatedSublocation.getOptional("LocationCreatedSublocation") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedWorldRegion(): Optional = - locationCreatedWorldRegion.getOptional("LocationCreatedWorldRegion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownCity(): Optional> = - locationShownCity.getOptional("LocationShownCity") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownCountryCode(): Optional> = - locationShownCountryCode.getOptional("LocationShownCountryCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownCountryName(): Optional> = - locationShownCountryName.getOptional("LocationShownCountryName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownGpsAltitude(): Optional> = - locationShownGpsAltitude.getOptional("LocationShownGPSAltitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownGpsLatitude(): Optional> = - locationShownGpsLatitude.getOptional("LocationShownGPSLatitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownGpsLongitude(): Optional> = - locationShownGpsLongitude.getOptional("LocationShownGPSLongitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownLocationId(): Optional> = - locationShownLocationId.getOptional("LocationShownLocationId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownLocationName(): Optional> = - locationShownLocationName.getOptional("LocationShownLocationName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownProvinceState(): Optional> = - locationShownProvinceState.getOptional("LocationShownProvinceState") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownSublocation(): Optional> = - locationShownSublocation.getOptional("LocationShownSublocation") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownWorldRegion(): Optional> = - locationShownWorldRegion.getOptional("LocationShownWorldRegion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun maxAvailHeight(): Optional = maxAvailHeight.getOptional("MaxAvailHeight") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun maxAvailWidth(): Optional = maxAvailWidth.getOptional("MaxAvailWidth") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun modelAge(): Optional> = modelAge.getOptional("ModelAge") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun modelReleaseId(): Optional> = modelReleaseId.getOptional("ModelReleaseID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun objectAttributeReference(): Optional = - objectAttributeReference.getOptional("ObjectAttributeReference") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun objectName(): Optional = objectName.getOptional("ObjectName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun offsetTimeOriginal(): Optional = - offsetTimeOriginal.getOptional("OffsetTimeOriginal") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun organisationInImageCode(): Optional> = - organisationInImageCode.getOptional("OrganisationInImageCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun organisationInImageName(): Optional> = - organisationInImageName.getOptional("OrganisationInImageName") - - /** - * @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 originalTransmissionReference(): Optional = - originalTransmissionReference.getOptional("OriginalTransmissionReference") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImage(): Optional> = personInImage.getOptional("PersonInImage") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageCvTermCvId(): Optional> = - personInImageCvTermCvId.getOptional("PersonInImageCvTermCvId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageCvTermId(): Optional> = - personInImageCvTermId.getOptional("PersonInImageCvTermId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageCvTermName(): Optional> = - personInImageCvTermName.getOptional("PersonInImageCvTermName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageCvTermRefinedAbout(): Optional> = - personInImageCvTermRefinedAbout.getOptional("PersonInImageCvTermRefinedAbout") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageDescription(): Optional> = - personInImageDescription.getOptional("PersonInImageDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageId(): Optional> = - personInImageId.getOptional("PersonInImageId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageName(): Optional> = - personInImageName.getOptional("PersonInImageName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productInImageDescription(): Optional> = - productInImageDescription.getOptional("ProductInImageDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productInImageGtin(): Optional> = - productInImageGtin.getOptional("ProductInImageGTIN") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productInImageName(): Optional> = - productInImageName.getOptional("ProductInImageName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun propertyReleaseId(): Optional> = - propertyReleaseId.getOptional("PropertyReleaseID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun provinceState(): Optional = provinceState.getOptional("ProvinceState") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rating(): Optional = rating.getOptional("Rating") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun registryEntryRole(): Optional> = - registryEntryRole.getOptional("RegistryEntryRole") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun registryItemId(): Optional> = registryItemId.getOptional("RegistryItemID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun registryOrganisationId(): Optional> = - registryOrganisationId.getOptional("RegistryOrganisationID") - - /** - * @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 rights(): Optional = rights.getOptional("Rights") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun scene(): Optional> = scene.getOptional("Scene") - - /** - * @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") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun specialInstructions(): Optional = - specialInstructions.getOptional("SpecialInstructions") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun state(): Optional = state.getOptional("State") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subject(): Optional> = subject.getOptional("Subject") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subjectCode(): Optional> = subjectCode.getOptional("SubjectCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subjectReference(): Optional> = - subjectReference.getOptional("SubjectReference") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun sublocation(): Optional = sublocation.getOptional("Sublocation") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun timeCreated(): Optional = timeCreated.getOptional("TimeCreated") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun title(): Optional = title.getOptional("Title") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun transmissionReference(): Optional = - transmissionReference.getOptional("TransmissionReference") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun usageTerms(): Optional = usageTerms.getOptional("UsageTerms") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webStatement(): Optional = webStatement.getOptional("WebStatement") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun writer(): Optional = writer.getOptional("Writer") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun writerEditor(): Optional = writerEditor.getOptional("WriterEditor") - - /** - * @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 [aboutCvTermCvId]. - * - * Unlike [aboutCvTermCvId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("AboutCvTermCvId") - @ExcludeMissing - fun _aboutCvTermCvId(): JsonField = aboutCvTermCvId - - /** - * Returns the raw JSON value of [aboutCvTermId]. - * - * Unlike [aboutCvTermId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("AboutCvTermId") - @ExcludeMissing - fun _aboutCvTermId(): JsonField = aboutCvTermId - - /** - * Returns the raw JSON value of [aboutCvTermName]. - * - * Unlike [aboutCvTermName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("AboutCvTermName") - @ExcludeMissing - fun _aboutCvTermName(): JsonField = aboutCvTermName - - /** - * Returns the raw JSON value of [aboutCvTermRefinedAbout]. - * - * Unlike [aboutCvTermRefinedAbout], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("AboutCvTermRefinedAbout") - @ExcludeMissing - fun _aboutCvTermRefinedAbout(): JsonField = aboutCvTermRefinedAbout - - /** - * Returns the raw JSON value of [additionalModelInformation]. - * - * Unlike [additionalModelInformation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("AdditionalModelInformation") - @ExcludeMissing - fun _additionalModelInformation(): JsonField = additionalModelInformation - - /** - * Returns the raw JSON value of [applicationRecordVersion]. - * - * Unlike [applicationRecordVersion], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ApplicationRecordVersion") - @ExcludeMissing - fun _applicationRecordVersion(): JsonField = applicationRecordVersion - - /** - * Returns the raw JSON value of [artist]. - * - * Unlike [artist], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Artist") @ExcludeMissing fun _artist(): JsonField = artist - - /** - * Returns the raw JSON value of [artworkCircaDateCreated]. - * - * Unlike [artworkCircaDateCreated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkCircaDateCreated") - @ExcludeMissing - fun _artworkCircaDateCreated(): JsonField = artworkCircaDateCreated - - /** - * Returns the raw JSON value of [artworkContentDescription]. - * - * Unlike [artworkContentDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkContentDescription") - @ExcludeMissing - fun _artworkContentDescription(): JsonField = artworkContentDescription - - /** - * Returns the raw JSON value of [artworkContributionDescription]. - * - * Unlike [artworkContributionDescription], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("ArtworkContributionDescription") - @ExcludeMissing - fun _artworkContributionDescription(): JsonField = artworkContributionDescription - - /** - * Returns the raw JSON value of [artworkCopyrightNotice]. - * - * Unlike [artworkCopyrightNotice], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkCopyrightNotice") - @ExcludeMissing - fun _artworkCopyrightNotice(): JsonField = artworkCopyrightNotice - - /** - * Returns the raw JSON value of [artworkCopyrightOwnerId]. - * - * Unlike [artworkCopyrightOwnerId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkCopyrightOwnerID") - @ExcludeMissing - fun _artworkCopyrightOwnerId(): JsonField = artworkCopyrightOwnerId - - /** - * Returns the raw JSON value of [artworkCopyrightOwnerName]. - * - * Unlike [artworkCopyrightOwnerName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkCopyrightOwnerName") - @ExcludeMissing - fun _artworkCopyrightOwnerName(): JsonField = artworkCopyrightOwnerName - - /** - * Returns the raw JSON value of [artworkCreator]. - * - * Unlike [artworkCreator], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkCreator") - @ExcludeMissing - fun _artworkCreator(): JsonField> = artworkCreator - - /** - * Returns the raw JSON value of [artworkCreatorId]. - * - * Unlike [artworkCreatorId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkCreatorID") - @ExcludeMissing - fun _artworkCreatorId(): JsonField> = artworkCreatorId - - /** - * Returns the raw JSON value of [artworkDateCreated]. - * - * Unlike [artworkDateCreated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkDateCreated") - @ExcludeMissing - fun _artworkDateCreated(): JsonField = artworkDateCreated - - /** - * Returns the raw JSON value of [artworkLicensorId]. - * - * Unlike [artworkLicensorId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkLicensorID") - @ExcludeMissing - fun _artworkLicensorId(): JsonField = artworkLicensorId - - /** - * Returns the raw JSON value of [artworkLicensorName]. - * - * Unlike [artworkLicensorName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkLicensorName") - @ExcludeMissing - fun _artworkLicensorName(): JsonField = artworkLicensorName - - /** - * Returns the raw JSON value of [artworkPhysicalDescription]. - * - * Unlike [artworkPhysicalDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkPhysicalDescription") - @ExcludeMissing - fun _artworkPhysicalDescription(): JsonField = artworkPhysicalDescription - - /** - * Returns the raw JSON value of [artworkSource]. - * - * Unlike [artworkSource], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkSource") - @ExcludeMissing - fun _artworkSource(): JsonField = artworkSource - - /** - * Returns the raw JSON value of [artworkSourceInventoryNo]. - * - * Unlike [artworkSourceInventoryNo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkSourceInventoryNo") - @ExcludeMissing - fun _artworkSourceInventoryNo(): JsonField = artworkSourceInventoryNo - - /** - * Returns the raw JSON value of [artworkSourceInvUrl]. - * - * Unlike [artworkSourceInvUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkSourceInvURL") - @ExcludeMissing - fun _artworkSourceInvUrl(): JsonField = artworkSourceInvUrl - - /** - * Returns the raw JSON value of [artworkStylePeriod]. - * - * Unlike [artworkStylePeriod], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkStylePeriod") - @ExcludeMissing - fun _artworkStylePeriod(): JsonField> = artworkStylePeriod - - /** - * Returns the raw JSON value of [artworkTitle]. - * - * Unlike [artworkTitle], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkTitle") - @ExcludeMissing - fun _artworkTitle(): JsonField = artworkTitle - - /** - * Returns the raw JSON value of [authorsPosition]. - * - * Unlike [authorsPosition], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("AuthorsPosition") - @ExcludeMissing - fun _authorsPosition(): JsonField = authorsPosition - - /** - * Returns the raw JSON value of [byline]. - * - * Unlike [byline], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Byline") @ExcludeMissing fun _byline(): JsonField = byline - - /** - * Returns the raw JSON value of [bylineTitle]. - * - * Unlike [bylineTitle], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("BylineTitle") - @ExcludeMissing - fun _bylineTitle(): JsonField = bylineTitle - - /** - * Returns the raw JSON value of [caption]. - * - * Unlike [caption], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Caption") @ExcludeMissing fun _caption(): JsonField = caption - - /** - * Returns the raw JSON value of [captionAbstract]. - * - * Unlike [captionAbstract], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CaptionAbstract") - @ExcludeMissing - fun _captionAbstract(): JsonField = captionAbstract - - /** - * Returns the raw JSON value of [captionWriter]. - * - * Unlike [captionWriter], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CaptionWriter") - @ExcludeMissing - fun _captionWriter(): JsonField = captionWriter - - /** - * Returns the raw JSON value of [city]. - * - * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("City") @ExcludeMissing fun _city(): JsonField = city - - /** - * 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 [componentsConfiguration]. - * - * Unlike [componentsConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ComponentsConfiguration") - @ExcludeMissing - fun _componentsConfiguration(): JsonField = componentsConfiguration - - /** - * Returns the raw JSON value of [copyright]. - * - * Unlike [copyright], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Copyright") @ExcludeMissing fun _copyright(): JsonField = copyright - - /** - * Returns the raw JSON value of [copyrightNotice]. - * - * Unlike [copyrightNotice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CopyrightNotice") - @ExcludeMissing - fun _copyrightNotice(): JsonField = copyrightNotice - - /** - * Returns the raw JSON value of [copyrightOwnerId]. - * - * Unlike [copyrightOwnerId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CopyrightOwnerID") - @ExcludeMissing - fun _copyrightOwnerId(): JsonField> = copyrightOwnerId - - /** - * Returns the raw JSON value of [copyrightOwnerName]. - * - * Unlike [copyrightOwnerName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("CopyrightOwnerName") - @ExcludeMissing - fun _copyrightOwnerName(): JsonField> = copyrightOwnerName - - /** - * Returns the raw JSON value of [country]. - * - * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Country") @ExcludeMissing fun _country(): JsonField = country - - /** - * Returns the raw JSON value of [countryCode]. - * - * Unlike [countryCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("CountryCode") - @ExcludeMissing - fun _countryCode(): JsonField = countryCode - - /** - * Returns the raw JSON value of [countryPrimaryLocationCode]. - * - * Unlike [countryPrimaryLocationCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("CountryPrimaryLocationCode") - @ExcludeMissing - fun _countryPrimaryLocationCode(): JsonField = countryPrimaryLocationCode - - /** - * Returns the raw JSON value of [countryPrimaryLocationName]. - * - * Unlike [countryPrimaryLocationName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("CountryPrimaryLocationName") - @ExcludeMissing - fun _countryPrimaryLocationName(): JsonField = countryPrimaryLocationName - - /** - * Returns the raw JSON value of [creator]. - * - * Unlike [creator], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Creator") @ExcludeMissing fun _creator(): JsonField = creator - - /** - * Returns the raw JSON value of [creatorAddress]. - * - * Unlike [creatorAddress], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorAddress") - @ExcludeMissing - fun _creatorAddress(): JsonField = creatorAddress - - /** - * Returns the raw JSON value of [creatorCity]. - * - * Unlike [creatorCity], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("CreatorCity") - @ExcludeMissing - fun _creatorCity(): JsonField = creatorCity - - /** - * Returns the raw JSON value of [creatorCountry]. - * - * Unlike [creatorCountry], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorCountry") - @ExcludeMissing - fun _creatorCountry(): JsonField = creatorCountry - - /** - * Returns the raw JSON value of [creatorPostalCode]. - * - * Unlike [creatorPostalCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorPostalCode") - @ExcludeMissing - fun _creatorPostalCode(): JsonField = creatorPostalCode - - /** - * Returns the raw JSON value of [creatorRegion]. - * - * Unlike [creatorRegion], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorRegion") - @ExcludeMissing - fun _creatorRegion(): JsonField = creatorRegion - - /** - * Returns the raw JSON value of [creatorWorkEmail]. - * - * Unlike [creatorWorkEmail], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorWorkEmail") - @ExcludeMissing - fun _creatorWorkEmail(): JsonField = creatorWorkEmail - - /** - * Returns the raw JSON value of [creatorWorkTelephone]. - * - * Unlike [creatorWorkTelephone], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("CreatorWorkTelephone") - @ExcludeMissing - fun _creatorWorkTelephone(): JsonField = creatorWorkTelephone - - /** - * Returns the raw JSON value of [creatorWorkUrl]. - * - * Unlike [creatorWorkUrl], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorWorkURL") - @ExcludeMissing - fun _creatorWorkUrl(): JsonField = creatorWorkUrl - - /** - * Returns the raw JSON value of [credit]. - * - * Unlike [credit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Credit") @ExcludeMissing fun _credit(): JsonField = credit - - /** - * Returns the raw JSON value of [dateCreated]. - * - * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("DateCreated") - @ExcludeMissing - fun _dateCreated(): JsonField = dateCreated - - /** - * Returns the raw JSON value of [dateTimeCreated]. - * - * Unlike [dateTimeCreated], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("DateTimeCreated") - @ExcludeMissing - fun _dateTimeCreated(): JsonField = dateTimeCreated - - /** - * 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 [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 [digitalImageGuid]. - * - * Unlike [digitalImageGuid], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("DigitalImageGUID") - @ExcludeMissing - fun _digitalImageGuid(): JsonField = digitalImageGuid - - /** - * Returns the raw JSON value of [digitalSourceType]. - * - * Unlike [digitalSourceType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("DigitalSourceType") - @ExcludeMissing - fun _digitalSourceType(): JsonField = digitalSourceType - - /** - * Returns the raw JSON value of [embeddedEncodedRightsExpr]. - * - * Unlike [embeddedEncodedRightsExpr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("EmbeddedEncodedRightsExpr") - @ExcludeMissing - fun _embeddedEncodedRightsExpr(): JsonField = embeddedEncodedRightsExpr - - /** - * Returns the raw JSON value of [embeddedEncodedRightsExprLangId]. - * - * Unlike [embeddedEncodedRightsExprLangId], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("EmbeddedEncodedRightsExprLangID") - @ExcludeMissing - fun _embeddedEncodedRightsExprLangId(): JsonField = embeddedEncodedRightsExprLangId - - /** - * Returns the raw JSON value of [embeddedEncodedRightsExprType]. - * - * Unlike [embeddedEncodedRightsExprType], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("EmbeddedEncodedRightsExprType") - @ExcludeMissing - fun _embeddedEncodedRightsExprType(): JsonField = embeddedEncodedRightsExprType - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Event") @ExcludeMissing fun _event(): JsonField = event - - /** - * 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 [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 [genreCvId]. - * - * Unlike [genreCvId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("GenreCvId") @ExcludeMissing fun _genreCvId(): JsonField = genreCvId - - /** - * Returns the raw JSON value of [genreCvTermId]. - * - * Unlike [genreCvTermId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GenreCvTermId") - @ExcludeMissing - fun _genreCvTermId(): JsonField = genreCvTermId - - /** - * Returns the raw JSON value of [genreCvTermName]. - * - * Unlike [genreCvTermName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GenreCvTermName") - @ExcludeMissing - fun _genreCvTermName(): JsonField = genreCvTermName - - /** - * Returns the raw JSON value of [genreCvTermRefinedAbout]. - * - * Unlike [genreCvTermRefinedAbout], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("GenreCvTermRefinedAbout") - @ExcludeMissing - fun _genreCvTermRefinedAbout(): JsonField = genreCvTermRefinedAbout - - /** - * Returns the raw JSON value of [headline]. - * - * Unlike [headline], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Headline") @ExcludeMissing fun _headline(): JsonField = headline - - /** - * Returns the raw JSON value of [imageCreatorId]. - * - * Unlike [imageCreatorId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageCreatorID") - @ExcludeMissing - fun _imageCreatorId(): JsonField = imageCreatorId - - /** - * Returns the raw JSON value of [imageCreatorImageId]. - * - * Unlike [imageCreatorImageId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageCreatorImageID") - @ExcludeMissing - fun _imageCreatorImageId(): JsonField = imageCreatorImageId - - /** - * Returns the raw JSON value of [imageCreatorName]. - * - * Unlike [imageCreatorName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageCreatorName") - @ExcludeMissing - fun _imageCreatorName(): JsonField = imageCreatorName - - /** - * Returns the raw JSON value of [imageDescription]. - * - * Unlike [imageDescription], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageDescription") - @ExcludeMissing - fun _imageDescription(): JsonField = imageDescription - - /** - * Returns the raw JSON value of [imageRegionBoundaryH]. - * - * Unlike [imageRegionBoundaryH], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryH") - @ExcludeMissing - fun _imageRegionBoundaryH(): JsonField> = imageRegionBoundaryH - - /** - * Returns the raw JSON value of [imageRegionBoundaryRx]. - * - * Unlike [imageRegionBoundaryRx], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryRx") - @ExcludeMissing - fun _imageRegionBoundaryRx(): JsonField> = imageRegionBoundaryRx - - /** - * Returns the raw JSON value of [imageRegionBoundaryShape]. - * - * Unlike [imageRegionBoundaryShape], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryShape") - @ExcludeMissing - fun _imageRegionBoundaryShape(): JsonField> = imageRegionBoundaryShape - - /** - * Returns the raw JSON value of [imageRegionBoundaryUnit]. - * - * Unlike [imageRegionBoundaryUnit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryUnit") - @ExcludeMissing - fun _imageRegionBoundaryUnit(): JsonField> = imageRegionBoundaryUnit - - /** - * Returns the raw JSON value of [imageRegionBoundaryVerticesX]. - * - * Unlike [imageRegionBoundaryVerticesX], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryVerticesX") - @ExcludeMissing - fun _imageRegionBoundaryVerticesX(): JsonField> = imageRegionBoundaryVerticesX - - /** - * Returns the raw JSON value of [imageRegionBoundaryVerticesY]. - * - * Unlike [imageRegionBoundaryVerticesY], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryVerticesY") - @ExcludeMissing - fun _imageRegionBoundaryVerticesY(): JsonField> = imageRegionBoundaryVerticesY - - /** - * Returns the raw JSON value of [imageRegionBoundaryW]. - * - * Unlike [imageRegionBoundaryW], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryW") - @ExcludeMissing - fun _imageRegionBoundaryW(): JsonField> = imageRegionBoundaryW - - /** - * Returns the raw JSON value of [imageRegionBoundaryX]. - * - * Unlike [imageRegionBoundaryX], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryX") - @ExcludeMissing - fun _imageRegionBoundaryX(): JsonField> = imageRegionBoundaryX - - /** - * Returns the raw JSON value of [imageRegionBoundaryY]. - * - * Unlike [imageRegionBoundaryY], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryY") - @ExcludeMissing - fun _imageRegionBoundaryY(): JsonField> = imageRegionBoundaryY - - /** - * Returns the raw JSON value of [imageRegionCtypeIdentifier]. - * - * Unlike [imageRegionCtypeIdentifier], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionCtypeIdentifier") - @ExcludeMissing - fun _imageRegionCtypeIdentifier(): JsonField> = imageRegionCtypeIdentifier - - /** - * Returns the raw JSON value of [imageRegionCtypeName]. - * - * Unlike [imageRegionCtypeName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionCtypeName") - @ExcludeMissing - fun _imageRegionCtypeName(): JsonField> = imageRegionCtypeName - - /** - * Returns the raw JSON value of [imageRegionId]. - * - * Unlike [imageRegionId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageRegionID") - @ExcludeMissing - fun _imageRegionId(): JsonField> = imageRegionId - - /** - * Returns the raw JSON value of [imageRegionName]. - * - * Unlike [imageRegionName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageRegionName") - @ExcludeMissing - fun _imageRegionName(): JsonField> = imageRegionName - - /** - * Returns the raw JSON value of [imageRegionOrganisationInImageName]. - * - * Unlike [imageRegionOrganisationInImageName], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("ImageRegionOrganisationInImageName") - @ExcludeMissing - fun _imageRegionOrganisationInImageName(): JsonField> = - imageRegionOrganisationInImageName - - /** - * Returns the raw JSON value of [imageRegionPersonInImage]. - * - * Unlike [imageRegionPersonInImage], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionPersonInImage") - @ExcludeMissing - fun _imageRegionPersonInImage(): JsonField> = imageRegionPersonInImage - - /** - * Returns the raw JSON value of [imageRegionRoleIdentifier]. - * - * Unlike [imageRegionRoleIdentifier], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionRoleIdentifier") - @ExcludeMissing - fun _imageRegionRoleIdentifier(): JsonField> = imageRegionRoleIdentifier - - /** - * Returns the raw JSON value of [imageRegionRoleName]. - * - * Unlike [imageRegionRoleName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionRoleName") - @ExcludeMissing - fun _imageRegionRoleName(): JsonField> = imageRegionRoleName - - /** - * Returns the raw JSON value of [imageSupplierId]. - * - * Unlike [imageSupplierId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageSupplierID") - @ExcludeMissing - fun _imageSupplierId(): JsonField = imageSupplierId - - /** - * Returns the raw JSON value of [imageSupplierImageId]. - * - * Unlike [imageSupplierImageId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageSupplierImageID") - @ExcludeMissing - fun _imageSupplierImageId(): JsonField = imageSupplierImageId - - /** - * Returns the raw JSON value of [imageSupplierName]. - * - * Unlike [imageSupplierName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageSupplierName") - @ExcludeMissing - fun _imageSupplierName(): JsonField = imageSupplierName - - /** - * Returns the raw JSON value of [instructions]. - * - * Unlike [instructions], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("Instructions") - @ExcludeMissing - fun _instructions(): JsonField = instructions - - /** - * Returns the raw JSON value of [intellectualGenre]. - * - * Unlike [intellectualGenre], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("IntellectualGenre") - @ExcludeMissing - fun _intellectualGenre(): JsonField = intellectualGenre - - /** - * Returns the raw JSON value of [keywords]. - * - * Unlike [keywords], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Keywords") - @ExcludeMissing - fun _keywords(): JsonField> = keywords - - /** - * Returns the raw JSON value of [licensorCity]. - * - * Unlike [licensorCity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorCity") - @ExcludeMissing - fun _licensorCity(): JsonField> = licensorCity - - /** - * Returns the raw JSON value of [licensorCountry]. - * - * Unlike [licensorCountry], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorCountry") - @ExcludeMissing - fun _licensorCountry(): JsonField> = licensorCountry - - /** - * Returns the raw JSON value of [licensorEmail]. - * - * Unlike [licensorEmail], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorEmail") - @ExcludeMissing - fun _licensorEmail(): JsonField> = licensorEmail - - /** - * Returns the raw JSON value of [licensorExtendedAddress]. - * - * Unlike [licensorExtendedAddress], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorExtendedAddress") - @ExcludeMissing - fun _licensorExtendedAddress(): JsonField> = licensorExtendedAddress - - /** - * Returns the raw JSON value of [licensorId]. - * - * Unlike [licensorId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("LicensorID") - @ExcludeMissing - fun _licensorId(): JsonField> = licensorId - - /** - * Returns the raw JSON value of [licensorName]. - * - * Unlike [licensorName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorName") - @ExcludeMissing - fun _licensorName(): JsonField> = licensorName - - /** - * Returns the raw JSON value of [licensorPostalCode]. - * - * Unlike [licensorPostalCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorPostalCode") - @ExcludeMissing - fun _licensorPostalCode(): JsonField> = licensorPostalCode - - /** - * Returns the raw JSON value of [licensorRegion]. - * - * Unlike [licensorRegion], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorRegion") - @ExcludeMissing - fun _licensorRegion(): JsonField> = licensorRegion - - /** - * Returns the raw JSON value of [licensorStreetAddress]. - * - * Unlike [licensorStreetAddress], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorStreetAddress") - @ExcludeMissing - fun _licensorStreetAddress(): JsonField> = licensorStreetAddress - - /** - * Returns the raw JSON value of [licensorTelephone1]. - * - * Unlike [licensorTelephone1], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorTelephone1") - @ExcludeMissing - fun _licensorTelephone1(): JsonField> = licensorTelephone1 - - /** - * Returns the raw JSON value of [licensorTelephone2]. - * - * Unlike [licensorTelephone2], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorTelephone2") - @ExcludeMissing - fun _licensorTelephone2(): JsonField> = licensorTelephone2 - - /** - * Returns the raw JSON value of [licensorUrl]. - * - * Unlike [licensorUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("LicensorURL") - @ExcludeMissing - fun _licensorUrl(): JsonField> = licensorUrl - - /** - * Returns the raw JSON value of [linkedEncodedRightsExpr]. - * - * Unlike [linkedEncodedRightsExpr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LinkedEncodedRightsExpr") - @ExcludeMissing - fun _linkedEncodedRightsExpr(): JsonField = linkedEncodedRightsExpr - - /** - * Returns the raw JSON value of [linkedEncodedRightsExprLangId]. - * - * Unlike [linkedEncodedRightsExprLangId], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("LinkedEncodedRightsExprLangID") - @ExcludeMissing - fun _linkedEncodedRightsExprLangId(): JsonField = linkedEncodedRightsExprLangId - - /** - * Returns the raw JSON value of [linkedEncodedRightsExprType]. - * - * Unlike [linkedEncodedRightsExprType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LinkedEncodedRightsExprType") - @ExcludeMissing - fun _linkedEncodedRightsExprType(): JsonField = linkedEncodedRightsExprType - - /** - * Returns the raw JSON value of [location]. - * - * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Location") @ExcludeMissing fun _location(): JsonField = location - - /** - * Returns the raw JSON value of [locationCreatedCity]. - * - * Unlike [locationCreatedCity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedCity") - @ExcludeMissing - fun _locationCreatedCity(): JsonField = locationCreatedCity - - /** - * Returns the raw JSON value of [locationCreatedCountryCode]. - * - * Unlike [locationCreatedCountryCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedCountryCode") - @ExcludeMissing - fun _locationCreatedCountryCode(): JsonField = locationCreatedCountryCode - - /** - * Returns the raw JSON value of [locationCreatedCountryName]. - * - * Unlike [locationCreatedCountryName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedCountryName") - @ExcludeMissing - fun _locationCreatedCountryName(): JsonField = locationCreatedCountryName - - /** - * Returns the raw JSON value of [locationCreatedGpsAltitude]. - * - * Unlike [locationCreatedGpsAltitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedGPSAltitude") - @ExcludeMissing - fun _locationCreatedGpsAltitude(): JsonField = locationCreatedGpsAltitude - - /** - * Returns the raw JSON value of [locationCreatedGpsLatitude]. - * - * Unlike [locationCreatedGpsLatitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedGPSLatitude") - @ExcludeMissing - fun _locationCreatedGpsLatitude(): JsonField = locationCreatedGpsLatitude - - /** - * Returns the raw JSON value of [locationCreatedGpsLongitude]. - * - * Unlike [locationCreatedGpsLongitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedGPSLongitude") - @ExcludeMissing - fun _locationCreatedGpsLongitude(): JsonField = locationCreatedGpsLongitude - - /** - * Returns the raw JSON value of [locationCreatedLocationId]. - * - * Unlike [locationCreatedLocationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedLocationId") - @ExcludeMissing - fun _locationCreatedLocationId(): JsonField = locationCreatedLocationId - - /** - * Returns the raw JSON value of [locationCreatedLocationName]. - * - * Unlike [locationCreatedLocationName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedLocationName") - @ExcludeMissing - fun _locationCreatedLocationName(): JsonField = locationCreatedLocationName - - /** - * Returns the raw JSON value of [locationCreatedProvinceState]. - * - * Unlike [locationCreatedProvinceState], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedProvinceState") - @ExcludeMissing - fun _locationCreatedProvinceState(): JsonField = locationCreatedProvinceState - - /** - * Returns the raw JSON value of [locationCreatedSublocation]. - * - * Unlike [locationCreatedSublocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedSublocation") - @ExcludeMissing - fun _locationCreatedSublocation(): JsonField = locationCreatedSublocation - - /** - * Returns the raw JSON value of [locationCreatedWorldRegion]. - * - * Unlike [locationCreatedWorldRegion], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedWorldRegion") - @ExcludeMissing - fun _locationCreatedWorldRegion(): JsonField = locationCreatedWorldRegion - - /** - * Returns the raw JSON value of [locationShownCity]. - * - * Unlike [locationShownCity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LocationShownCity") - @ExcludeMissing - fun _locationShownCity(): JsonField> = locationShownCity - - /** - * Returns the raw JSON value of [locationShownCountryCode]. - * - * Unlike [locationShownCountryCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownCountryCode") - @ExcludeMissing - fun _locationShownCountryCode(): JsonField> = locationShownCountryCode - - /** - * Returns the raw JSON value of [locationShownCountryName]. - * - * Unlike [locationShownCountryName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownCountryName") - @ExcludeMissing - fun _locationShownCountryName(): JsonField> = locationShownCountryName - - /** - * Returns the raw JSON value of [locationShownGpsAltitude]. - * - * Unlike [locationShownGpsAltitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownGPSAltitude") - @ExcludeMissing - fun _locationShownGpsAltitude(): JsonField> = locationShownGpsAltitude - - /** - * Returns the raw JSON value of [locationShownGpsLatitude]. - * - * Unlike [locationShownGpsLatitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownGPSLatitude") - @ExcludeMissing - fun _locationShownGpsLatitude(): JsonField> = locationShownGpsLatitude - - /** - * Returns the raw JSON value of [locationShownGpsLongitude]. - * - * Unlike [locationShownGpsLongitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownGPSLongitude") - @ExcludeMissing - fun _locationShownGpsLongitude(): JsonField> = locationShownGpsLongitude - - /** - * Returns the raw JSON value of [locationShownLocationId]. - * - * Unlike [locationShownLocationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownLocationId") - @ExcludeMissing - fun _locationShownLocationId(): JsonField> = locationShownLocationId - - /** - * Returns the raw JSON value of [locationShownLocationName]. - * - * Unlike [locationShownLocationName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownLocationName") - @ExcludeMissing - fun _locationShownLocationName(): JsonField> = locationShownLocationName - - /** - * Returns the raw JSON value of [locationShownProvinceState]. - * - * Unlike [locationShownProvinceState], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownProvinceState") - @ExcludeMissing - fun _locationShownProvinceState(): JsonField> = locationShownProvinceState - - /** - * Returns the raw JSON value of [locationShownSublocation]. - * - * Unlike [locationShownSublocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownSublocation") - @ExcludeMissing - fun _locationShownSublocation(): JsonField> = locationShownSublocation - - /** - * Returns the raw JSON value of [locationShownWorldRegion]. - * - * Unlike [locationShownWorldRegion], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownWorldRegion") - @ExcludeMissing - fun _locationShownWorldRegion(): JsonField> = locationShownWorldRegion - - /** - * Returns the raw JSON value of [maxAvailHeight]. - * - * Unlike [maxAvailHeight], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("MaxAvailHeight") - @ExcludeMissing - fun _maxAvailHeight(): JsonField = maxAvailHeight - - /** - * Returns the raw JSON value of [maxAvailWidth]. - * - * Unlike [maxAvailWidth], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("MaxAvailWidth") - @ExcludeMissing - fun _maxAvailWidth(): JsonField = maxAvailWidth - - /** - * Returns the raw JSON value of [modelAge]. - * - * Unlike [modelAge], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ModelAge") - @ExcludeMissing - fun _modelAge(): JsonField> = modelAge - - /** - * Returns the raw JSON value of [modelReleaseId]. - * - * Unlike [modelReleaseId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ModelReleaseID") - @ExcludeMissing - fun _modelReleaseId(): JsonField> = modelReleaseId - - /** - * Returns the raw JSON value of [objectAttributeReference]. - * - * Unlike [objectAttributeReference], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ObjectAttributeReference") - @ExcludeMissing - fun _objectAttributeReference(): JsonField = objectAttributeReference - - /** - * Returns the raw JSON value of [objectName]. - * - * Unlike [objectName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ObjectName") - @ExcludeMissing - fun _objectName(): JsonField = objectName - - /** - * Returns the raw JSON value of [offsetTimeOriginal]. - * - * Unlike [offsetTimeOriginal], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("OffsetTimeOriginal") - @ExcludeMissing - fun _offsetTimeOriginal(): JsonField = offsetTimeOriginal - - /** - * Returns the raw JSON value of [organisationInImageCode]. - * - * Unlike [organisationInImageCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("OrganisationInImageCode") - @ExcludeMissing - fun _organisationInImageCode(): JsonField> = organisationInImageCode - - /** - * Returns the raw JSON value of [organisationInImageName]. - * - * Unlike [organisationInImageName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("OrganisationInImageName") - @ExcludeMissing - fun _organisationInImageName(): JsonField> = organisationInImageName - - /** - * 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 [originalTransmissionReference]. - * - * Unlike [originalTransmissionReference], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("OriginalTransmissionReference") - @ExcludeMissing - fun _originalTransmissionReference(): JsonField = originalTransmissionReference - - /** - * Returns the raw JSON value of [personInImage]. - * - * Unlike [personInImage], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("PersonInImage") - @ExcludeMissing - fun _personInImage(): JsonField> = personInImage - - /** - * Returns the raw JSON value of [personInImageCvTermCvId]. - * - * Unlike [personInImageCvTermCvId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("PersonInImageCvTermCvId") - @ExcludeMissing - fun _personInImageCvTermCvId(): JsonField> = personInImageCvTermCvId - - /** - * Returns the raw JSON value of [personInImageCvTermId]. - * - * Unlike [personInImageCvTermId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("PersonInImageCvTermId") - @ExcludeMissing - fun _personInImageCvTermId(): JsonField> = personInImageCvTermId - - /** - * Returns the raw JSON value of [personInImageCvTermName]. - * - * Unlike [personInImageCvTermName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("PersonInImageCvTermName") - @ExcludeMissing - fun _personInImageCvTermName(): JsonField> = personInImageCvTermName - - /** - * Returns the raw JSON value of [personInImageCvTermRefinedAbout]. - * - * Unlike [personInImageCvTermRefinedAbout], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("PersonInImageCvTermRefinedAbout") - @ExcludeMissing - fun _personInImageCvTermRefinedAbout(): JsonField> = - personInImageCvTermRefinedAbout - - /** - * Returns the raw JSON value of [personInImageDescription]. - * - * Unlike [personInImageDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("PersonInImageDescription") - @ExcludeMissing - fun _personInImageDescription(): JsonField> = personInImageDescription - - /** - * Returns the raw JSON value of [personInImageId]. - * - * Unlike [personInImageId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("PersonInImageId") - @ExcludeMissing - fun _personInImageId(): JsonField> = personInImageId - - /** - * Returns the raw JSON value of [personInImageName]. - * - * Unlike [personInImageName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("PersonInImageName") - @ExcludeMissing - fun _personInImageName(): JsonField> = personInImageName - - /** - * Returns the raw JSON value of [productInImageDescription]. - * - * Unlike [productInImageDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ProductInImageDescription") - @ExcludeMissing - fun _productInImageDescription(): JsonField> = productInImageDescription - - /** - * Returns the raw JSON value of [productInImageGtin]. - * - * Unlike [productInImageGtin], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ProductInImageGTIN") - @ExcludeMissing - fun _productInImageGtin(): JsonField> = productInImageGtin - - /** - * Returns the raw JSON value of [productInImageName]. - * - * Unlike [productInImageName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ProductInImageName") - @ExcludeMissing - fun _productInImageName(): JsonField> = productInImageName - - /** - * Returns the raw JSON value of [propertyReleaseId]. - * - * Unlike [propertyReleaseId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("PropertyReleaseID") - @ExcludeMissing - fun _propertyReleaseId(): JsonField> = propertyReleaseId - - /** - * Returns the raw JSON value of [provinceState]. - * - * Unlike [provinceState], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ProvinceState") - @ExcludeMissing - fun _provinceState(): JsonField = provinceState - - /** - * Returns the raw JSON value of [rating]. - * - * Unlike [rating], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Rating") @ExcludeMissing fun _rating(): JsonField = rating - - /** - * Returns the raw JSON value of [registryEntryRole]. - * - * Unlike [registryEntryRole], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("RegistryEntryRole") - @ExcludeMissing - fun _registryEntryRole(): JsonField> = registryEntryRole - - /** - * Returns the raw JSON value of [registryItemId]. - * - * Unlike [registryItemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("RegistryItemID") - @ExcludeMissing - fun _registryItemId(): JsonField> = registryItemId - - /** - * Returns the raw JSON value of [registryOrganisationId]. - * - * Unlike [registryOrganisationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("RegistryOrganisationID") - @ExcludeMissing - fun _registryOrganisationId(): JsonField> = registryOrganisationId - - /** - * 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 [rights]. - * - * Unlike [rights], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Rights") @ExcludeMissing fun _rights(): JsonField = rights - - /** - * Returns the raw JSON value of [scene]. - * - * Unlike [scene], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Scene") @ExcludeMissing fun _scene(): JsonField> = scene - - /** - * 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 - - /** - * Returns the raw JSON value of [specialInstructions]. - * - * Unlike [specialInstructions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("SpecialInstructions") - @ExcludeMissing - fun _specialInstructions(): JsonField = specialInstructions - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("State") @ExcludeMissing fun _state(): JsonField = state - - /** - * Returns the raw JSON value of [subject]. - * - * Unlike [subject], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Subject") @ExcludeMissing fun _subject(): JsonField> = subject - - /** - * Returns the raw JSON value of [subjectCode]. - * - * Unlike [subjectCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("SubjectCode") - @ExcludeMissing - fun _subjectCode(): JsonField> = subjectCode - - /** - * Returns the raw JSON value of [subjectReference]. - * - * Unlike [subjectReference], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("SubjectReference") - @ExcludeMissing - fun _subjectReference(): JsonField> = subjectReference - - /** - * Returns the raw JSON value of [sublocation]. - * - * Unlike [sublocation], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Sublocation") - @ExcludeMissing - fun _sublocation(): JsonField = sublocation - - /** - * Returns the raw JSON value of [timeCreated]. - * - * Unlike [timeCreated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("TimeCreated") - @ExcludeMissing - fun _timeCreated(): JsonField = timeCreated - - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Title") @ExcludeMissing fun _title(): JsonField = title - - /** - * Returns the raw JSON value of [transmissionReference]. - * - * Unlike [transmissionReference], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("TransmissionReference") - @ExcludeMissing - fun _transmissionReference(): JsonField = transmissionReference - - /** - * Returns the raw JSON value of [usageTerms]. - * - * Unlike [usageTerms], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("UsageTerms") - @ExcludeMissing - fun _usageTerms(): JsonField = usageTerms - - /** - * Returns the raw JSON value of [webStatement]. - * - * Unlike [webStatement], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("WebStatement") - @ExcludeMissing - fun _webStatement(): JsonField = webStatement - - /** - * Returns the raw JSON value of [writer]. - * - * Unlike [writer], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Writer") @ExcludeMissing fun _writer(): JsonField = writer - - /** - * Returns the raw JSON value of [writerEditor]. - * - * Unlike [writerEditor], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("WriterEditor") - @ExcludeMissing - fun _writerEditor(): JsonField = writerEditor - - /** - * 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 [EmbeddedMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmbeddedMetadata]. */ - class Builder internal constructor() { - - private var aboutCvTermCvId: JsonField = JsonMissing.of() - private var aboutCvTermId: JsonField = JsonMissing.of() - private var aboutCvTermName: JsonField = JsonMissing.of() - private var aboutCvTermRefinedAbout: JsonField = JsonMissing.of() - private var additionalModelInformation: JsonField = JsonMissing.of() - private var applicationRecordVersion: JsonField = JsonMissing.of() - private var artist: JsonField = JsonMissing.of() - private var artworkCircaDateCreated: JsonField = JsonMissing.of() - private var artworkContentDescription: JsonField = JsonMissing.of() - private var artworkContributionDescription: JsonField = JsonMissing.of() - private var artworkCopyrightNotice: JsonField = JsonMissing.of() - private var artworkCopyrightOwnerId: JsonField = JsonMissing.of() - private var artworkCopyrightOwnerName: JsonField = JsonMissing.of() - private var artworkCreator: JsonField>? = null - private var artworkCreatorId: JsonField>? = null - private var artworkDateCreated: JsonField = JsonMissing.of() - private var artworkLicensorId: JsonField = JsonMissing.of() - private var artworkLicensorName: JsonField = JsonMissing.of() - private var artworkPhysicalDescription: JsonField = JsonMissing.of() - private var artworkSource: JsonField = JsonMissing.of() - private var artworkSourceInventoryNo: JsonField = JsonMissing.of() - private var artworkSourceInvUrl: JsonField = JsonMissing.of() - private var artworkStylePeriod: JsonField>? = null - private var artworkTitle: JsonField = JsonMissing.of() - private var authorsPosition: JsonField = JsonMissing.of() - private var byline: JsonField = JsonMissing.of() - private var bylineTitle: JsonField = JsonMissing.of() - private var caption: JsonField = JsonMissing.of() - private var captionAbstract: JsonField = JsonMissing.of() - private var captionWriter: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var colorSpace: JsonField = JsonMissing.of() - private var componentsConfiguration: JsonField = JsonMissing.of() - private var copyright: JsonField = JsonMissing.of() - private var copyrightNotice: JsonField = JsonMissing.of() - private var copyrightOwnerId: JsonField>? = null - private var copyrightOwnerName: JsonField>? = null - private var country: JsonField = JsonMissing.of() - private var countryCode: JsonField = JsonMissing.of() - private var countryPrimaryLocationCode: JsonField = JsonMissing.of() - private var countryPrimaryLocationName: JsonField = JsonMissing.of() - private var creator: JsonField = JsonMissing.of() - private var creatorAddress: JsonField = JsonMissing.of() - private var creatorCity: JsonField = JsonMissing.of() - private var creatorCountry: JsonField = JsonMissing.of() - private var creatorPostalCode: JsonField = JsonMissing.of() - private var creatorRegion: JsonField = JsonMissing.of() - private var creatorWorkEmail: JsonField = JsonMissing.of() - private var creatorWorkTelephone: JsonField = JsonMissing.of() - private var creatorWorkUrl: JsonField = JsonMissing.of() - private var credit: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateTimeCreated: JsonField = JsonMissing.of() - private var dateTimeOriginal: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var digitalImageGuid: JsonField = JsonMissing.of() - private var digitalSourceType: JsonField = JsonMissing.of() - private var embeddedEncodedRightsExpr: JsonField = JsonMissing.of() - private var embeddedEncodedRightsExprLangId: JsonField = JsonMissing.of() - private var embeddedEncodedRightsExprType: JsonField = JsonMissing.of() - private var event: JsonField = JsonMissing.of() - private var exifVersion: JsonField = JsonMissing.of() - private var flashpixVersion: JsonField = JsonMissing.of() - private var genreCvId: JsonField = JsonMissing.of() - private var genreCvTermId: JsonField = JsonMissing.of() - private var genreCvTermName: JsonField = JsonMissing.of() - private var genreCvTermRefinedAbout: JsonField = JsonMissing.of() - private var headline: JsonField = JsonMissing.of() - private var imageCreatorId: JsonField = JsonMissing.of() - private var imageCreatorImageId: JsonField = JsonMissing.of() - private var imageCreatorName: JsonField = JsonMissing.of() - private var imageDescription: JsonField = JsonMissing.of() - private var imageRegionBoundaryH: JsonField>? = null - private var imageRegionBoundaryRx: JsonField>? = null - private var imageRegionBoundaryShape: JsonField>? = null - private var imageRegionBoundaryUnit: JsonField>? = null - private var imageRegionBoundaryVerticesX: JsonField>? = null - private var imageRegionBoundaryVerticesY: JsonField>? = null - private var imageRegionBoundaryW: JsonField>? = null - private var imageRegionBoundaryX: JsonField>? = null - private var imageRegionBoundaryY: JsonField>? = null - private var imageRegionCtypeIdentifier: JsonField>? = null - private var imageRegionCtypeName: JsonField>? = null - private var imageRegionId: JsonField>? = null - private var imageRegionName: JsonField>? = null - private var imageRegionOrganisationInImageName: JsonField>? = null - private var imageRegionPersonInImage: JsonField>? = null - private var imageRegionRoleIdentifier: JsonField>? = null - private var imageRegionRoleName: JsonField>? = null - private var imageSupplierId: JsonField = JsonMissing.of() - private var imageSupplierImageId: JsonField = JsonMissing.of() - private var imageSupplierName: JsonField = JsonMissing.of() - private var instructions: JsonField = JsonMissing.of() - private var intellectualGenre: JsonField = JsonMissing.of() - private var keywords: JsonField>? = null - private var licensorCity: JsonField>? = null - private var licensorCountry: JsonField>? = null - private var licensorEmail: JsonField>? = null - private var licensorExtendedAddress: JsonField>? = null - private var licensorId: JsonField>? = null - private var licensorName: JsonField>? = null - private var licensorPostalCode: JsonField>? = null - private var licensorRegion: JsonField>? = null - private var licensorStreetAddress: JsonField>? = null - private var licensorTelephone1: JsonField>? = null - private var licensorTelephone2: JsonField>? = null - private var licensorUrl: JsonField>? = null - private var linkedEncodedRightsExpr: JsonField = JsonMissing.of() - private var linkedEncodedRightsExprLangId: JsonField = JsonMissing.of() - private var linkedEncodedRightsExprType: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var locationCreatedCity: JsonField = JsonMissing.of() - private var locationCreatedCountryCode: JsonField = JsonMissing.of() - private var locationCreatedCountryName: JsonField = JsonMissing.of() - private var locationCreatedGpsAltitude: JsonField = JsonMissing.of() - private var locationCreatedGpsLatitude: JsonField = JsonMissing.of() - private var locationCreatedGpsLongitude: JsonField = JsonMissing.of() - private var locationCreatedLocationId: JsonField = JsonMissing.of() - private var locationCreatedLocationName: JsonField = JsonMissing.of() - private var locationCreatedProvinceState: JsonField = JsonMissing.of() - private var locationCreatedSublocation: JsonField = JsonMissing.of() - private var locationCreatedWorldRegion: JsonField = JsonMissing.of() - private var locationShownCity: JsonField>? = null - private var locationShownCountryCode: JsonField>? = null - private var locationShownCountryName: JsonField>? = null - private var locationShownGpsAltitude: JsonField>? = null - private var locationShownGpsLatitude: JsonField>? = null - private var locationShownGpsLongitude: JsonField>? = null - private var locationShownLocationId: JsonField>? = null - private var locationShownLocationName: JsonField>? = null - private var locationShownProvinceState: JsonField>? = null - private var locationShownSublocation: JsonField>? = null - private var locationShownWorldRegion: JsonField>? = null - private var maxAvailHeight: JsonField = JsonMissing.of() - private var maxAvailWidth: JsonField = JsonMissing.of() - private var modelAge: JsonField>? = null - private var modelReleaseId: JsonField>? = null - private var objectAttributeReference: JsonField = JsonMissing.of() - private var objectName: JsonField = JsonMissing.of() - private var offsetTimeOriginal: JsonField = JsonMissing.of() - private var organisationInImageCode: JsonField>? = null - private var organisationInImageName: JsonField>? = null - private var orientation: JsonField = JsonMissing.of() - private var originalTransmissionReference: JsonField = JsonMissing.of() - private var personInImage: JsonField>? = null - private var personInImageCvTermCvId: JsonField>? = null - private var personInImageCvTermId: JsonField>? = null - private var personInImageCvTermName: JsonField>? = null - private var personInImageCvTermRefinedAbout: JsonField>? = null - private var personInImageDescription: JsonField>? = null - private var personInImageId: JsonField>? = null - private var personInImageName: JsonField>? = null - private var productInImageDescription: JsonField>? = null - private var productInImageGtin: JsonField>? = null - private var productInImageName: JsonField>? = null - private var propertyReleaseId: JsonField>? = null - private var provinceState: JsonField = JsonMissing.of() - private var rating: JsonField = JsonMissing.of() - private var registryEntryRole: JsonField>? = null - private var registryItemId: JsonField>? = null - private var registryOrganisationId: JsonField>? = null - private var resolutionUnit: JsonField = JsonMissing.of() - private var rights: JsonField = JsonMissing.of() - private var scene: JsonField>? = null - private var source: JsonField = JsonMissing.of() - private var specialInstructions: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var subject: JsonField>? = null - private var subjectCode: JsonField>? = null - private var subjectReference: JsonField>? = null - private var sublocation: JsonField = JsonMissing.of() - private var timeCreated: JsonField = JsonMissing.of() - private var title: JsonField = JsonMissing.of() - private var transmissionReference: JsonField = JsonMissing.of() - private var usageTerms: JsonField = JsonMissing.of() - private var webStatement: JsonField = JsonMissing.of() - private var writer: JsonField = JsonMissing.of() - private var writerEditor: JsonField = JsonMissing.of() - private var xResolution: JsonField = JsonMissing.of() - private var yResolution: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { - aboutCvTermCvId = embeddedMetadata.aboutCvTermCvId - aboutCvTermId = embeddedMetadata.aboutCvTermId - aboutCvTermName = embeddedMetadata.aboutCvTermName - aboutCvTermRefinedAbout = embeddedMetadata.aboutCvTermRefinedAbout - additionalModelInformation = embeddedMetadata.additionalModelInformation - applicationRecordVersion = embeddedMetadata.applicationRecordVersion - artist = embeddedMetadata.artist - artworkCircaDateCreated = embeddedMetadata.artworkCircaDateCreated - artworkContentDescription = embeddedMetadata.artworkContentDescription - artworkContributionDescription = embeddedMetadata.artworkContributionDescription - artworkCopyrightNotice = embeddedMetadata.artworkCopyrightNotice - artworkCopyrightOwnerId = embeddedMetadata.artworkCopyrightOwnerId - artworkCopyrightOwnerName = embeddedMetadata.artworkCopyrightOwnerName - artworkCreator = embeddedMetadata.artworkCreator.map { it.toMutableList() } - artworkCreatorId = embeddedMetadata.artworkCreatorId.map { it.toMutableList() } - artworkDateCreated = embeddedMetadata.artworkDateCreated - artworkLicensorId = embeddedMetadata.artworkLicensorId - artworkLicensorName = embeddedMetadata.artworkLicensorName - artworkPhysicalDescription = embeddedMetadata.artworkPhysicalDescription - artworkSource = embeddedMetadata.artworkSource - artworkSourceInventoryNo = embeddedMetadata.artworkSourceInventoryNo - artworkSourceInvUrl = embeddedMetadata.artworkSourceInvUrl - artworkStylePeriod = embeddedMetadata.artworkStylePeriod.map { it.toMutableList() } - artworkTitle = embeddedMetadata.artworkTitle - authorsPosition = embeddedMetadata.authorsPosition - byline = embeddedMetadata.byline - bylineTitle = embeddedMetadata.bylineTitle - caption = embeddedMetadata.caption - captionAbstract = embeddedMetadata.captionAbstract - captionWriter = embeddedMetadata.captionWriter - city = embeddedMetadata.city - colorSpace = embeddedMetadata.colorSpace - componentsConfiguration = embeddedMetadata.componentsConfiguration - copyright = embeddedMetadata.copyright - copyrightNotice = embeddedMetadata.copyrightNotice - copyrightOwnerId = embeddedMetadata.copyrightOwnerId.map { it.toMutableList() } - copyrightOwnerName = embeddedMetadata.copyrightOwnerName.map { it.toMutableList() } - country = embeddedMetadata.country - countryCode = embeddedMetadata.countryCode - countryPrimaryLocationCode = embeddedMetadata.countryPrimaryLocationCode - countryPrimaryLocationName = embeddedMetadata.countryPrimaryLocationName - creator = embeddedMetadata.creator - creatorAddress = embeddedMetadata.creatorAddress - creatorCity = embeddedMetadata.creatorCity - creatorCountry = embeddedMetadata.creatorCountry - creatorPostalCode = embeddedMetadata.creatorPostalCode - creatorRegion = embeddedMetadata.creatorRegion - creatorWorkEmail = embeddedMetadata.creatorWorkEmail - creatorWorkTelephone = embeddedMetadata.creatorWorkTelephone - creatorWorkUrl = embeddedMetadata.creatorWorkUrl - credit = embeddedMetadata.credit - dateCreated = embeddedMetadata.dateCreated - dateTimeCreated = embeddedMetadata.dateTimeCreated - dateTimeOriginal = embeddedMetadata.dateTimeOriginal - description = embeddedMetadata.description - digitalImageGuid = embeddedMetadata.digitalImageGuid - digitalSourceType = embeddedMetadata.digitalSourceType - embeddedEncodedRightsExpr = embeddedMetadata.embeddedEncodedRightsExpr - embeddedEncodedRightsExprLangId = embeddedMetadata.embeddedEncodedRightsExprLangId - embeddedEncodedRightsExprType = embeddedMetadata.embeddedEncodedRightsExprType - event = embeddedMetadata.event - exifVersion = embeddedMetadata.exifVersion - flashpixVersion = embeddedMetadata.flashpixVersion - genreCvId = embeddedMetadata.genreCvId - genreCvTermId = embeddedMetadata.genreCvTermId - genreCvTermName = embeddedMetadata.genreCvTermName - genreCvTermRefinedAbout = embeddedMetadata.genreCvTermRefinedAbout - headline = embeddedMetadata.headline - imageCreatorId = embeddedMetadata.imageCreatorId - imageCreatorImageId = embeddedMetadata.imageCreatorImageId - imageCreatorName = embeddedMetadata.imageCreatorName - imageDescription = embeddedMetadata.imageDescription - imageRegionBoundaryH = - embeddedMetadata.imageRegionBoundaryH.map { it.toMutableList() } - imageRegionBoundaryRx = - embeddedMetadata.imageRegionBoundaryRx.map { it.toMutableList() } - imageRegionBoundaryShape = - embeddedMetadata.imageRegionBoundaryShape.map { it.toMutableList() } - imageRegionBoundaryUnit = - embeddedMetadata.imageRegionBoundaryUnit.map { it.toMutableList() } - imageRegionBoundaryVerticesX = - embeddedMetadata.imageRegionBoundaryVerticesX.map { it.toMutableList() } - imageRegionBoundaryVerticesY = - embeddedMetadata.imageRegionBoundaryVerticesY.map { it.toMutableList() } - imageRegionBoundaryW = - embeddedMetadata.imageRegionBoundaryW.map { it.toMutableList() } - imageRegionBoundaryX = - embeddedMetadata.imageRegionBoundaryX.map { it.toMutableList() } - imageRegionBoundaryY = - embeddedMetadata.imageRegionBoundaryY.map { it.toMutableList() } - imageRegionCtypeIdentifier = - embeddedMetadata.imageRegionCtypeIdentifier.map { it.toMutableList() } - imageRegionCtypeName = - embeddedMetadata.imageRegionCtypeName.map { it.toMutableList() } - imageRegionId = embeddedMetadata.imageRegionId.map { it.toMutableList() } - imageRegionName = embeddedMetadata.imageRegionName.map { it.toMutableList() } - imageRegionOrganisationInImageName = - embeddedMetadata.imageRegionOrganisationInImageName.map { it.toMutableList() } - imageRegionPersonInImage = - embeddedMetadata.imageRegionPersonInImage.map { it.toMutableList() } - imageRegionRoleIdentifier = - embeddedMetadata.imageRegionRoleIdentifier.map { it.toMutableList() } - imageRegionRoleName = - embeddedMetadata.imageRegionRoleName.map { it.toMutableList() } - imageSupplierId = embeddedMetadata.imageSupplierId - imageSupplierImageId = embeddedMetadata.imageSupplierImageId - imageSupplierName = embeddedMetadata.imageSupplierName - instructions = embeddedMetadata.instructions - intellectualGenre = embeddedMetadata.intellectualGenre - keywords = embeddedMetadata.keywords.map { it.toMutableList() } - licensorCity = embeddedMetadata.licensorCity.map { it.toMutableList() } - licensorCountry = embeddedMetadata.licensorCountry.map { it.toMutableList() } - licensorEmail = embeddedMetadata.licensorEmail.map { it.toMutableList() } - licensorExtendedAddress = - embeddedMetadata.licensorExtendedAddress.map { it.toMutableList() } - licensorId = embeddedMetadata.licensorId.map { it.toMutableList() } - licensorName = embeddedMetadata.licensorName.map { it.toMutableList() } - licensorPostalCode = embeddedMetadata.licensorPostalCode.map { it.toMutableList() } - licensorRegion = embeddedMetadata.licensorRegion.map { it.toMutableList() } - licensorStreetAddress = - embeddedMetadata.licensorStreetAddress.map { it.toMutableList() } - licensorTelephone1 = embeddedMetadata.licensorTelephone1.map { it.toMutableList() } - licensorTelephone2 = embeddedMetadata.licensorTelephone2.map { it.toMutableList() } - licensorUrl = embeddedMetadata.licensorUrl.map { it.toMutableList() } - linkedEncodedRightsExpr = embeddedMetadata.linkedEncodedRightsExpr - linkedEncodedRightsExprLangId = embeddedMetadata.linkedEncodedRightsExprLangId - linkedEncodedRightsExprType = embeddedMetadata.linkedEncodedRightsExprType - location = embeddedMetadata.location - locationCreatedCity = embeddedMetadata.locationCreatedCity - locationCreatedCountryCode = embeddedMetadata.locationCreatedCountryCode - locationCreatedCountryName = embeddedMetadata.locationCreatedCountryName - locationCreatedGpsAltitude = embeddedMetadata.locationCreatedGpsAltitude - locationCreatedGpsLatitude = embeddedMetadata.locationCreatedGpsLatitude - locationCreatedGpsLongitude = embeddedMetadata.locationCreatedGpsLongitude - locationCreatedLocationId = embeddedMetadata.locationCreatedLocationId - locationCreatedLocationName = embeddedMetadata.locationCreatedLocationName - locationCreatedProvinceState = embeddedMetadata.locationCreatedProvinceState - locationCreatedSublocation = embeddedMetadata.locationCreatedSublocation - locationCreatedWorldRegion = embeddedMetadata.locationCreatedWorldRegion - locationShownCity = embeddedMetadata.locationShownCity.map { it.toMutableList() } - locationShownCountryCode = - embeddedMetadata.locationShownCountryCode.map { it.toMutableList() } - locationShownCountryName = - embeddedMetadata.locationShownCountryName.map { it.toMutableList() } - locationShownGpsAltitude = - embeddedMetadata.locationShownGpsAltitude.map { it.toMutableList() } - locationShownGpsLatitude = - embeddedMetadata.locationShownGpsLatitude.map { it.toMutableList() } - locationShownGpsLongitude = - embeddedMetadata.locationShownGpsLongitude.map { it.toMutableList() } - locationShownLocationId = - embeddedMetadata.locationShownLocationId.map { it.toMutableList() } - locationShownLocationName = - embeddedMetadata.locationShownLocationName.map { it.toMutableList() } - locationShownProvinceState = - embeddedMetadata.locationShownProvinceState.map { it.toMutableList() } - locationShownSublocation = - embeddedMetadata.locationShownSublocation.map { it.toMutableList() } - locationShownWorldRegion = - embeddedMetadata.locationShownWorldRegion.map { it.toMutableList() } - maxAvailHeight = embeddedMetadata.maxAvailHeight - maxAvailWidth = embeddedMetadata.maxAvailWidth - modelAge = embeddedMetadata.modelAge.map { it.toMutableList() } - modelReleaseId = embeddedMetadata.modelReleaseId.map { it.toMutableList() } - objectAttributeReference = embeddedMetadata.objectAttributeReference - objectName = embeddedMetadata.objectName - offsetTimeOriginal = embeddedMetadata.offsetTimeOriginal - organisationInImageCode = - embeddedMetadata.organisationInImageCode.map { it.toMutableList() } - organisationInImageName = - embeddedMetadata.organisationInImageName.map { it.toMutableList() } - orientation = embeddedMetadata.orientation - originalTransmissionReference = embeddedMetadata.originalTransmissionReference - personInImage = embeddedMetadata.personInImage.map { it.toMutableList() } - personInImageCvTermCvId = - embeddedMetadata.personInImageCvTermCvId.map { it.toMutableList() } - personInImageCvTermId = - embeddedMetadata.personInImageCvTermId.map { it.toMutableList() } - personInImageCvTermName = - embeddedMetadata.personInImageCvTermName.map { it.toMutableList() } - personInImageCvTermRefinedAbout = - embeddedMetadata.personInImageCvTermRefinedAbout.map { it.toMutableList() } - personInImageDescription = - embeddedMetadata.personInImageDescription.map { it.toMutableList() } - personInImageId = embeddedMetadata.personInImageId.map { it.toMutableList() } - personInImageName = embeddedMetadata.personInImageName.map { it.toMutableList() } - productInImageDescription = - embeddedMetadata.productInImageDescription.map { it.toMutableList() } - productInImageGtin = embeddedMetadata.productInImageGtin.map { it.toMutableList() } - productInImageName = embeddedMetadata.productInImageName.map { it.toMutableList() } - propertyReleaseId = embeddedMetadata.propertyReleaseId.map { it.toMutableList() } - provinceState = embeddedMetadata.provinceState - rating = embeddedMetadata.rating - registryEntryRole = embeddedMetadata.registryEntryRole.map { it.toMutableList() } - registryItemId = embeddedMetadata.registryItemId.map { it.toMutableList() } - registryOrganisationId = - embeddedMetadata.registryOrganisationId.map { it.toMutableList() } - resolutionUnit = embeddedMetadata.resolutionUnit - rights = embeddedMetadata.rights - scene = embeddedMetadata.scene.map { it.toMutableList() } - source = embeddedMetadata.source - specialInstructions = embeddedMetadata.specialInstructions - state = embeddedMetadata.state - subject = embeddedMetadata.subject.map { it.toMutableList() } - subjectCode = embeddedMetadata.subjectCode.map { it.toMutableList() } - subjectReference = embeddedMetadata.subjectReference.map { it.toMutableList() } - sublocation = embeddedMetadata.sublocation - timeCreated = embeddedMetadata.timeCreated - title = embeddedMetadata.title - transmissionReference = embeddedMetadata.transmissionReference - usageTerms = embeddedMetadata.usageTerms - webStatement = embeddedMetadata.webStatement - writer = embeddedMetadata.writer - writerEditor = embeddedMetadata.writerEditor - xResolution = embeddedMetadata.xResolution - yResolution = embeddedMetadata.yResolution - additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() - } - - fun aboutCvTermCvId(aboutCvTermCvId: String) = - aboutCvTermCvId(JsonField.of(aboutCvTermCvId)) - - /** - * Sets [Builder.aboutCvTermCvId] to an arbitrary JSON value. - * - * You should usually call [Builder.aboutCvTermCvId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun aboutCvTermCvId(aboutCvTermCvId: JsonField) = apply { - this.aboutCvTermCvId = aboutCvTermCvId - } - - fun aboutCvTermId(aboutCvTermId: String) = aboutCvTermId(JsonField.of(aboutCvTermId)) - - /** - * Sets [Builder.aboutCvTermId] to an arbitrary JSON value. - * - * You should usually call [Builder.aboutCvTermId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun aboutCvTermId(aboutCvTermId: JsonField) = apply { - this.aboutCvTermId = aboutCvTermId - } - - fun aboutCvTermName(aboutCvTermName: String) = - aboutCvTermName(JsonField.of(aboutCvTermName)) - - /** - * Sets [Builder.aboutCvTermName] to an arbitrary JSON value. - * - * You should usually call [Builder.aboutCvTermName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun aboutCvTermName(aboutCvTermName: JsonField) = apply { - this.aboutCvTermName = aboutCvTermName - } - - fun aboutCvTermRefinedAbout(aboutCvTermRefinedAbout: String) = - aboutCvTermRefinedAbout(JsonField.of(aboutCvTermRefinedAbout)) - - /** - * Sets [Builder.aboutCvTermRefinedAbout] to an arbitrary JSON value. - * - * You should usually call [Builder.aboutCvTermRefinedAbout] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun aboutCvTermRefinedAbout(aboutCvTermRefinedAbout: JsonField) = apply { - this.aboutCvTermRefinedAbout = aboutCvTermRefinedAbout - } - - fun additionalModelInformation(additionalModelInformation: String) = - additionalModelInformation(JsonField.of(additionalModelInformation)) - - /** - * Sets [Builder.additionalModelInformation] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalModelInformation] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun additionalModelInformation(additionalModelInformation: JsonField) = apply { - this.additionalModelInformation = additionalModelInformation - } - - fun applicationRecordVersion(applicationRecordVersion: Long) = - applicationRecordVersion(JsonField.of(applicationRecordVersion)) - - /** - * Sets [Builder.applicationRecordVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.applicationRecordVersion] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun applicationRecordVersion(applicationRecordVersion: JsonField) = apply { - this.applicationRecordVersion = applicationRecordVersion - } - - fun artist(artist: String) = artist(JsonField.of(artist)) - - /** - * Sets [Builder.artist] to an arbitrary JSON value. - * - * You should usually call [Builder.artist] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun artist(artist: JsonField) = apply { this.artist = artist } - - fun artworkCircaDateCreated(artworkCircaDateCreated: String) = - artworkCircaDateCreated(JsonField.of(artworkCircaDateCreated)) - - /** - * Sets [Builder.artworkCircaDateCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCircaDateCreated] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCircaDateCreated(artworkCircaDateCreated: JsonField) = apply { - this.artworkCircaDateCreated = artworkCircaDateCreated - } - - fun artworkContentDescription(artworkContentDescription: String) = - artworkContentDescription(JsonField.of(artworkContentDescription)) - - /** - * Sets [Builder.artworkContentDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkContentDescription] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkContentDescription(artworkContentDescription: JsonField) = apply { - this.artworkContentDescription = artworkContentDescription - } - - fun artworkContributionDescription(artworkContributionDescription: String) = - artworkContributionDescription(JsonField.of(artworkContributionDescription)) - - /** - * Sets [Builder.artworkContributionDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkContributionDescription] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkContributionDescription(artworkContributionDescription: JsonField) = - apply { - this.artworkContributionDescription = artworkContributionDescription - } - - fun artworkCopyrightNotice(artworkCopyrightNotice: String) = - artworkCopyrightNotice(JsonField.of(artworkCopyrightNotice)) - - /** - * Sets [Builder.artworkCopyrightNotice] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCopyrightNotice] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCopyrightNotice(artworkCopyrightNotice: JsonField) = apply { - this.artworkCopyrightNotice = artworkCopyrightNotice - } - - fun artworkCopyrightOwnerId(artworkCopyrightOwnerId: String) = - artworkCopyrightOwnerId(JsonField.of(artworkCopyrightOwnerId)) - - /** - * Sets [Builder.artworkCopyrightOwnerId] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCopyrightOwnerId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCopyrightOwnerId(artworkCopyrightOwnerId: JsonField) = apply { - this.artworkCopyrightOwnerId = artworkCopyrightOwnerId - } - - fun artworkCopyrightOwnerName(artworkCopyrightOwnerName: String) = - artworkCopyrightOwnerName(JsonField.of(artworkCopyrightOwnerName)) - - /** - * Sets [Builder.artworkCopyrightOwnerName] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCopyrightOwnerName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkCopyrightOwnerName(artworkCopyrightOwnerName: JsonField) = apply { - this.artworkCopyrightOwnerName = artworkCopyrightOwnerName - } - - fun artworkCreator(artworkCreator: List) = - artworkCreator(JsonField.of(artworkCreator)) - - /** - * Sets [Builder.artworkCreator] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCreator] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCreator(artworkCreator: JsonField>) = apply { - this.artworkCreator = artworkCreator.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.artworkCreator]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addArtworkCreator(artworkCreator: String) = apply { - this.artworkCreator = - (this.artworkCreator ?: JsonField.of(mutableListOf())).also { - checkKnown("artworkCreator", it).add(artworkCreator) - } - } - - fun artworkCreatorId(artworkCreatorId: List) = - artworkCreatorId(JsonField.of(artworkCreatorId)) - - /** - * Sets [Builder.artworkCreatorId] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCreatorId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCreatorId(artworkCreatorId: JsonField>) = apply { - this.artworkCreatorId = artworkCreatorId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.artworkCreatorId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addArtworkCreatorId(artworkCreatorId: String) = apply { - this.artworkCreatorId = - (this.artworkCreatorId ?: JsonField.of(mutableListOf())).also { - checkKnown("artworkCreatorId", it).add(artworkCreatorId) - } - } - - fun artworkDateCreated(artworkDateCreated: OffsetDateTime) = - artworkDateCreated(JsonField.of(artworkDateCreated)) - - /** - * Sets [Builder.artworkDateCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkDateCreated] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkDateCreated(artworkDateCreated: JsonField) = apply { - this.artworkDateCreated = artworkDateCreated - } - - fun artworkLicensorId(artworkLicensorId: String) = - artworkLicensorId(JsonField.of(artworkLicensorId)) - - /** - * Sets [Builder.artworkLicensorId] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkLicensorId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun artworkLicensorId(artworkLicensorId: JsonField) = apply { - this.artworkLicensorId = artworkLicensorId - } - - fun artworkLicensorName(artworkLicensorName: String) = - artworkLicensorName(JsonField.of(artworkLicensorName)) - - /** - * Sets [Builder.artworkLicensorName] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkLicensorName] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkLicensorName(artworkLicensorName: JsonField) = apply { - this.artworkLicensorName = artworkLicensorName - } - - fun artworkPhysicalDescription(artworkPhysicalDescription: String) = - artworkPhysicalDescription(JsonField.of(artworkPhysicalDescription)) - - /** - * Sets [Builder.artworkPhysicalDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkPhysicalDescription] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkPhysicalDescription(artworkPhysicalDescription: JsonField) = apply { - this.artworkPhysicalDescription = artworkPhysicalDescription - } - - fun artworkSource(artworkSource: String) = artworkSource(JsonField.of(artworkSource)) - - /** - * Sets [Builder.artworkSource] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkSource] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun artworkSource(artworkSource: JsonField) = apply { - this.artworkSource = artworkSource - } - - fun artworkSourceInventoryNo(artworkSourceInventoryNo: String) = - artworkSourceInventoryNo(JsonField.of(artworkSourceInventoryNo)) - - /** - * Sets [Builder.artworkSourceInventoryNo] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkSourceInventoryNo] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkSourceInventoryNo(artworkSourceInventoryNo: JsonField) = apply { - this.artworkSourceInventoryNo = artworkSourceInventoryNo - } - - fun artworkSourceInvUrl(artworkSourceInvUrl: String) = - artworkSourceInvUrl(JsonField.of(artworkSourceInvUrl)) - - /** - * Sets [Builder.artworkSourceInvUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkSourceInvUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkSourceInvUrl(artworkSourceInvUrl: JsonField) = apply { - this.artworkSourceInvUrl = artworkSourceInvUrl - } - - fun artworkStylePeriod(artworkStylePeriod: List) = - artworkStylePeriod(JsonField.of(artworkStylePeriod)) - - /** - * Sets [Builder.artworkStylePeriod] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkStylePeriod] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkStylePeriod(artworkStylePeriod: JsonField>) = apply { - this.artworkStylePeriod = artworkStylePeriod.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.artworkStylePeriod]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addArtworkStylePeriod(artworkStylePeriod: String) = apply { - this.artworkStylePeriod = - (this.artworkStylePeriod ?: JsonField.of(mutableListOf())).also { - checkKnown("artworkStylePeriod", it).add(artworkStylePeriod) - } - } - - fun artworkTitle(artworkTitle: String) = artworkTitle(JsonField.of(artworkTitle)) - - /** - * Sets [Builder.artworkTitle] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkTitle] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun artworkTitle(artworkTitle: JsonField) = apply { - this.artworkTitle = artworkTitle - } - - fun authorsPosition(authorsPosition: String) = - authorsPosition(JsonField.of(authorsPosition)) - - /** - * Sets [Builder.authorsPosition] to an arbitrary JSON value. - * - * You should usually call [Builder.authorsPosition] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun authorsPosition(authorsPosition: JsonField) = apply { - this.authorsPosition = authorsPosition - } - - fun byline(byline: String) = byline(JsonField.of(byline)) - - /** - * Sets [Builder.byline] to an arbitrary JSON value. - * - * You should usually call [Builder.byline] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun byline(byline: JsonField) = apply { this.byline = byline } - - fun bylineTitle(bylineTitle: String) = bylineTitle(JsonField.of(bylineTitle)) - - /** - * Sets [Builder.bylineTitle] to an arbitrary JSON value. - * - * You should usually call [Builder.bylineTitle] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun bylineTitle(bylineTitle: JsonField) = apply { - this.bylineTitle = bylineTitle - } - - fun caption(caption: String) = caption(JsonField.of(caption)) - - /** - * Sets [Builder.caption] to an arbitrary JSON value. - * - * You should usually call [Builder.caption] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun caption(caption: JsonField) = apply { this.caption = caption } - - fun captionAbstract(captionAbstract: String) = - captionAbstract(JsonField.of(captionAbstract)) - - /** - * Sets [Builder.captionAbstract] to an arbitrary JSON value. - * - * You should usually call [Builder.captionAbstract] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun captionAbstract(captionAbstract: JsonField) = apply { - this.captionAbstract = captionAbstract - } - - fun captionWriter(captionWriter: String) = captionWriter(JsonField.of(captionWriter)) - - /** - * Sets [Builder.captionWriter] to an arbitrary JSON value. - * - * You should usually call [Builder.captionWriter] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun captionWriter(captionWriter: JsonField) = apply { - this.captionWriter = captionWriter - } - - fun city(city: String) = city(JsonField.of(city)) - - /** - * Sets [Builder.city] to an arbitrary JSON value. - * - * You should usually call [Builder.city] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun city(city: JsonField) = apply { this.city = city } - - fun colorSpace(colorSpace: String) = colorSpace(JsonField.of(colorSpace)) - - /** - * Sets [Builder.colorSpace] to an arbitrary JSON value. - * - * You should usually call [Builder.colorSpace] with a well-typed [String] 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 componentsConfiguration(componentsConfiguration: String) = - componentsConfiguration(JsonField.of(componentsConfiguration)) - - /** - * Sets [Builder.componentsConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.componentsConfiguration] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun componentsConfiguration(componentsConfiguration: JsonField) = apply { - this.componentsConfiguration = componentsConfiguration - } - - fun copyright(copyright: String) = copyright(JsonField.of(copyright)) - - /** - * Sets [Builder.copyright] to an arbitrary JSON value. - * - * You should usually call [Builder.copyright] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun copyright(copyright: JsonField) = apply { this.copyright = copyright } - - fun copyrightNotice(copyrightNotice: String) = - copyrightNotice(JsonField.of(copyrightNotice)) - - /** - * Sets [Builder.copyrightNotice] to an arbitrary JSON value. - * - * You should usually call [Builder.copyrightNotice] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun copyrightNotice(copyrightNotice: JsonField) = apply { - this.copyrightNotice = copyrightNotice - } - - fun copyrightOwnerId(copyrightOwnerId: List) = - copyrightOwnerId(JsonField.of(copyrightOwnerId)) - - /** - * Sets [Builder.copyrightOwnerId] to an arbitrary JSON value. - * - * You should usually call [Builder.copyrightOwnerId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun copyrightOwnerId(copyrightOwnerId: JsonField>) = apply { - this.copyrightOwnerId = copyrightOwnerId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.copyrightOwnerId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCopyrightOwnerId(copyrightOwnerId: String) = apply { - this.copyrightOwnerId = - (this.copyrightOwnerId ?: JsonField.of(mutableListOf())).also { - checkKnown("copyrightOwnerId", it).add(copyrightOwnerId) - } - } - - fun copyrightOwnerName(copyrightOwnerName: List) = - copyrightOwnerName(JsonField.of(copyrightOwnerName)) - - /** - * Sets [Builder.copyrightOwnerName] to an arbitrary JSON value. - * - * You should usually call [Builder.copyrightOwnerName] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun copyrightOwnerName(copyrightOwnerName: JsonField>) = apply { - this.copyrightOwnerName = copyrightOwnerName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.copyrightOwnerName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCopyrightOwnerName(copyrightOwnerName: String) = apply { - this.copyrightOwnerName = - (this.copyrightOwnerName ?: JsonField.of(mutableListOf())).also { - checkKnown("copyrightOwnerName", it).add(copyrightOwnerName) - } - } - - fun country(country: String) = country(JsonField.of(country)) - - /** - * Sets [Builder.country] to an arbitrary JSON value. - * - * You should usually call [Builder.country] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun country(country: JsonField) = apply { this.country = country } - - fun countryCode(countryCode: String) = countryCode(JsonField.of(countryCode)) - - /** - * Sets [Builder.countryCode] to an arbitrary JSON value. - * - * You should usually call [Builder.countryCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun countryCode(countryCode: JsonField) = apply { - this.countryCode = countryCode - } - - fun countryPrimaryLocationCode(countryPrimaryLocationCode: String) = - countryPrimaryLocationCode(JsonField.of(countryPrimaryLocationCode)) - - /** - * Sets [Builder.countryPrimaryLocationCode] to an arbitrary JSON value. - * - * You should usually call [Builder.countryPrimaryLocationCode] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun countryPrimaryLocationCode(countryPrimaryLocationCode: JsonField) = apply { - this.countryPrimaryLocationCode = countryPrimaryLocationCode - } - - fun countryPrimaryLocationName(countryPrimaryLocationName: String) = - countryPrimaryLocationName(JsonField.of(countryPrimaryLocationName)) - - /** - * Sets [Builder.countryPrimaryLocationName] to an arbitrary JSON value. - * - * You should usually call [Builder.countryPrimaryLocationName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun countryPrimaryLocationName(countryPrimaryLocationName: JsonField) = apply { - this.countryPrimaryLocationName = countryPrimaryLocationName - } - - fun creator(creator: String) = creator(JsonField.of(creator)) - - /** - * Sets [Builder.creator] to an arbitrary JSON value. - * - * You should usually call [Builder.creator] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creator(creator: JsonField) = apply { this.creator = creator } - - fun creatorAddress(creatorAddress: String) = - creatorAddress(JsonField.of(creatorAddress)) - - /** - * Sets [Builder.creatorAddress] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorAddress] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorAddress(creatorAddress: JsonField) = apply { - this.creatorAddress = creatorAddress - } - - fun creatorCity(creatorCity: String) = creatorCity(JsonField.of(creatorCity)) - - /** - * Sets [Builder.creatorCity] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorCity] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorCity(creatorCity: JsonField) = apply { - this.creatorCity = creatorCity - } - - fun creatorCountry(creatorCountry: String) = - creatorCountry(JsonField.of(creatorCountry)) - - /** - * Sets [Builder.creatorCountry] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorCountry] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorCountry(creatorCountry: JsonField) = apply { - this.creatorCountry = creatorCountry - } - - fun creatorPostalCode(creatorPostalCode: String) = - creatorPostalCode(JsonField.of(creatorPostalCode)) - - /** - * Sets [Builder.creatorPostalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorPostalCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorPostalCode(creatorPostalCode: JsonField) = apply { - this.creatorPostalCode = creatorPostalCode - } - - fun creatorRegion(creatorRegion: String) = creatorRegion(JsonField.of(creatorRegion)) - - /** - * Sets [Builder.creatorRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorRegion] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorRegion(creatorRegion: JsonField) = apply { - this.creatorRegion = creatorRegion - } - - fun creatorWorkEmail(creatorWorkEmail: String) = - creatorWorkEmail(JsonField.of(creatorWorkEmail)) - - /** - * Sets [Builder.creatorWorkEmail] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorWorkEmail] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorWorkEmail(creatorWorkEmail: JsonField) = apply { - this.creatorWorkEmail = creatorWorkEmail - } - - fun creatorWorkTelephone(creatorWorkTelephone: String) = - creatorWorkTelephone(JsonField.of(creatorWorkTelephone)) - - /** - * Sets [Builder.creatorWorkTelephone] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorWorkTelephone] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun creatorWorkTelephone(creatorWorkTelephone: JsonField) = apply { - this.creatorWorkTelephone = creatorWorkTelephone - } - - fun creatorWorkUrl(creatorWorkUrl: String) = - creatorWorkUrl(JsonField.of(creatorWorkUrl)) - - /** - * Sets [Builder.creatorWorkUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorWorkUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorWorkUrl(creatorWorkUrl: JsonField) = apply { - this.creatorWorkUrl = creatorWorkUrl - } - - fun credit(credit: String) = credit(JsonField.of(credit)) - - /** - * Sets [Builder.credit] to an arbitrary JSON value. - * - * You should usually call [Builder.credit] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun credit(credit: JsonField) = apply { this.credit = credit } - - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** - * Sets [Builder.dateCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - fun dateTimeCreated(dateTimeCreated: OffsetDateTime) = - dateTimeCreated(JsonField.of(dateTimeCreated)) - - /** - * Sets [Builder.dateTimeCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.dateTimeCreated] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun dateTimeCreated(dateTimeCreated: JsonField) = apply { - this.dateTimeCreated = dateTimeCreated - } - - fun dateTimeOriginal(dateTimeOriginal: OffsetDateTime) = - dateTimeOriginal(JsonField.of(dateTimeOriginal)) - - /** - * Sets [Builder.dateTimeOriginal] to an arbitrary JSON value. - * - * You should usually call [Builder.dateTimeOriginal] with a well-typed [OffsetDateTime] - * 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 description(description: String) = description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - fun digitalImageGuid(digitalImageGuid: String) = - digitalImageGuid(JsonField.of(digitalImageGuid)) - - /** - * Sets [Builder.digitalImageGuid] to an arbitrary JSON value. - * - * You should usually call [Builder.digitalImageGuid] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun digitalImageGuid(digitalImageGuid: JsonField) = apply { - this.digitalImageGuid = digitalImageGuid - } - - fun digitalSourceType(digitalSourceType: String) = - digitalSourceType(JsonField.of(digitalSourceType)) - - /** - * Sets [Builder.digitalSourceType] to an arbitrary JSON value. - * - * You should usually call [Builder.digitalSourceType] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun digitalSourceType(digitalSourceType: JsonField) = apply { - this.digitalSourceType = digitalSourceType - } - - fun embeddedEncodedRightsExpr(embeddedEncodedRightsExpr: String) = - embeddedEncodedRightsExpr(JsonField.of(embeddedEncodedRightsExpr)) - - /** - * Sets [Builder.embeddedEncodedRightsExpr] to an arbitrary JSON value. - * - * You should usually call [Builder.embeddedEncodedRightsExpr] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun embeddedEncodedRightsExpr(embeddedEncodedRightsExpr: JsonField) = apply { - this.embeddedEncodedRightsExpr = embeddedEncodedRightsExpr - } - - fun embeddedEncodedRightsExprLangId(embeddedEncodedRightsExprLangId: String) = - embeddedEncodedRightsExprLangId(JsonField.of(embeddedEncodedRightsExprLangId)) - - /** - * Sets [Builder.embeddedEncodedRightsExprLangId] to an arbitrary JSON value. - * - * You should usually call [Builder.embeddedEncodedRightsExprLangId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun embeddedEncodedRightsExprLangId( - embeddedEncodedRightsExprLangId: JsonField - ) = apply { this.embeddedEncodedRightsExprLangId = embeddedEncodedRightsExprLangId } - - fun embeddedEncodedRightsExprType(embeddedEncodedRightsExprType: String) = - embeddedEncodedRightsExprType(JsonField.of(embeddedEncodedRightsExprType)) - - /** - * Sets [Builder.embeddedEncodedRightsExprType] to an arbitrary JSON value. - * - * You should usually call [Builder.embeddedEncodedRightsExprType] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun embeddedEncodedRightsExprType(embeddedEncodedRightsExprType: JsonField) = - apply { - this.embeddedEncodedRightsExprType = embeddedEncodedRightsExprType - } - - fun event(event: String) = event(JsonField.of(event)) - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun event(event: JsonField) = apply { this.event = event } - - 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 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 genreCvId(genreCvId: String) = genreCvId(JsonField.of(genreCvId)) - - /** - * Sets [Builder.genreCvId] to an arbitrary JSON value. - * - * You should usually call [Builder.genreCvId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun genreCvId(genreCvId: JsonField) = apply { this.genreCvId = genreCvId } - - fun genreCvTermId(genreCvTermId: String) = genreCvTermId(JsonField.of(genreCvTermId)) - - /** - * Sets [Builder.genreCvTermId] to an arbitrary JSON value. - * - * You should usually call [Builder.genreCvTermId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun genreCvTermId(genreCvTermId: JsonField) = apply { - this.genreCvTermId = genreCvTermId - } - - fun genreCvTermName(genreCvTermName: String) = - genreCvTermName(JsonField.of(genreCvTermName)) - - /** - * Sets [Builder.genreCvTermName] to an arbitrary JSON value. - * - * You should usually call [Builder.genreCvTermName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun genreCvTermName(genreCvTermName: JsonField) = apply { - this.genreCvTermName = genreCvTermName - } - - fun genreCvTermRefinedAbout(genreCvTermRefinedAbout: String) = - genreCvTermRefinedAbout(JsonField.of(genreCvTermRefinedAbout)) - - /** - * Sets [Builder.genreCvTermRefinedAbout] to an arbitrary JSON value. - * - * You should usually call [Builder.genreCvTermRefinedAbout] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun genreCvTermRefinedAbout(genreCvTermRefinedAbout: JsonField) = apply { - this.genreCvTermRefinedAbout = genreCvTermRefinedAbout - } - - fun headline(headline: String) = headline(JsonField.of(headline)) - - /** - * Sets [Builder.headline] to an arbitrary JSON value. - * - * You should usually call [Builder.headline] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun headline(headline: JsonField) = apply { this.headline = headline } - - fun imageCreatorId(imageCreatorId: String) = - imageCreatorId(JsonField.of(imageCreatorId)) - - /** - * Sets [Builder.imageCreatorId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageCreatorId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageCreatorId(imageCreatorId: JsonField) = apply { - this.imageCreatorId = imageCreatorId - } - - fun imageCreatorImageId(imageCreatorImageId: String) = - imageCreatorImageId(JsonField.of(imageCreatorImageId)) - - /** - * Sets [Builder.imageCreatorImageId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageCreatorImageId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageCreatorImageId(imageCreatorImageId: JsonField) = apply { - this.imageCreatorImageId = imageCreatorImageId - } - - fun imageCreatorName(imageCreatorName: String) = - imageCreatorName(JsonField.of(imageCreatorName)) - - /** - * Sets [Builder.imageCreatorName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageCreatorName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageCreatorName(imageCreatorName: JsonField) = apply { - this.imageCreatorName = imageCreatorName - } - - fun imageDescription(imageDescription: String) = - imageDescription(JsonField.of(imageDescription)) - - /** - * Sets [Builder.imageDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.imageDescription] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageDescription(imageDescription: JsonField) = apply { - this.imageDescription = imageDescription - } - - fun imageRegionBoundaryH(imageRegionBoundaryH: List) = - imageRegionBoundaryH(JsonField.of(imageRegionBoundaryH)) - - /** - * Sets [Builder.imageRegionBoundaryH] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryH] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryH(imageRegionBoundaryH: JsonField>) = apply { - this.imageRegionBoundaryH = imageRegionBoundaryH.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryH]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryH(imageRegionBoundaryH: Double) = apply { - this.imageRegionBoundaryH = - (this.imageRegionBoundaryH ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryH", it).add(imageRegionBoundaryH) - } - } - - fun imageRegionBoundaryRx(imageRegionBoundaryRx: List) = - imageRegionBoundaryRx(JsonField.of(imageRegionBoundaryRx)) - - /** - * Sets [Builder.imageRegionBoundaryRx] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryRx] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryRx(imageRegionBoundaryRx: JsonField>) = apply { - this.imageRegionBoundaryRx = imageRegionBoundaryRx.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryRx]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryRx(imageRegionBoundaryRx: Double) = apply { - this.imageRegionBoundaryRx = - (this.imageRegionBoundaryRx ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryRx", it).add(imageRegionBoundaryRx) - } - } - - fun imageRegionBoundaryShape(imageRegionBoundaryShape: List) = - imageRegionBoundaryShape(JsonField.of(imageRegionBoundaryShape)) - - /** - * Sets [Builder.imageRegionBoundaryShape] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryShape] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryShape(imageRegionBoundaryShape: JsonField>) = - apply { - this.imageRegionBoundaryShape = - imageRegionBoundaryShape.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionBoundaryShape]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryShape(imageRegionBoundaryShape: String) = apply { - this.imageRegionBoundaryShape = - (this.imageRegionBoundaryShape ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryShape", it).add(imageRegionBoundaryShape) - } - } - - fun imageRegionBoundaryUnit(imageRegionBoundaryUnit: List) = - imageRegionBoundaryUnit(JsonField.of(imageRegionBoundaryUnit)) - - /** - * Sets [Builder.imageRegionBoundaryUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryUnit] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryUnit(imageRegionBoundaryUnit: JsonField>) = apply { - this.imageRegionBoundaryUnit = imageRegionBoundaryUnit.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionBoundaryUnit]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryUnit(imageRegionBoundaryUnit: String) = apply { - this.imageRegionBoundaryUnit = - (this.imageRegionBoundaryUnit ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryUnit", it).add(imageRegionBoundaryUnit) - } - } - - fun imageRegionBoundaryVerticesX(imageRegionBoundaryVerticesX: List) = - imageRegionBoundaryVerticesX(JsonField.of(imageRegionBoundaryVerticesX)) - - /** - * Sets [Builder.imageRegionBoundaryVerticesX] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryVerticesX] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryVerticesX( - imageRegionBoundaryVerticesX: JsonField> - ) = apply { - this.imageRegionBoundaryVerticesX = - imageRegionBoundaryVerticesX.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryVerticesX]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryVerticesX(imageRegionBoundaryVerticesX: Double) = apply { - this.imageRegionBoundaryVerticesX = - (this.imageRegionBoundaryVerticesX ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryVerticesX", it) - .add(imageRegionBoundaryVerticesX) - } - } - - fun imageRegionBoundaryVerticesY(imageRegionBoundaryVerticesY: List) = - imageRegionBoundaryVerticesY(JsonField.of(imageRegionBoundaryVerticesY)) - - /** - * Sets [Builder.imageRegionBoundaryVerticesY] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryVerticesY] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryVerticesY( - imageRegionBoundaryVerticesY: JsonField> - ) = apply { - this.imageRegionBoundaryVerticesY = - imageRegionBoundaryVerticesY.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryVerticesY]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryVerticesY(imageRegionBoundaryVerticesY: Double) = apply { - this.imageRegionBoundaryVerticesY = - (this.imageRegionBoundaryVerticesY ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryVerticesY", it) - .add(imageRegionBoundaryVerticesY) - } - } - - fun imageRegionBoundaryW(imageRegionBoundaryW: List) = - imageRegionBoundaryW(JsonField.of(imageRegionBoundaryW)) - - /** - * Sets [Builder.imageRegionBoundaryW] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryW] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryW(imageRegionBoundaryW: JsonField>) = apply { - this.imageRegionBoundaryW = imageRegionBoundaryW.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryW]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryW(imageRegionBoundaryW: Double) = apply { - this.imageRegionBoundaryW = - (this.imageRegionBoundaryW ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryW", it).add(imageRegionBoundaryW) - } - } - - fun imageRegionBoundaryX(imageRegionBoundaryX: List) = - imageRegionBoundaryX(JsonField.of(imageRegionBoundaryX)) - - /** - * Sets [Builder.imageRegionBoundaryX] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryX] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryX(imageRegionBoundaryX: JsonField>) = apply { - this.imageRegionBoundaryX = imageRegionBoundaryX.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryX]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryX(imageRegionBoundaryX: Double) = apply { - this.imageRegionBoundaryX = - (this.imageRegionBoundaryX ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryX", it).add(imageRegionBoundaryX) - } - } - - fun imageRegionBoundaryY(imageRegionBoundaryY: List) = - imageRegionBoundaryY(JsonField.of(imageRegionBoundaryY)) - - /** - * Sets [Builder.imageRegionBoundaryY] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryY] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryY(imageRegionBoundaryY: JsonField>) = apply { - this.imageRegionBoundaryY = imageRegionBoundaryY.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryY]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryY(imageRegionBoundaryY: Double) = apply { - this.imageRegionBoundaryY = - (this.imageRegionBoundaryY ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryY", it).add(imageRegionBoundaryY) - } - } - - fun imageRegionCtypeIdentifier(imageRegionCtypeIdentifier: List) = - imageRegionCtypeIdentifier(JsonField.of(imageRegionCtypeIdentifier)) - - /** - * Sets [Builder.imageRegionCtypeIdentifier] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionCtypeIdentifier] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionCtypeIdentifier(imageRegionCtypeIdentifier: JsonField>) = - apply { - this.imageRegionCtypeIdentifier = - imageRegionCtypeIdentifier.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionCtypeIdentifier]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionCtypeIdentifier(imageRegionCtypeIdentifier: String) = apply { - this.imageRegionCtypeIdentifier = - (this.imageRegionCtypeIdentifier ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionCtypeIdentifier", it).add(imageRegionCtypeIdentifier) - } - } - - fun imageRegionCtypeName(imageRegionCtypeName: List) = - imageRegionCtypeName(JsonField.of(imageRegionCtypeName)) - - /** - * Sets [Builder.imageRegionCtypeName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionCtypeName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionCtypeName(imageRegionCtypeName: JsonField>) = apply { - this.imageRegionCtypeName = imageRegionCtypeName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionCtypeName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionCtypeName(imageRegionCtypeName: String) = apply { - this.imageRegionCtypeName = - (this.imageRegionCtypeName ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionCtypeName", it).add(imageRegionCtypeName) - } - } - - fun imageRegionId(imageRegionId: List) = - imageRegionId(JsonField.of(imageRegionId)) - - /** - * Sets [Builder.imageRegionId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageRegionId(imageRegionId: JsonField>) = apply { - this.imageRegionId = imageRegionId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionId(imageRegionId: String) = apply { - this.imageRegionId = - (this.imageRegionId ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionId", it).add(imageRegionId) - } - } - - fun imageRegionName(imageRegionName: List) = - imageRegionName(JsonField.of(imageRegionName)) - - /** - * Sets [Builder.imageRegionName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionName] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageRegionName(imageRegionName: JsonField>) = apply { - this.imageRegionName = imageRegionName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionName(imageRegionName: String) = apply { - this.imageRegionName = - (this.imageRegionName ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionName", it).add(imageRegionName) - } - } - - fun imageRegionOrganisationInImageName( - imageRegionOrganisationInImageName: List - ) = imageRegionOrganisationInImageName(JsonField.of(imageRegionOrganisationInImageName)) - - /** - * Sets [Builder.imageRegionOrganisationInImageName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionOrganisationInImageName] with a - * well-typed `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun imageRegionOrganisationInImageName( - imageRegionOrganisationInImageName: JsonField> - ) = apply { - this.imageRegionOrganisationInImageName = - imageRegionOrganisationInImageName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionOrganisationInImageName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionOrganisationInImageName(imageRegionOrganisationInImageName: String) = - apply { - this.imageRegionOrganisationInImageName = - (this.imageRegionOrganisationInImageName ?: JsonField.of(mutableListOf())) - .also { - checkKnown("imageRegionOrganisationInImageName", it) - .add(imageRegionOrganisationInImageName) - } - } - - fun imageRegionPersonInImage(imageRegionPersonInImage: List) = - imageRegionPersonInImage(JsonField.of(imageRegionPersonInImage)) - - /** - * Sets [Builder.imageRegionPersonInImage] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionPersonInImage] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionPersonInImage(imageRegionPersonInImage: JsonField>) = - apply { - this.imageRegionPersonInImage = - imageRegionPersonInImage.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionPersonInImage]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionPersonInImage(imageRegionPersonInImage: String) = apply { - this.imageRegionPersonInImage = - (this.imageRegionPersonInImage ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionPersonInImage", it).add(imageRegionPersonInImage) - } - } - - fun imageRegionRoleIdentifier(imageRegionRoleIdentifier: List) = - imageRegionRoleIdentifier(JsonField.of(imageRegionRoleIdentifier)) - - /** - * Sets [Builder.imageRegionRoleIdentifier] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionRoleIdentifier] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionRoleIdentifier(imageRegionRoleIdentifier: JsonField>) = - apply { - this.imageRegionRoleIdentifier = - imageRegionRoleIdentifier.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionRoleIdentifier]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionRoleIdentifier(imageRegionRoleIdentifier: String) = apply { - this.imageRegionRoleIdentifier = - (this.imageRegionRoleIdentifier ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionRoleIdentifier", it).add(imageRegionRoleIdentifier) - } - } - - fun imageRegionRoleName(imageRegionRoleName: List) = - imageRegionRoleName(JsonField.of(imageRegionRoleName)) - - /** - * Sets [Builder.imageRegionRoleName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionRoleName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionRoleName(imageRegionRoleName: JsonField>) = apply { - this.imageRegionRoleName = imageRegionRoleName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionRoleName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionRoleName(imageRegionRoleName: String) = apply { - this.imageRegionRoleName = - (this.imageRegionRoleName ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionRoleName", it).add(imageRegionRoleName) - } - } - - fun imageSupplierId(imageSupplierId: String) = - imageSupplierId(JsonField.of(imageSupplierId)) - - /** - * Sets [Builder.imageSupplierId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageSupplierId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageSupplierId(imageSupplierId: JsonField) = apply { - this.imageSupplierId = imageSupplierId - } - - fun imageSupplierImageId(imageSupplierImageId: String) = - imageSupplierImageId(JsonField.of(imageSupplierImageId)) - - /** - * Sets [Builder.imageSupplierImageId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageSupplierImageId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageSupplierImageId(imageSupplierImageId: JsonField) = apply { - this.imageSupplierImageId = imageSupplierImageId - } - - fun imageSupplierName(imageSupplierName: String) = - imageSupplierName(JsonField.of(imageSupplierName)) - - /** - * Sets [Builder.imageSupplierName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageSupplierName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageSupplierName(imageSupplierName: JsonField) = apply { - this.imageSupplierName = imageSupplierName - } - - fun instructions(instructions: String) = instructions(JsonField.of(instructions)) - - /** - * Sets [Builder.instructions] to an arbitrary JSON value. - * - * You should usually call [Builder.instructions] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun instructions(instructions: JsonField) = apply { - this.instructions = instructions - } - - fun intellectualGenre(intellectualGenre: String) = - intellectualGenre(JsonField.of(intellectualGenre)) - - /** - * Sets [Builder.intellectualGenre] to an arbitrary JSON value. - * - * You should usually call [Builder.intellectualGenre] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun intellectualGenre(intellectualGenre: JsonField) = apply { - this.intellectualGenre = intellectualGenre - } - - fun keywords(keywords: List) = keywords(JsonField.of(keywords)) - - /** - * Sets [Builder.keywords] to an arbitrary JSON value. - * - * You should usually call [Builder.keywords] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun keywords(keywords: JsonField>) = apply { - this.keywords = keywords.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [keywords]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addKeyword(keyword: String) = apply { - keywords = - (keywords ?: JsonField.of(mutableListOf())).also { - checkKnown("keywords", it).add(keyword) - } - } - - fun licensorCity(licensorCity: List) = licensorCity(JsonField.of(licensorCity)) - - /** - * Sets [Builder.licensorCity] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorCity] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun licensorCity(licensorCity: JsonField>) = apply { - this.licensorCity = licensorCity.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorCity]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorCity(licensorCity: String) = apply { - this.licensorCity = - (this.licensorCity ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorCity", it).add(licensorCity) - } - } - - fun licensorCountry(licensorCountry: List) = - licensorCountry(JsonField.of(licensorCountry)) - - /** - * Sets [Builder.licensorCountry] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorCountry] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorCountry(licensorCountry: JsonField>) = apply { - this.licensorCountry = licensorCountry.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorCountry]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorCountry(licensorCountry: String) = apply { - this.licensorCountry = - (this.licensorCountry ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorCountry", it).add(licensorCountry) - } - } - - fun licensorEmail(licensorEmail: List) = - licensorEmail(JsonField.of(licensorEmail)) - - /** - * Sets [Builder.licensorEmail] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorEmail] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorEmail(licensorEmail: JsonField>) = apply { - this.licensorEmail = licensorEmail.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorEmail]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorEmail(licensorEmail: String) = apply { - this.licensorEmail = - (this.licensorEmail ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorEmail", it).add(licensorEmail) - } - } - - fun licensorExtendedAddress(licensorExtendedAddress: List) = - licensorExtendedAddress(JsonField.of(licensorExtendedAddress)) - - /** - * Sets [Builder.licensorExtendedAddress] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorExtendedAddress] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun licensorExtendedAddress(licensorExtendedAddress: JsonField>) = apply { - this.licensorExtendedAddress = licensorExtendedAddress.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorExtendedAddress]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorExtendedAddress(licensorExtendedAddress: String) = apply { - this.licensorExtendedAddress = - (this.licensorExtendedAddress ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorExtendedAddress", it).add(licensorExtendedAddress) - } - } - - fun licensorId(licensorId: List) = licensorId(JsonField.of(licensorId)) - - /** - * Sets [Builder.licensorId] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorId] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun licensorId(licensorId: JsonField>) = apply { - this.licensorId = licensorId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorId(licensorId: String) = apply { - this.licensorId = - (this.licensorId ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorId", it).add(licensorId) - } - } - - fun licensorName(licensorName: List) = licensorName(JsonField.of(licensorName)) - - /** - * Sets [Builder.licensorName] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorName] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun licensorName(licensorName: JsonField>) = apply { - this.licensorName = licensorName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorName(licensorName: String) = apply { - this.licensorName = - (this.licensorName ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorName", it).add(licensorName) - } - } - - fun licensorPostalCode(licensorPostalCode: List) = - licensorPostalCode(JsonField.of(licensorPostalCode)) - - /** - * Sets [Builder.licensorPostalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorPostalCode] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorPostalCode(licensorPostalCode: JsonField>) = apply { - this.licensorPostalCode = licensorPostalCode.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorPostalCode]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorPostalCode(licensorPostalCode: String) = apply { - this.licensorPostalCode = - (this.licensorPostalCode ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorPostalCode", it).add(licensorPostalCode) - } - } - - fun licensorRegion(licensorRegion: List) = - licensorRegion(JsonField.of(licensorRegion)) - - /** - * Sets [Builder.licensorRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorRegion] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorRegion(licensorRegion: JsonField>) = apply { - this.licensorRegion = licensorRegion.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorRegion]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorRegion(licensorRegion: String) = apply { - this.licensorRegion = - (this.licensorRegion ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorRegion", it).add(licensorRegion) - } - } - - fun licensorStreetAddress(licensorStreetAddress: List) = - licensorStreetAddress(JsonField.of(licensorStreetAddress)) - - /** - * Sets [Builder.licensorStreetAddress] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorStreetAddress] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun licensorStreetAddress(licensorStreetAddress: JsonField>) = apply { - this.licensorStreetAddress = licensorStreetAddress.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorStreetAddress]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorStreetAddress(licensorStreetAddress: String) = apply { - this.licensorStreetAddress = - (this.licensorStreetAddress ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorStreetAddress", it).add(licensorStreetAddress) - } - } - - fun licensorTelephone1(licensorTelephone1: List) = - licensorTelephone1(JsonField.of(licensorTelephone1)) - - /** - * Sets [Builder.licensorTelephone1] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorTelephone1] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorTelephone1(licensorTelephone1: JsonField>) = apply { - this.licensorTelephone1 = licensorTelephone1.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorTelephone1]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorTelephone1(licensorTelephone1: String) = apply { - this.licensorTelephone1 = - (this.licensorTelephone1 ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorTelephone1", it).add(licensorTelephone1) - } - } - - fun licensorTelephone2(licensorTelephone2: List) = - licensorTelephone2(JsonField.of(licensorTelephone2)) - - /** - * Sets [Builder.licensorTelephone2] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorTelephone2] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorTelephone2(licensorTelephone2: JsonField>) = apply { - this.licensorTelephone2 = licensorTelephone2.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorTelephone2]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorTelephone2(licensorTelephone2: String) = apply { - this.licensorTelephone2 = - (this.licensorTelephone2 ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorTelephone2", it).add(licensorTelephone2) - } - } - - fun licensorUrl(licensorUrl: List) = licensorUrl(JsonField.of(licensorUrl)) - - /** - * Sets [Builder.licensorUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorUrl] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun licensorUrl(licensorUrl: JsonField>) = apply { - this.licensorUrl = licensorUrl.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorUrl]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorUrl(licensorUrl: String) = apply { - this.licensorUrl = - (this.licensorUrl ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorUrl", it).add(licensorUrl) - } - } - - fun linkedEncodedRightsExpr(linkedEncodedRightsExpr: String) = - linkedEncodedRightsExpr(JsonField.of(linkedEncodedRightsExpr)) - - /** - * Sets [Builder.linkedEncodedRightsExpr] to an arbitrary JSON value. - * - * You should usually call [Builder.linkedEncodedRightsExpr] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun linkedEncodedRightsExpr(linkedEncodedRightsExpr: JsonField) = apply { - this.linkedEncodedRightsExpr = linkedEncodedRightsExpr - } - - fun linkedEncodedRightsExprLangId(linkedEncodedRightsExprLangId: String) = - linkedEncodedRightsExprLangId(JsonField.of(linkedEncodedRightsExprLangId)) - - /** - * Sets [Builder.linkedEncodedRightsExprLangId] to an arbitrary JSON value. - * - * You should usually call [Builder.linkedEncodedRightsExprLangId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun linkedEncodedRightsExprLangId(linkedEncodedRightsExprLangId: JsonField) = - apply { - this.linkedEncodedRightsExprLangId = linkedEncodedRightsExprLangId - } - - fun linkedEncodedRightsExprType(linkedEncodedRightsExprType: String) = - linkedEncodedRightsExprType(JsonField.of(linkedEncodedRightsExprType)) - - /** - * Sets [Builder.linkedEncodedRightsExprType] to an arbitrary JSON value. - * - * You should usually call [Builder.linkedEncodedRightsExprType] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun linkedEncodedRightsExprType(linkedEncodedRightsExprType: JsonField) = - apply { - this.linkedEncodedRightsExprType = linkedEncodedRightsExprType - } - - fun location(location: String) = location(JsonField.of(location)) - - /** - * Sets [Builder.location] to an arbitrary JSON value. - * - * You should usually call [Builder.location] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun location(location: JsonField) = apply { this.location = location } - - fun locationCreatedCity(locationCreatedCity: String) = - locationCreatedCity(JsonField.of(locationCreatedCity)) - - /** - * Sets [Builder.locationCreatedCity] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedCity] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun locationCreatedCity(locationCreatedCity: JsonField) = apply { - this.locationCreatedCity = locationCreatedCity - } - - fun locationCreatedCountryCode(locationCreatedCountryCode: String) = - locationCreatedCountryCode(JsonField.of(locationCreatedCountryCode)) - - /** - * Sets [Builder.locationCreatedCountryCode] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedCountryCode] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedCountryCode(locationCreatedCountryCode: JsonField) = apply { - this.locationCreatedCountryCode = locationCreatedCountryCode - } - - fun locationCreatedCountryName(locationCreatedCountryName: String) = - locationCreatedCountryName(JsonField.of(locationCreatedCountryName)) - - /** - * Sets [Builder.locationCreatedCountryName] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedCountryName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedCountryName(locationCreatedCountryName: JsonField) = apply { - this.locationCreatedCountryName = locationCreatedCountryName - } - - fun locationCreatedGpsAltitude(locationCreatedGpsAltitude: String) = - locationCreatedGpsAltitude(JsonField.of(locationCreatedGpsAltitude)) - - /** - * Sets [Builder.locationCreatedGpsAltitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedGpsAltitude] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedGpsAltitude(locationCreatedGpsAltitude: JsonField) = apply { - this.locationCreatedGpsAltitude = locationCreatedGpsAltitude - } - - fun locationCreatedGpsLatitude(locationCreatedGpsLatitude: String) = - locationCreatedGpsLatitude(JsonField.of(locationCreatedGpsLatitude)) - - /** - * Sets [Builder.locationCreatedGpsLatitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedGpsLatitude] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedGpsLatitude(locationCreatedGpsLatitude: JsonField) = apply { - this.locationCreatedGpsLatitude = locationCreatedGpsLatitude - } - - fun locationCreatedGpsLongitude(locationCreatedGpsLongitude: String) = - locationCreatedGpsLongitude(JsonField.of(locationCreatedGpsLongitude)) - - /** - * Sets [Builder.locationCreatedGpsLongitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedGpsLongitude] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedGpsLongitude(locationCreatedGpsLongitude: JsonField) = - apply { - this.locationCreatedGpsLongitude = locationCreatedGpsLongitude - } - - fun locationCreatedLocationId(locationCreatedLocationId: String) = - locationCreatedLocationId(JsonField.of(locationCreatedLocationId)) - - /** - * Sets [Builder.locationCreatedLocationId] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedLocationId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedLocationId(locationCreatedLocationId: JsonField) = apply { - this.locationCreatedLocationId = locationCreatedLocationId - } - - fun locationCreatedLocationName(locationCreatedLocationName: String) = - locationCreatedLocationName(JsonField.of(locationCreatedLocationName)) - - /** - * Sets [Builder.locationCreatedLocationName] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedLocationName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedLocationName(locationCreatedLocationName: JsonField) = - apply { - this.locationCreatedLocationName = locationCreatedLocationName - } - - fun locationCreatedProvinceState(locationCreatedProvinceState: String) = - locationCreatedProvinceState(JsonField.of(locationCreatedProvinceState)) - - /** - * Sets [Builder.locationCreatedProvinceState] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedProvinceState] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedProvinceState(locationCreatedProvinceState: JsonField) = - apply { - this.locationCreatedProvinceState = locationCreatedProvinceState - } - - fun locationCreatedSublocation(locationCreatedSublocation: String) = - locationCreatedSublocation(JsonField.of(locationCreatedSublocation)) - - /** - * Sets [Builder.locationCreatedSublocation] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedSublocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedSublocation(locationCreatedSublocation: JsonField) = apply { - this.locationCreatedSublocation = locationCreatedSublocation - } - - fun locationCreatedWorldRegion(locationCreatedWorldRegion: String) = - locationCreatedWorldRegion(JsonField.of(locationCreatedWorldRegion)) - - /** - * Sets [Builder.locationCreatedWorldRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedWorldRegion] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedWorldRegion(locationCreatedWorldRegion: JsonField) = apply { - this.locationCreatedWorldRegion = locationCreatedWorldRegion - } - - fun locationShownCity(locationShownCity: List) = - locationShownCity(JsonField.of(locationShownCity)) - - /** - * Sets [Builder.locationShownCity] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownCity] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun locationShownCity(locationShownCity: JsonField>) = apply { - this.locationShownCity = locationShownCity.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownCity]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownCity(locationShownCity: String) = apply { - this.locationShownCity = - (this.locationShownCity ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownCity", it).add(locationShownCity) - } - } - - fun locationShownCountryCode(locationShownCountryCode: List) = - locationShownCountryCode(JsonField.of(locationShownCountryCode)) - - /** - * Sets [Builder.locationShownCountryCode] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownCountryCode] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownCountryCode(locationShownCountryCode: JsonField>) = - apply { - this.locationShownCountryCode = - locationShownCountryCode.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownCountryCode]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownCountryCode(locationShownCountryCode: String) = apply { - this.locationShownCountryCode = - (this.locationShownCountryCode ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownCountryCode", it).add(locationShownCountryCode) - } - } - - fun locationShownCountryName(locationShownCountryName: List) = - locationShownCountryName(JsonField.of(locationShownCountryName)) - - /** - * Sets [Builder.locationShownCountryName] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownCountryName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownCountryName(locationShownCountryName: JsonField>) = - apply { - this.locationShownCountryName = - locationShownCountryName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownCountryName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownCountryName(locationShownCountryName: String) = apply { - this.locationShownCountryName = - (this.locationShownCountryName ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownCountryName", it).add(locationShownCountryName) - } - } - - fun locationShownGpsAltitude(locationShownGpsAltitude: List) = - locationShownGpsAltitude(JsonField.of(locationShownGpsAltitude)) - - /** - * Sets [Builder.locationShownGpsAltitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownGpsAltitude] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownGpsAltitude(locationShownGpsAltitude: JsonField>) = - apply { - this.locationShownGpsAltitude = - locationShownGpsAltitude.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownGpsAltitude]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownGpsAltitude(locationShownGpsAltitude: String) = apply { - this.locationShownGpsAltitude = - (this.locationShownGpsAltitude ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownGpsAltitude", it).add(locationShownGpsAltitude) - } - } - - fun locationShownGpsLatitude(locationShownGpsLatitude: List) = - locationShownGpsLatitude(JsonField.of(locationShownGpsLatitude)) - - /** - * Sets [Builder.locationShownGpsLatitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownGpsLatitude] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownGpsLatitude(locationShownGpsLatitude: JsonField>) = - apply { - this.locationShownGpsLatitude = - locationShownGpsLatitude.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownGpsLatitude]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownGpsLatitude(locationShownGpsLatitude: String) = apply { - this.locationShownGpsLatitude = - (this.locationShownGpsLatitude ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownGpsLatitude", it).add(locationShownGpsLatitude) - } - } - - fun locationShownGpsLongitude(locationShownGpsLongitude: List) = - locationShownGpsLongitude(JsonField.of(locationShownGpsLongitude)) - - /** - * Sets [Builder.locationShownGpsLongitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownGpsLongitude] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownGpsLongitude(locationShownGpsLongitude: JsonField>) = - apply { - this.locationShownGpsLongitude = - locationShownGpsLongitude.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownGpsLongitude]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownGpsLongitude(locationShownGpsLongitude: String) = apply { - this.locationShownGpsLongitude = - (this.locationShownGpsLongitude ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownGpsLongitude", it).add(locationShownGpsLongitude) - } - } - - fun locationShownLocationId(locationShownLocationId: List) = - locationShownLocationId(JsonField.of(locationShownLocationId)) - - /** - * Sets [Builder.locationShownLocationId] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownLocationId] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownLocationId(locationShownLocationId: JsonField>) = apply { - this.locationShownLocationId = locationShownLocationId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownLocationId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownLocationId(locationShownLocationId: String) = apply { - this.locationShownLocationId = - (this.locationShownLocationId ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownLocationId", it).add(locationShownLocationId) - } - } - - fun locationShownLocationName(locationShownLocationName: List) = - locationShownLocationName(JsonField.of(locationShownLocationName)) - - /** - * Sets [Builder.locationShownLocationName] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownLocationName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownLocationName(locationShownLocationName: JsonField>) = - apply { - this.locationShownLocationName = - locationShownLocationName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownLocationName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownLocationName(locationShownLocationName: String) = apply { - this.locationShownLocationName = - (this.locationShownLocationName ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownLocationName", it).add(locationShownLocationName) - } - } - - fun locationShownProvinceState(locationShownProvinceState: List) = - locationShownProvinceState(JsonField.of(locationShownProvinceState)) - - /** - * Sets [Builder.locationShownProvinceState] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownProvinceState] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownProvinceState(locationShownProvinceState: JsonField>) = - apply { - this.locationShownProvinceState = - locationShownProvinceState.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownProvinceState]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownProvinceState(locationShownProvinceState: String) = apply { - this.locationShownProvinceState = - (this.locationShownProvinceState ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownProvinceState", it).add(locationShownProvinceState) - } - } - - fun locationShownSublocation(locationShownSublocation: List) = - locationShownSublocation(JsonField.of(locationShownSublocation)) - - /** - * Sets [Builder.locationShownSublocation] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownSublocation] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownSublocation(locationShownSublocation: JsonField>) = - apply { - this.locationShownSublocation = - locationShownSublocation.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownSublocation]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownSublocation(locationShownSublocation: String) = apply { - this.locationShownSublocation = - (this.locationShownSublocation ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownSublocation", it).add(locationShownSublocation) - } - } - - fun locationShownWorldRegion(locationShownWorldRegion: List) = - locationShownWorldRegion(JsonField.of(locationShownWorldRegion)) - - /** - * Sets [Builder.locationShownWorldRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownWorldRegion] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownWorldRegion(locationShownWorldRegion: JsonField>) = - apply { - this.locationShownWorldRegion = - locationShownWorldRegion.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownWorldRegion]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownWorldRegion(locationShownWorldRegion: String) = apply { - this.locationShownWorldRegion = - (this.locationShownWorldRegion ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownWorldRegion", it).add(locationShownWorldRegion) - } - } - - fun maxAvailHeight(maxAvailHeight: Double) = - maxAvailHeight(JsonField.of(maxAvailHeight)) - - /** - * Sets [Builder.maxAvailHeight] to an arbitrary JSON value. - * - * You should usually call [Builder.maxAvailHeight] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxAvailHeight(maxAvailHeight: JsonField) = apply { - this.maxAvailHeight = maxAvailHeight - } - - fun maxAvailWidth(maxAvailWidth: Double) = maxAvailWidth(JsonField.of(maxAvailWidth)) - - /** - * Sets [Builder.maxAvailWidth] to an arbitrary JSON value. - * - * You should usually call [Builder.maxAvailWidth] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxAvailWidth(maxAvailWidth: JsonField) = apply { - this.maxAvailWidth = maxAvailWidth - } - - fun modelAge(modelAge: List) = modelAge(JsonField.of(modelAge)) - - /** - * Sets [Builder.modelAge] to an arbitrary JSON value. - * - * You should usually call [Builder.modelAge] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelAge(modelAge: JsonField>) = apply { - this.modelAge = modelAge.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.modelAge]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addModelAge(modelAge: Double) = apply { - this.modelAge = - (this.modelAge ?: JsonField.of(mutableListOf())).also { - checkKnown("modelAge", it).add(modelAge) - } - } - - fun modelReleaseId(modelReleaseId: List) = - modelReleaseId(JsonField.of(modelReleaseId)) - - /** - * Sets [Builder.modelReleaseId] to an arbitrary JSON value. - * - * You should usually call [Builder.modelReleaseId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun modelReleaseId(modelReleaseId: JsonField>) = apply { - this.modelReleaseId = modelReleaseId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.modelReleaseId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addModelReleaseId(modelReleaseId: String) = apply { - this.modelReleaseId = - (this.modelReleaseId ?: JsonField.of(mutableListOf())).also { - checkKnown("modelReleaseId", it).add(modelReleaseId) - } - } - - fun objectAttributeReference(objectAttributeReference: String) = - objectAttributeReference(JsonField.of(objectAttributeReference)) - - /** - * Sets [Builder.objectAttributeReference] to an arbitrary JSON value. - * - * You should usually call [Builder.objectAttributeReference] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun objectAttributeReference(objectAttributeReference: JsonField) = apply { - this.objectAttributeReference = objectAttributeReference - } - - fun objectName(objectName: String) = objectName(JsonField.of(objectName)) - - /** - * Sets [Builder.objectName] to an arbitrary JSON value. - * - * You should usually call [Builder.objectName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun objectName(objectName: JsonField) = apply { this.objectName = objectName } - - fun offsetTimeOriginal(offsetTimeOriginal: String) = - offsetTimeOriginal(JsonField.of(offsetTimeOriginal)) - - /** - * Sets [Builder.offsetTimeOriginal] to an arbitrary JSON value. - * - * You should usually call [Builder.offsetTimeOriginal] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun offsetTimeOriginal(offsetTimeOriginal: JsonField) = apply { - this.offsetTimeOriginal = offsetTimeOriginal - } - - fun organisationInImageCode(organisationInImageCode: List) = - organisationInImageCode(JsonField.of(organisationInImageCode)) - - /** - * Sets [Builder.organisationInImageCode] to an arbitrary JSON value. - * - * You should usually call [Builder.organisationInImageCode] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun organisationInImageCode(organisationInImageCode: JsonField>) = apply { - this.organisationInImageCode = organisationInImageCode.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.organisationInImageCode]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addOrganisationInImageCode(organisationInImageCode: String) = apply { - this.organisationInImageCode = - (this.organisationInImageCode ?: JsonField.of(mutableListOf())).also { - checkKnown("organisationInImageCode", it).add(organisationInImageCode) - } - } - - fun organisationInImageName(organisationInImageName: List) = - organisationInImageName(JsonField.of(organisationInImageName)) - - /** - * Sets [Builder.organisationInImageName] to an arbitrary JSON value. - * - * You should usually call [Builder.organisationInImageName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun organisationInImageName(organisationInImageName: JsonField>) = apply { - this.organisationInImageName = organisationInImageName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.organisationInImageName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addOrganisationInImageName(organisationInImageName: String) = apply { - this.organisationInImageName = - (this.organisationInImageName ?: JsonField.of(mutableListOf())).also { - checkKnown("organisationInImageName", it).add(organisationInImageName) - } - } - - fun orientation(orientation: String) = orientation(JsonField.of(orientation)) - - /** - * Sets [Builder.orientation] to an arbitrary JSON value. - * - * You should usually call [Builder.orientation] with a well-typed [String] 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 originalTransmissionReference(originalTransmissionReference: String) = - originalTransmissionReference(JsonField.of(originalTransmissionReference)) - - /** - * Sets [Builder.originalTransmissionReference] to an arbitrary JSON value. - * - * You should usually call [Builder.originalTransmissionReference] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun originalTransmissionReference(originalTransmissionReference: JsonField) = - apply { - this.originalTransmissionReference = originalTransmissionReference - } - - fun personInImage(personInImage: List) = - personInImage(JsonField.of(personInImage)) - - /** - * Sets [Builder.personInImage] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImage] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun personInImage(personInImage: JsonField>) = apply { - this.personInImage = personInImage.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImage]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImage(personInImage: String) = apply { - this.personInImage = - (this.personInImage ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImage", it).add(personInImage) - } - } - - fun personInImageCvTermCvId(personInImageCvTermCvId: List) = - personInImageCvTermCvId(JsonField.of(personInImageCvTermCvId)) - - /** - * Sets [Builder.personInImageCvTermCvId] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageCvTermCvId] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageCvTermCvId(personInImageCvTermCvId: JsonField>) = apply { - this.personInImageCvTermCvId = personInImageCvTermCvId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageCvTermCvId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageCvTermCvId(personInImageCvTermCvId: String) = apply { - this.personInImageCvTermCvId = - (this.personInImageCvTermCvId ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageCvTermCvId", it).add(personInImageCvTermCvId) - } - } - - fun personInImageCvTermId(personInImageCvTermId: List) = - personInImageCvTermId(JsonField.of(personInImageCvTermId)) - - /** - * Sets [Builder.personInImageCvTermId] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageCvTermId] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageCvTermId(personInImageCvTermId: JsonField>) = apply { - this.personInImageCvTermId = personInImageCvTermId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageCvTermId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageCvTermId(personInImageCvTermId: String) = apply { - this.personInImageCvTermId = - (this.personInImageCvTermId ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageCvTermId", it).add(personInImageCvTermId) - } - } - - fun personInImageCvTermName(personInImageCvTermName: List) = - personInImageCvTermName(JsonField.of(personInImageCvTermName)) - - /** - * Sets [Builder.personInImageCvTermName] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageCvTermName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageCvTermName(personInImageCvTermName: JsonField>) = apply { - this.personInImageCvTermName = personInImageCvTermName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageCvTermName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageCvTermName(personInImageCvTermName: String) = apply { - this.personInImageCvTermName = - (this.personInImageCvTermName ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageCvTermName", it).add(personInImageCvTermName) - } - } - - fun personInImageCvTermRefinedAbout(personInImageCvTermRefinedAbout: List) = - personInImageCvTermRefinedAbout(JsonField.of(personInImageCvTermRefinedAbout)) - - /** - * Sets [Builder.personInImageCvTermRefinedAbout] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageCvTermRefinedAbout] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageCvTermRefinedAbout( - personInImageCvTermRefinedAbout: JsonField> - ) = apply { - this.personInImageCvTermRefinedAbout = - personInImageCvTermRefinedAbout.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageCvTermRefinedAbout]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageCvTermRefinedAbout(personInImageCvTermRefinedAbout: String) = - apply { - this.personInImageCvTermRefinedAbout = - (this.personInImageCvTermRefinedAbout ?: JsonField.of(mutableListOf())) - .also { - checkKnown("personInImageCvTermRefinedAbout", it) - .add(personInImageCvTermRefinedAbout) - } - } - - fun personInImageDescription(personInImageDescription: List) = - personInImageDescription(JsonField.of(personInImageDescription)) - - /** - * Sets [Builder.personInImageDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageDescription] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageDescription(personInImageDescription: JsonField>) = - apply { - this.personInImageDescription = - personInImageDescription.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageDescription]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageDescription(personInImageDescription: String) = apply { - this.personInImageDescription = - (this.personInImageDescription ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageDescription", it).add(personInImageDescription) - } - } - - fun personInImageId(personInImageId: List) = - personInImageId(JsonField.of(personInImageId)) - - /** - * Sets [Builder.personInImageId] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun personInImageId(personInImageId: JsonField>) = apply { - this.personInImageId = personInImageId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageId(personInImageId: String) = apply { - this.personInImageId = - (this.personInImageId ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageId", it).add(personInImageId) - } - } - - fun personInImageName(personInImageName: List) = - personInImageName(JsonField.of(personInImageName)) - - /** - * Sets [Builder.personInImageName] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageName] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun personInImageName(personInImageName: JsonField>) = apply { - this.personInImageName = personInImageName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageName(personInImageName: String) = apply { - this.personInImageName = - (this.personInImageName ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageName", it).add(personInImageName) - } - } - - fun productInImageDescription(productInImageDescription: List) = - productInImageDescription(JsonField.of(productInImageDescription)) - - /** - * Sets [Builder.productInImageDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.productInImageDescription] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun productInImageDescription(productInImageDescription: JsonField>) = - apply { - this.productInImageDescription = - productInImageDescription.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.productInImageDescription]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProductInImageDescription(productInImageDescription: String) = apply { - this.productInImageDescription = - (this.productInImageDescription ?: JsonField.of(mutableListOf())).also { - checkKnown("productInImageDescription", it).add(productInImageDescription) - } - } - - fun productInImageGtin(productInImageGtin: List) = - productInImageGtin(JsonField.of(productInImageGtin)) - - /** - * Sets [Builder.productInImageGtin] to an arbitrary JSON value. - * - * You should usually call [Builder.productInImageGtin] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun productInImageGtin(productInImageGtin: JsonField>) = apply { - this.productInImageGtin = productInImageGtin.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.productInImageGtin]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProductInImageGtin(productInImageGtin: Double) = apply { - this.productInImageGtin = - (this.productInImageGtin ?: JsonField.of(mutableListOf())).also { - checkKnown("productInImageGtin", it).add(productInImageGtin) - } - } - - fun productInImageName(productInImageName: List) = - productInImageName(JsonField.of(productInImageName)) - - /** - * Sets [Builder.productInImageName] to an arbitrary JSON value. - * - * You should usually call [Builder.productInImageName] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun productInImageName(productInImageName: JsonField>) = apply { - this.productInImageName = productInImageName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.productInImageName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProductInImageName(productInImageName: String) = apply { - this.productInImageName = - (this.productInImageName ?: JsonField.of(mutableListOf())).also { - checkKnown("productInImageName", it).add(productInImageName) - } - } - - fun propertyReleaseId(propertyReleaseId: List) = - propertyReleaseId(JsonField.of(propertyReleaseId)) - - /** - * Sets [Builder.propertyReleaseId] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyReleaseId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun propertyReleaseId(propertyReleaseId: JsonField>) = apply { - this.propertyReleaseId = propertyReleaseId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.propertyReleaseId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPropertyReleaseId(propertyReleaseId: String) = apply { - this.propertyReleaseId = - (this.propertyReleaseId ?: JsonField.of(mutableListOf())).also { - checkKnown("propertyReleaseId", it).add(propertyReleaseId) - } - } - - fun provinceState(provinceState: String) = provinceState(JsonField.of(provinceState)) - - /** - * Sets [Builder.provinceState] to an arbitrary JSON value. - * - * You should usually call [Builder.provinceState] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun provinceState(provinceState: JsonField) = apply { - this.provinceState = provinceState - } - - fun rating(rating: Long) = rating(JsonField.of(rating)) - - /** - * Sets [Builder.rating] to an arbitrary JSON value. - * - * You should usually call [Builder.rating] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun rating(rating: JsonField) = apply { this.rating = rating } - - fun registryEntryRole(registryEntryRole: List) = - registryEntryRole(JsonField.of(registryEntryRole)) - - /** - * Sets [Builder.registryEntryRole] to an arbitrary JSON value. - * - * You should usually call [Builder.registryEntryRole] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun registryEntryRole(registryEntryRole: JsonField>) = apply { - this.registryEntryRole = registryEntryRole.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.registryEntryRole]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRegistryEntryRole(registryEntryRole: String) = apply { - this.registryEntryRole = - (this.registryEntryRole ?: JsonField.of(mutableListOf())).also { - checkKnown("registryEntryRole", it).add(registryEntryRole) - } - } - - fun registryItemId(registryItemId: List) = - registryItemId(JsonField.of(registryItemId)) - - /** - * Sets [Builder.registryItemId] to an arbitrary JSON value. - * - * You should usually call [Builder.registryItemId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun registryItemId(registryItemId: JsonField>) = apply { - this.registryItemId = registryItemId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.registryItemId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRegistryItemId(registryItemId: String) = apply { - this.registryItemId = - (this.registryItemId ?: JsonField.of(mutableListOf())).also { - checkKnown("registryItemId", it).add(registryItemId) - } - } - - fun registryOrganisationId(registryOrganisationId: List) = - registryOrganisationId(JsonField.of(registryOrganisationId)) - - /** - * Sets [Builder.registryOrganisationId] to an arbitrary JSON value. - * - * You should usually call [Builder.registryOrganisationId] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun registryOrganisationId(registryOrganisationId: JsonField>) = apply { - this.registryOrganisationId = registryOrganisationId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.registryOrganisationId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRegistryOrganisationId(registryOrganisationId: String) = apply { - this.registryOrganisationId = - (this.registryOrganisationId ?: JsonField.of(mutableListOf())).also { - checkKnown("registryOrganisationId", it).add(registryOrganisationId) - } - } - - fun resolutionUnit(resolutionUnit: String) = - resolutionUnit(JsonField.of(resolutionUnit)) - - /** - * Sets [Builder.resolutionUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.resolutionUnit] with a well-typed [String] 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 rights(rights: String) = rights(JsonField.of(rights)) - - /** - * Sets [Builder.rights] to an arbitrary JSON value. - * - * You should usually call [Builder.rights] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rights(rights: JsonField) = apply { this.rights = rights } - - fun scene(scene: List) = scene(JsonField.of(scene)) - - /** - * Sets [Builder.scene] to an arbitrary JSON value. - * - * You should usually call [Builder.scene] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun scene(scene: JsonField>) = apply { - this.scene = scene.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.scene]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addScene(scene: String) = apply { - this.scene = - (this.scene ?: JsonField.of(mutableListOf())).also { - checkKnown("scene", it).add(scene) - } - } - - 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 specialInstructions(specialInstructions: String) = - specialInstructions(JsonField.of(specialInstructions)) - - /** - * Sets [Builder.specialInstructions] to an arbitrary JSON value. - * - * You should usually call [Builder.specialInstructions] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun specialInstructions(specialInstructions: JsonField) = apply { - this.specialInstructions = specialInstructions - } - - fun state(state: String) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun state(state: JsonField) = apply { this.state = state } - - fun subject(subject: List) = subject(JsonField.of(subject)) - - /** - * Sets [Builder.subject] to an arbitrary JSON value. - * - * You should usually call [Builder.subject] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun subject(subject: JsonField>) = apply { - this.subject = subject.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.subject]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSubject(subject: String) = apply { - this.subject = - (this.subject ?: JsonField.of(mutableListOf())).also { - checkKnown("subject", it).add(subject) - } - } - - fun subjectCode(subjectCode: List) = subjectCode(JsonField.of(subjectCode)) - - /** - * Sets [Builder.subjectCode] to an arbitrary JSON value. - * - * You should usually call [Builder.subjectCode] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun subjectCode(subjectCode: JsonField>) = apply { - this.subjectCode = subjectCode.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.subjectCode]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSubjectCode(subjectCode: String) = apply { - this.subjectCode = - (this.subjectCode ?: JsonField.of(mutableListOf())).also { - checkKnown("subjectCode", it).add(subjectCode) - } - } - - fun subjectReference(subjectReference: List) = - subjectReference(JsonField.of(subjectReference)) - - /** - * Sets [Builder.subjectReference] to an arbitrary JSON value. - * - * You should usually call [Builder.subjectReference] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun subjectReference(subjectReference: JsonField>) = apply { - this.subjectReference = subjectReference.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.subjectReference]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSubjectReference(subjectReference: String) = apply { - this.subjectReference = - (this.subjectReference ?: JsonField.of(mutableListOf())).also { - checkKnown("subjectReference", it).add(subjectReference) - } - } - - fun sublocation(sublocation: String) = sublocation(JsonField.of(sublocation)) - - /** - * Sets [Builder.sublocation] to an arbitrary JSON value. - * - * You should usually call [Builder.sublocation] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sublocation(sublocation: JsonField) = apply { - this.sublocation = sublocation - } - - fun timeCreated(timeCreated: String) = timeCreated(JsonField.of(timeCreated)) - - /** - * Sets [Builder.timeCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.timeCreated] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun timeCreated(timeCreated: JsonField) = apply { - this.timeCreated = timeCreated - } - - fun title(title: String) = title(JsonField.of(title)) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun title(title: JsonField) = apply { this.title = title } - - fun transmissionReference(transmissionReference: String) = - transmissionReference(JsonField.of(transmissionReference)) - - /** - * Sets [Builder.transmissionReference] to an arbitrary JSON value. - * - * You should usually call [Builder.transmissionReference] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun transmissionReference(transmissionReference: JsonField) = apply { - this.transmissionReference = transmissionReference - } - - fun usageTerms(usageTerms: String) = usageTerms(JsonField.of(usageTerms)) - - /** - * Sets [Builder.usageTerms] to an arbitrary JSON value. - * - * You should usually call [Builder.usageTerms] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun usageTerms(usageTerms: JsonField) = apply { this.usageTerms = usageTerms } - - fun webStatement(webStatement: String) = webStatement(JsonField.of(webStatement)) - - /** - * Sets [Builder.webStatement] to an arbitrary JSON value. - * - * You should usually call [Builder.webStatement] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun webStatement(webStatement: JsonField) = apply { - this.webStatement = webStatement - } - - fun writer(writer: String) = writer(JsonField.of(writer)) - - /** - * Sets [Builder.writer] to an arbitrary JSON value. - * - * You should usually call [Builder.writer] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun writer(writer: JsonField) = apply { this.writer = writer } - - fun writerEditor(writerEditor: String) = writerEditor(JsonField.of(writerEditor)) - - /** - * Sets [Builder.writerEditor] to an arbitrary JSON value. - * - * You should usually call [Builder.writerEditor] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun writerEditor(writerEditor: JsonField) = apply { - this.writerEditor = writerEditor - } - - fun xResolution(xResolution: Double) = xResolution(JsonField.of(xResolution)) - - /** - * Sets [Builder.xResolution] to an arbitrary JSON value. - * - * You should usually call [Builder.xResolution] with a well-typed [Double] 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: Double) = yResolution(JsonField.of(yResolution)) - - /** - * Sets [Builder.yResolution] to an arbitrary JSON value. - * - * You should usually call [Builder.yResolution] with a well-typed [Double] 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 [EmbeddedMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EmbeddedMetadata = - EmbeddedMetadata( - aboutCvTermCvId, - aboutCvTermId, - aboutCvTermName, - aboutCvTermRefinedAbout, - additionalModelInformation, - applicationRecordVersion, - artist, - artworkCircaDateCreated, - artworkContentDescription, - artworkContributionDescription, - artworkCopyrightNotice, - artworkCopyrightOwnerId, - artworkCopyrightOwnerName, - (artworkCreator ?: JsonMissing.of()).map { it.toImmutable() }, - (artworkCreatorId ?: JsonMissing.of()).map { it.toImmutable() }, - artworkDateCreated, - artworkLicensorId, - artworkLicensorName, - artworkPhysicalDescription, - artworkSource, - artworkSourceInventoryNo, - artworkSourceInvUrl, - (artworkStylePeriod ?: JsonMissing.of()).map { it.toImmutable() }, - artworkTitle, - authorsPosition, - byline, - bylineTitle, - caption, - captionAbstract, - captionWriter, - city, - colorSpace, - componentsConfiguration, - copyright, - copyrightNotice, - (copyrightOwnerId ?: JsonMissing.of()).map { it.toImmutable() }, - (copyrightOwnerName ?: JsonMissing.of()).map { it.toImmutable() }, - country, - countryCode, - countryPrimaryLocationCode, - countryPrimaryLocationName, - creator, - creatorAddress, - creatorCity, - creatorCountry, - creatorPostalCode, - creatorRegion, - creatorWorkEmail, - creatorWorkTelephone, - creatorWorkUrl, - credit, - dateCreated, - dateTimeCreated, - dateTimeOriginal, - description, - digitalImageGuid, - digitalSourceType, - embeddedEncodedRightsExpr, - embeddedEncodedRightsExprLangId, - embeddedEncodedRightsExprType, - event, - exifVersion, - flashpixVersion, - genreCvId, - genreCvTermId, - genreCvTermName, - genreCvTermRefinedAbout, - headline, - imageCreatorId, - imageCreatorImageId, - imageCreatorName, - imageDescription, - (imageRegionBoundaryH ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryRx ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryShape ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryUnit ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryVerticesX ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryVerticesY ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryW ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryX ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryY ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionCtypeIdentifier ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionCtypeName ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionId ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionName ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionOrganisationInImageName ?: JsonMissing.of()).map { - it.toImmutable() - }, - (imageRegionPersonInImage ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionRoleIdentifier ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionRoleName ?: JsonMissing.of()).map { it.toImmutable() }, - imageSupplierId, - imageSupplierImageId, - imageSupplierName, - instructions, - intellectualGenre, - (keywords ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorCity ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorCountry ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorEmail ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorExtendedAddress ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorId ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorName ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorPostalCode ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorRegion ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorStreetAddress ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorTelephone1 ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorTelephone2 ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorUrl ?: JsonMissing.of()).map { it.toImmutable() }, - linkedEncodedRightsExpr, - linkedEncodedRightsExprLangId, - linkedEncodedRightsExprType, - location, - locationCreatedCity, - locationCreatedCountryCode, - locationCreatedCountryName, - locationCreatedGpsAltitude, - locationCreatedGpsLatitude, - locationCreatedGpsLongitude, - locationCreatedLocationId, - locationCreatedLocationName, - locationCreatedProvinceState, - locationCreatedSublocation, - locationCreatedWorldRegion, - (locationShownCity ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownCountryCode ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownCountryName ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownGpsAltitude ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownGpsLatitude ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownGpsLongitude ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownLocationId ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownLocationName ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownProvinceState ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownSublocation ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownWorldRegion ?: JsonMissing.of()).map { it.toImmutable() }, - maxAvailHeight, - maxAvailWidth, - (modelAge ?: JsonMissing.of()).map { it.toImmutable() }, - (modelReleaseId ?: JsonMissing.of()).map { it.toImmutable() }, - objectAttributeReference, - objectName, - offsetTimeOriginal, - (organisationInImageCode ?: JsonMissing.of()).map { it.toImmutable() }, - (organisationInImageName ?: JsonMissing.of()).map { it.toImmutable() }, - orientation, - originalTransmissionReference, - (personInImage ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageCvTermCvId ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageCvTermId ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageCvTermName ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageCvTermRefinedAbout ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageDescription ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageId ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageName ?: JsonMissing.of()).map { it.toImmutable() }, - (productInImageDescription ?: JsonMissing.of()).map { it.toImmutable() }, - (productInImageGtin ?: JsonMissing.of()).map { it.toImmutable() }, - (productInImageName ?: JsonMissing.of()).map { it.toImmutable() }, - (propertyReleaseId ?: JsonMissing.of()).map { it.toImmutable() }, - provinceState, - rating, - (registryEntryRole ?: JsonMissing.of()).map { it.toImmutable() }, - (registryItemId ?: JsonMissing.of()).map { it.toImmutable() }, - (registryOrganisationId ?: JsonMissing.of()).map { it.toImmutable() }, - resolutionUnit, - rights, - (scene ?: JsonMissing.of()).map { it.toImmutable() }, - source, - specialInstructions, - state, - (subject ?: JsonMissing.of()).map { it.toImmutable() }, - (subjectCode ?: JsonMissing.of()).map { it.toImmutable() }, - (subjectReference ?: JsonMissing.of()).map { it.toImmutable() }, - sublocation, - timeCreated, - title, - transmissionReference, - usageTerms, - webStatement, - writer, - writerEditor, - xResolution, - yResolution, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmbeddedMetadata = apply { - if (validated) { - return@apply - } - - aboutCvTermCvId() - aboutCvTermId() - aboutCvTermName() - aboutCvTermRefinedAbout() - additionalModelInformation() - applicationRecordVersion() - artist() - artworkCircaDateCreated() - artworkContentDescription() - artworkContributionDescription() - artworkCopyrightNotice() - artworkCopyrightOwnerId() - artworkCopyrightOwnerName() - artworkCreator() - artworkCreatorId() - artworkDateCreated() - artworkLicensorId() - artworkLicensorName() - artworkPhysicalDescription() - artworkSource() - artworkSourceInventoryNo() - artworkSourceInvUrl() - artworkStylePeriod() - artworkTitle() - authorsPosition() - byline() - bylineTitle() - caption() - captionAbstract() - captionWriter() - city() - colorSpace() - componentsConfiguration() - copyright() - copyrightNotice() - copyrightOwnerId() - copyrightOwnerName() - country() - countryCode() - countryPrimaryLocationCode() - countryPrimaryLocationName() - creator() - creatorAddress() - creatorCity() - creatorCountry() - creatorPostalCode() - creatorRegion() - creatorWorkEmail() - creatorWorkTelephone() - creatorWorkUrl() - credit() - dateCreated() - dateTimeCreated() - dateTimeOriginal() - description() - digitalImageGuid() - digitalSourceType() - embeddedEncodedRightsExpr() - embeddedEncodedRightsExprLangId() - embeddedEncodedRightsExprType() - event() - exifVersion() - flashpixVersion() - genreCvId() - genreCvTermId() - genreCvTermName() - genreCvTermRefinedAbout() - headline() - imageCreatorId() - imageCreatorImageId() - imageCreatorName() - imageDescription() - imageRegionBoundaryH() - imageRegionBoundaryRx() - imageRegionBoundaryShape() - imageRegionBoundaryUnit() - imageRegionBoundaryVerticesX() - imageRegionBoundaryVerticesY() - imageRegionBoundaryW() - imageRegionBoundaryX() - imageRegionBoundaryY() - imageRegionCtypeIdentifier() - imageRegionCtypeName() - imageRegionId() - imageRegionName() - imageRegionOrganisationInImageName() - imageRegionPersonInImage() - imageRegionRoleIdentifier() - imageRegionRoleName() - imageSupplierId() - imageSupplierImageId() - imageSupplierName() - instructions() - intellectualGenre() - keywords() - licensorCity() - licensorCountry() - licensorEmail() - licensorExtendedAddress() - licensorId() - licensorName() - licensorPostalCode() - licensorRegion() - licensorStreetAddress() - licensorTelephone1() - licensorTelephone2() - licensorUrl() - linkedEncodedRightsExpr() - linkedEncodedRightsExprLangId() - linkedEncodedRightsExprType() - location() - locationCreatedCity() - locationCreatedCountryCode() - locationCreatedCountryName() - locationCreatedGpsAltitude() - locationCreatedGpsLatitude() - locationCreatedGpsLongitude() - locationCreatedLocationId() - locationCreatedLocationName() - locationCreatedProvinceState() - locationCreatedSublocation() - locationCreatedWorldRegion() - locationShownCity() - locationShownCountryCode() - locationShownCountryName() - locationShownGpsAltitude() - locationShownGpsLatitude() - locationShownGpsLongitude() - locationShownLocationId() - locationShownLocationName() - locationShownProvinceState() - locationShownSublocation() - locationShownWorldRegion() - maxAvailHeight() - maxAvailWidth() - modelAge() - modelReleaseId() - objectAttributeReference() - objectName() - offsetTimeOriginal() - organisationInImageCode() - organisationInImageName() - orientation() - originalTransmissionReference() - personInImage() - personInImageCvTermCvId() - personInImageCvTermId() - personInImageCvTermName() - personInImageCvTermRefinedAbout() - personInImageDescription() - personInImageId() - personInImageName() - productInImageDescription() - productInImageGtin() - productInImageName() - propertyReleaseId() - provinceState() - rating() - registryEntryRole() - registryItemId() - registryOrganisationId() - resolutionUnit() - rights() - scene() - source() - specialInstructions() - state() - subject() - subjectCode() - subjectReference() - sublocation() - timeCreated() - title() - transmissionReference() - usageTerms() - webStatement() - writer() - writerEditor() - 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 (aboutCvTermCvId.asKnown().isPresent) 1 else 0) + - (if (aboutCvTermId.asKnown().isPresent) 1 else 0) + - (if (aboutCvTermName.asKnown().isPresent) 1 else 0) + - (if (aboutCvTermRefinedAbout.asKnown().isPresent) 1 else 0) + - (if (additionalModelInformation.asKnown().isPresent) 1 else 0) + - (if (applicationRecordVersion.asKnown().isPresent) 1 else 0) + - (if (artist.asKnown().isPresent) 1 else 0) + - (if (artworkCircaDateCreated.asKnown().isPresent) 1 else 0) + - (if (artworkContentDescription.asKnown().isPresent) 1 else 0) + - (if (artworkContributionDescription.asKnown().isPresent) 1 else 0) + - (if (artworkCopyrightNotice.asKnown().isPresent) 1 else 0) + - (if (artworkCopyrightOwnerId.asKnown().isPresent) 1 else 0) + - (if (artworkCopyrightOwnerName.asKnown().isPresent) 1 else 0) + - (artworkCreator.asKnown().getOrNull()?.size ?: 0) + - (artworkCreatorId.asKnown().getOrNull()?.size ?: 0) + - (if (artworkDateCreated.asKnown().isPresent) 1 else 0) + - (if (artworkLicensorId.asKnown().isPresent) 1 else 0) + - (if (artworkLicensorName.asKnown().isPresent) 1 else 0) + - (if (artworkPhysicalDescription.asKnown().isPresent) 1 else 0) + - (if (artworkSource.asKnown().isPresent) 1 else 0) + - (if (artworkSourceInventoryNo.asKnown().isPresent) 1 else 0) + - (if (artworkSourceInvUrl.asKnown().isPresent) 1 else 0) + - (artworkStylePeriod.asKnown().getOrNull()?.size ?: 0) + - (if (artworkTitle.asKnown().isPresent) 1 else 0) + - (if (authorsPosition.asKnown().isPresent) 1 else 0) + - (if (byline.asKnown().isPresent) 1 else 0) + - (if (bylineTitle.asKnown().isPresent) 1 else 0) + - (if (caption.asKnown().isPresent) 1 else 0) + - (if (captionAbstract.asKnown().isPresent) 1 else 0) + - (if (captionWriter.asKnown().isPresent) 1 else 0) + - (if (city.asKnown().isPresent) 1 else 0) + - (if (colorSpace.asKnown().isPresent) 1 else 0) + - (if (componentsConfiguration.asKnown().isPresent) 1 else 0) + - (if (copyright.asKnown().isPresent) 1 else 0) + - (if (copyrightNotice.asKnown().isPresent) 1 else 0) + - (copyrightOwnerId.asKnown().getOrNull()?.size ?: 0) + - (copyrightOwnerName.asKnown().getOrNull()?.size ?: 0) + - (if (country.asKnown().isPresent) 1 else 0) + - (if (countryCode.asKnown().isPresent) 1 else 0) + - (if (countryPrimaryLocationCode.asKnown().isPresent) 1 else 0) + - (if (countryPrimaryLocationName.asKnown().isPresent) 1 else 0) + - (if (creator.asKnown().isPresent) 1 else 0) + - (if (creatorAddress.asKnown().isPresent) 1 else 0) + - (if (creatorCity.asKnown().isPresent) 1 else 0) + - (if (creatorCountry.asKnown().isPresent) 1 else 0) + - (if (creatorPostalCode.asKnown().isPresent) 1 else 0) + - (if (creatorRegion.asKnown().isPresent) 1 else 0) + - (if (creatorWorkEmail.asKnown().isPresent) 1 else 0) + - (if (creatorWorkTelephone.asKnown().isPresent) 1 else 0) + - (if (creatorWorkUrl.asKnown().isPresent) 1 else 0) + - (if (credit.asKnown().isPresent) 1 else 0) + - (if (dateCreated.asKnown().isPresent) 1 else 0) + - (if (dateTimeCreated.asKnown().isPresent) 1 else 0) + - (if (dateTimeOriginal.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (digitalImageGuid.asKnown().isPresent) 1 else 0) + - (if (digitalSourceType.asKnown().isPresent) 1 else 0) + - (if (embeddedEncodedRightsExpr.asKnown().isPresent) 1 else 0) + - (if (embeddedEncodedRightsExprLangId.asKnown().isPresent) 1 else 0) + - (if (embeddedEncodedRightsExprType.asKnown().isPresent) 1 else 0) + - (if (event.asKnown().isPresent) 1 else 0) + - (if (exifVersion.asKnown().isPresent) 1 else 0) + - (if (flashpixVersion.asKnown().isPresent) 1 else 0) + - (if (genreCvId.asKnown().isPresent) 1 else 0) + - (if (genreCvTermId.asKnown().isPresent) 1 else 0) + - (if (genreCvTermName.asKnown().isPresent) 1 else 0) + - (if (genreCvTermRefinedAbout.asKnown().isPresent) 1 else 0) + - (if (headline.asKnown().isPresent) 1 else 0) + - (if (imageCreatorId.asKnown().isPresent) 1 else 0) + - (if (imageCreatorImageId.asKnown().isPresent) 1 else 0) + - (if (imageCreatorName.asKnown().isPresent) 1 else 0) + - (if (imageDescription.asKnown().isPresent) 1 else 0) + - (imageRegionBoundaryH.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryRx.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryShape.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryUnit.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryVerticesX.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryVerticesY.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryW.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryX.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryY.asKnown().getOrNull()?.size ?: 0) + - (imageRegionCtypeIdentifier.asKnown().getOrNull()?.size ?: 0) + - (imageRegionCtypeName.asKnown().getOrNull()?.size ?: 0) + - (imageRegionId.asKnown().getOrNull()?.size ?: 0) + - (imageRegionName.asKnown().getOrNull()?.size ?: 0) + - (imageRegionOrganisationInImageName.asKnown().getOrNull()?.size ?: 0) + - (imageRegionPersonInImage.asKnown().getOrNull()?.size ?: 0) + - (imageRegionRoleIdentifier.asKnown().getOrNull()?.size ?: 0) + - (imageRegionRoleName.asKnown().getOrNull()?.size ?: 0) + - (if (imageSupplierId.asKnown().isPresent) 1 else 0) + - (if (imageSupplierImageId.asKnown().isPresent) 1 else 0) + - (if (imageSupplierName.asKnown().isPresent) 1 else 0) + - (if (instructions.asKnown().isPresent) 1 else 0) + - (if (intellectualGenre.asKnown().isPresent) 1 else 0) + - (keywords.asKnown().getOrNull()?.size ?: 0) + - (licensorCity.asKnown().getOrNull()?.size ?: 0) + - (licensorCountry.asKnown().getOrNull()?.size ?: 0) + - (licensorEmail.asKnown().getOrNull()?.size ?: 0) + - (licensorExtendedAddress.asKnown().getOrNull()?.size ?: 0) + - (licensorId.asKnown().getOrNull()?.size ?: 0) + - (licensorName.asKnown().getOrNull()?.size ?: 0) + - (licensorPostalCode.asKnown().getOrNull()?.size ?: 0) + - (licensorRegion.asKnown().getOrNull()?.size ?: 0) + - (licensorStreetAddress.asKnown().getOrNull()?.size ?: 0) + - (licensorTelephone1.asKnown().getOrNull()?.size ?: 0) + - (licensorTelephone2.asKnown().getOrNull()?.size ?: 0) + - (licensorUrl.asKnown().getOrNull()?.size ?: 0) + - (if (linkedEncodedRightsExpr.asKnown().isPresent) 1 else 0) + - (if (linkedEncodedRightsExprLangId.asKnown().isPresent) 1 else 0) + - (if (linkedEncodedRightsExprType.asKnown().isPresent) 1 else 0) + - (if (location.asKnown().isPresent) 1 else 0) + - (if (locationCreatedCity.asKnown().isPresent) 1 else 0) + - (if (locationCreatedCountryCode.asKnown().isPresent) 1 else 0) + - (if (locationCreatedCountryName.asKnown().isPresent) 1 else 0) + - (if (locationCreatedGpsAltitude.asKnown().isPresent) 1 else 0) + - (if (locationCreatedGpsLatitude.asKnown().isPresent) 1 else 0) + - (if (locationCreatedGpsLongitude.asKnown().isPresent) 1 else 0) + - (if (locationCreatedLocationId.asKnown().isPresent) 1 else 0) + - (if (locationCreatedLocationName.asKnown().isPresent) 1 else 0) + - (if (locationCreatedProvinceState.asKnown().isPresent) 1 else 0) + - (if (locationCreatedSublocation.asKnown().isPresent) 1 else 0) + - (if (locationCreatedWorldRegion.asKnown().isPresent) 1 else 0) + - (locationShownCity.asKnown().getOrNull()?.size ?: 0) + - (locationShownCountryCode.asKnown().getOrNull()?.size ?: 0) + - (locationShownCountryName.asKnown().getOrNull()?.size ?: 0) + - (locationShownGpsAltitude.asKnown().getOrNull()?.size ?: 0) + - (locationShownGpsLatitude.asKnown().getOrNull()?.size ?: 0) + - (locationShownGpsLongitude.asKnown().getOrNull()?.size ?: 0) + - (locationShownLocationId.asKnown().getOrNull()?.size ?: 0) + - (locationShownLocationName.asKnown().getOrNull()?.size ?: 0) + - (locationShownProvinceState.asKnown().getOrNull()?.size ?: 0) + - (locationShownSublocation.asKnown().getOrNull()?.size ?: 0) + - (locationShownWorldRegion.asKnown().getOrNull()?.size ?: 0) + - (if (maxAvailHeight.asKnown().isPresent) 1 else 0) + - (if (maxAvailWidth.asKnown().isPresent) 1 else 0) + - (modelAge.asKnown().getOrNull()?.size ?: 0) + - (modelReleaseId.asKnown().getOrNull()?.size ?: 0) + - (if (objectAttributeReference.asKnown().isPresent) 1 else 0) + - (if (objectName.asKnown().isPresent) 1 else 0) + - (if (offsetTimeOriginal.asKnown().isPresent) 1 else 0) + - (organisationInImageCode.asKnown().getOrNull()?.size ?: 0) + - (organisationInImageName.asKnown().getOrNull()?.size ?: 0) + - (if (orientation.asKnown().isPresent) 1 else 0) + - (if (originalTransmissionReference.asKnown().isPresent) 1 else 0) + - (personInImage.asKnown().getOrNull()?.size ?: 0) + - (personInImageCvTermCvId.asKnown().getOrNull()?.size ?: 0) + - (personInImageCvTermId.asKnown().getOrNull()?.size ?: 0) + - (personInImageCvTermName.asKnown().getOrNull()?.size ?: 0) + - (personInImageCvTermRefinedAbout.asKnown().getOrNull()?.size ?: 0) + - (personInImageDescription.asKnown().getOrNull()?.size ?: 0) + - (personInImageId.asKnown().getOrNull()?.size ?: 0) + - (personInImageName.asKnown().getOrNull()?.size ?: 0) + - (productInImageDescription.asKnown().getOrNull()?.size ?: 0) + - (productInImageGtin.asKnown().getOrNull()?.size ?: 0) + - (productInImageName.asKnown().getOrNull()?.size ?: 0) + - (propertyReleaseId.asKnown().getOrNull()?.size ?: 0) + - (if (provinceState.asKnown().isPresent) 1 else 0) + - (if (rating.asKnown().isPresent) 1 else 0) + - (registryEntryRole.asKnown().getOrNull()?.size ?: 0) + - (registryItemId.asKnown().getOrNull()?.size ?: 0) + - (registryOrganisationId.asKnown().getOrNull()?.size ?: 0) + - (if (resolutionUnit.asKnown().isPresent) 1 else 0) + - (if (rights.asKnown().isPresent) 1 else 0) + - (scene.asKnown().getOrNull()?.size ?: 0) + - (if (source.asKnown().isPresent) 1 else 0) + - (if (specialInstructions.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) + - (subject.asKnown().getOrNull()?.size ?: 0) + - (subjectCode.asKnown().getOrNull()?.size ?: 0) + - (subjectReference.asKnown().getOrNull()?.size ?: 0) + - (if (sublocation.asKnown().isPresent) 1 else 0) + - (if (timeCreated.asKnown().isPresent) 1 else 0) + - (if (title.asKnown().isPresent) 1 else 0) + - (if (transmissionReference.asKnown().isPresent) 1 else 0) + - (if (usageTerms.asKnown().isPresent) 1 else 0) + - (if (webStatement.asKnown().isPresent) 1 else 0) + - (if (writer.asKnown().isPresent) 1 else 0) + - (if (writerEditor.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 EmbeddedMetadata && - aboutCvTermCvId == other.aboutCvTermCvId && - aboutCvTermId == other.aboutCvTermId && - aboutCvTermName == other.aboutCvTermName && - aboutCvTermRefinedAbout == other.aboutCvTermRefinedAbout && - additionalModelInformation == other.additionalModelInformation && - applicationRecordVersion == other.applicationRecordVersion && - artist == other.artist && - artworkCircaDateCreated == other.artworkCircaDateCreated && - artworkContentDescription == other.artworkContentDescription && - artworkContributionDescription == other.artworkContributionDescription && - artworkCopyrightNotice == other.artworkCopyrightNotice && - artworkCopyrightOwnerId == other.artworkCopyrightOwnerId && - artworkCopyrightOwnerName == other.artworkCopyrightOwnerName && - artworkCreator == other.artworkCreator && - artworkCreatorId == other.artworkCreatorId && - artworkDateCreated == other.artworkDateCreated && - artworkLicensorId == other.artworkLicensorId && - artworkLicensorName == other.artworkLicensorName && - artworkPhysicalDescription == other.artworkPhysicalDescription && - artworkSource == other.artworkSource && - artworkSourceInventoryNo == other.artworkSourceInventoryNo && - artworkSourceInvUrl == other.artworkSourceInvUrl && - artworkStylePeriod == other.artworkStylePeriod && - artworkTitle == other.artworkTitle && - authorsPosition == other.authorsPosition && - byline == other.byline && - bylineTitle == other.bylineTitle && - caption == other.caption && - captionAbstract == other.captionAbstract && - captionWriter == other.captionWriter && - city == other.city && - colorSpace == other.colorSpace && - componentsConfiguration == other.componentsConfiguration && - copyright == other.copyright && - copyrightNotice == other.copyrightNotice && - copyrightOwnerId == other.copyrightOwnerId && - copyrightOwnerName == other.copyrightOwnerName && - country == other.country && - countryCode == other.countryCode && - countryPrimaryLocationCode == other.countryPrimaryLocationCode && - countryPrimaryLocationName == other.countryPrimaryLocationName && - creator == other.creator && - creatorAddress == other.creatorAddress && - creatorCity == other.creatorCity && - creatorCountry == other.creatorCountry && - creatorPostalCode == other.creatorPostalCode && - creatorRegion == other.creatorRegion && - creatorWorkEmail == other.creatorWorkEmail && - creatorWorkTelephone == other.creatorWorkTelephone && - creatorWorkUrl == other.creatorWorkUrl && - credit == other.credit && - dateCreated == other.dateCreated && - dateTimeCreated == other.dateTimeCreated && - dateTimeOriginal == other.dateTimeOriginal && - description == other.description && - digitalImageGuid == other.digitalImageGuid && - digitalSourceType == other.digitalSourceType && - embeddedEncodedRightsExpr == other.embeddedEncodedRightsExpr && - embeddedEncodedRightsExprLangId == other.embeddedEncodedRightsExprLangId && - embeddedEncodedRightsExprType == other.embeddedEncodedRightsExprType && - event == other.event && - exifVersion == other.exifVersion && - flashpixVersion == other.flashpixVersion && - genreCvId == other.genreCvId && - genreCvTermId == other.genreCvTermId && - genreCvTermName == other.genreCvTermName && - genreCvTermRefinedAbout == other.genreCvTermRefinedAbout && - headline == other.headline && - imageCreatorId == other.imageCreatorId && - imageCreatorImageId == other.imageCreatorImageId && - imageCreatorName == other.imageCreatorName && - imageDescription == other.imageDescription && - imageRegionBoundaryH == other.imageRegionBoundaryH && - imageRegionBoundaryRx == other.imageRegionBoundaryRx && - imageRegionBoundaryShape == other.imageRegionBoundaryShape && - imageRegionBoundaryUnit == other.imageRegionBoundaryUnit && - imageRegionBoundaryVerticesX == other.imageRegionBoundaryVerticesX && - imageRegionBoundaryVerticesY == other.imageRegionBoundaryVerticesY && - imageRegionBoundaryW == other.imageRegionBoundaryW && - imageRegionBoundaryX == other.imageRegionBoundaryX && - imageRegionBoundaryY == other.imageRegionBoundaryY && - imageRegionCtypeIdentifier == other.imageRegionCtypeIdentifier && - imageRegionCtypeName == other.imageRegionCtypeName && - imageRegionId == other.imageRegionId && - imageRegionName == other.imageRegionName && - imageRegionOrganisationInImageName == other.imageRegionOrganisationInImageName && - imageRegionPersonInImage == other.imageRegionPersonInImage && - imageRegionRoleIdentifier == other.imageRegionRoleIdentifier && - imageRegionRoleName == other.imageRegionRoleName && - imageSupplierId == other.imageSupplierId && - imageSupplierImageId == other.imageSupplierImageId && - imageSupplierName == other.imageSupplierName && - instructions == other.instructions && - intellectualGenre == other.intellectualGenre && - keywords == other.keywords && - licensorCity == other.licensorCity && - licensorCountry == other.licensorCountry && - licensorEmail == other.licensorEmail && - licensorExtendedAddress == other.licensorExtendedAddress && - licensorId == other.licensorId && - licensorName == other.licensorName && - licensorPostalCode == other.licensorPostalCode && - licensorRegion == other.licensorRegion && - licensorStreetAddress == other.licensorStreetAddress && - licensorTelephone1 == other.licensorTelephone1 && - licensorTelephone2 == other.licensorTelephone2 && - licensorUrl == other.licensorUrl && - linkedEncodedRightsExpr == other.linkedEncodedRightsExpr && - linkedEncodedRightsExprLangId == other.linkedEncodedRightsExprLangId && - linkedEncodedRightsExprType == other.linkedEncodedRightsExprType && - location == other.location && - locationCreatedCity == other.locationCreatedCity && - locationCreatedCountryCode == other.locationCreatedCountryCode && - locationCreatedCountryName == other.locationCreatedCountryName && - locationCreatedGpsAltitude == other.locationCreatedGpsAltitude && - locationCreatedGpsLatitude == other.locationCreatedGpsLatitude && - locationCreatedGpsLongitude == other.locationCreatedGpsLongitude && - locationCreatedLocationId == other.locationCreatedLocationId && - locationCreatedLocationName == other.locationCreatedLocationName && - locationCreatedProvinceState == other.locationCreatedProvinceState && - locationCreatedSublocation == other.locationCreatedSublocation && - locationCreatedWorldRegion == other.locationCreatedWorldRegion && - locationShownCity == other.locationShownCity && - locationShownCountryCode == other.locationShownCountryCode && - locationShownCountryName == other.locationShownCountryName && - locationShownGpsAltitude == other.locationShownGpsAltitude && - locationShownGpsLatitude == other.locationShownGpsLatitude && - locationShownGpsLongitude == other.locationShownGpsLongitude && - locationShownLocationId == other.locationShownLocationId && - locationShownLocationName == other.locationShownLocationName && - locationShownProvinceState == other.locationShownProvinceState && - locationShownSublocation == other.locationShownSublocation && - locationShownWorldRegion == other.locationShownWorldRegion && - maxAvailHeight == other.maxAvailHeight && - maxAvailWidth == other.maxAvailWidth && - modelAge == other.modelAge && - modelReleaseId == other.modelReleaseId && - objectAttributeReference == other.objectAttributeReference && - objectName == other.objectName && - offsetTimeOriginal == other.offsetTimeOriginal && - organisationInImageCode == other.organisationInImageCode && - organisationInImageName == other.organisationInImageName && - orientation == other.orientation && - originalTransmissionReference == other.originalTransmissionReference && - personInImage == other.personInImage && - personInImageCvTermCvId == other.personInImageCvTermCvId && - personInImageCvTermId == other.personInImageCvTermId && - personInImageCvTermName == other.personInImageCvTermName && - personInImageCvTermRefinedAbout == other.personInImageCvTermRefinedAbout && - personInImageDescription == other.personInImageDescription && - personInImageId == other.personInImageId && - personInImageName == other.personInImageName && - productInImageDescription == other.productInImageDescription && - productInImageGtin == other.productInImageGtin && - productInImageName == other.productInImageName && - propertyReleaseId == other.propertyReleaseId && - provinceState == other.provinceState && - rating == other.rating && - registryEntryRole == other.registryEntryRole && - registryItemId == other.registryItemId && - registryOrganisationId == other.registryOrganisationId && - resolutionUnit == other.resolutionUnit && - rights == other.rights && - scene == other.scene && - source == other.source && - specialInstructions == other.specialInstructions && - state == other.state && - subject == other.subject && - subjectCode == other.subjectCode && - subjectReference == other.subjectReference && - sublocation == other.sublocation && - timeCreated == other.timeCreated && - title == other.title && - transmissionReference == other.transmissionReference && - usageTerms == other.usageTerms && - webStatement == other.webStatement && - writer == other.writer && - writerEditor == other.writerEditor && - xResolution == other.xResolution && - yResolution == other.yResolution && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - aboutCvTermCvId, - aboutCvTermId, - aboutCvTermName, - aboutCvTermRefinedAbout, - additionalModelInformation, - applicationRecordVersion, - artist, - artworkCircaDateCreated, - artworkContentDescription, - artworkContributionDescription, - artworkCopyrightNotice, - artworkCopyrightOwnerId, - artworkCopyrightOwnerName, - artworkCreator, - artworkCreatorId, - artworkDateCreated, - artworkLicensorId, - artworkLicensorName, - artworkPhysicalDescription, - artworkSource, - artworkSourceInventoryNo, - artworkSourceInvUrl, - artworkStylePeriod, - artworkTitle, - authorsPosition, - byline, - bylineTitle, - caption, - captionAbstract, - captionWriter, - city, - colorSpace, - componentsConfiguration, - copyright, - copyrightNotice, - copyrightOwnerId, - copyrightOwnerName, - country, - countryCode, - countryPrimaryLocationCode, - countryPrimaryLocationName, - creator, - creatorAddress, - creatorCity, - creatorCountry, - creatorPostalCode, - creatorRegion, - creatorWorkEmail, - creatorWorkTelephone, - creatorWorkUrl, - credit, - dateCreated, - dateTimeCreated, - dateTimeOriginal, - description, - digitalImageGuid, - digitalSourceType, - embeddedEncodedRightsExpr, - embeddedEncodedRightsExprLangId, - embeddedEncodedRightsExprType, - event, - exifVersion, - flashpixVersion, - genreCvId, - genreCvTermId, - genreCvTermName, - genreCvTermRefinedAbout, - headline, - imageCreatorId, - imageCreatorImageId, - imageCreatorName, - imageDescription, - imageRegionBoundaryH, - imageRegionBoundaryRx, - imageRegionBoundaryShape, - imageRegionBoundaryUnit, - imageRegionBoundaryVerticesX, - imageRegionBoundaryVerticesY, - imageRegionBoundaryW, - imageRegionBoundaryX, - imageRegionBoundaryY, - imageRegionCtypeIdentifier, - imageRegionCtypeName, - imageRegionId, - imageRegionName, - imageRegionOrganisationInImageName, - imageRegionPersonInImage, - imageRegionRoleIdentifier, - imageRegionRoleName, - imageSupplierId, - imageSupplierImageId, - imageSupplierName, - instructions, - intellectualGenre, - keywords, - licensorCity, - licensorCountry, - licensorEmail, - licensorExtendedAddress, - licensorId, - licensorName, - licensorPostalCode, - licensorRegion, - licensorStreetAddress, - licensorTelephone1, - licensorTelephone2, - licensorUrl, - linkedEncodedRightsExpr, - linkedEncodedRightsExprLangId, - linkedEncodedRightsExprType, - location, - locationCreatedCity, - locationCreatedCountryCode, - locationCreatedCountryName, - locationCreatedGpsAltitude, - locationCreatedGpsLatitude, - locationCreatedGpsLongitude, - locationCreatedLocationId, - locationCreatedLocationName, - locationCreatedProvinceState, - locationCreatedSublocation, - locationCreatedWorldRegion, - locationShownCity, - locationShownCountryCode, - locationShownCountryName, - locationShownGpsAltitude, - locationShownGpsLatitude, - locationShownGpsLongitude, - locationShownLocationId, - locationShownLocationName, - locationShownProvinceState, - locationShownSublocation, - locationShownWorldRegion, - maxAvailHeight, - maxAvailWidth, - modelAge, - modelReleaseId, - objectAttributeReference, - objectName, - offsetTimeOriginal, - organisationInImageCode, - organisationInImageName, - orientation, - originalTransmissionReference, - personInImage, - personInImageCvTermCvId, - personInImageCvTermId, - personInImageCvTermName, - personInImageCvTermRefinedAbout, - personInImageDescription, - personInImageId, - personInImageName, - productInImageDescription, - productInImageGtin, - productInImageName, - propertyReleaseId, - provinceState, - rating, - registryEntryRole, - registryItemId, - registryOrganisationId, - resolutionUnit, - rights, - scene, - source, - specialInstructions, - state, - subject, - subjectCode, - subjectReference, - sublocation, - timeCreated, - title, - transmissionReference, - usageTerms, - webStatement, - writer, - writerEditor, - xResolution, - yResolution, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmbeddedMetadata{aboutCvTermCvId=$aboutCvTermCvId, aboutCvTermId=$aboutCvTermId, aboutCvTermName=$aboutCvTermName, aboutCvTermRefinedAbout=$aboutCvTermRefinedAbout, additionalModelInformation=$additionalModelInformation, applicationRecordVersion=$applicationRecordVersion, artist=$artist, artworkCircaDateCreated=$artworkCircaDateCreated, artworkContentDescription=$artworkContentDescription, artworkContributionDescription=$artworkContributionDescription, artworkCopyrightNotice=$artworkCopyrightNotice, artworkCopyrightOwnerId=$artworkCopyrightOwnerId, artworkCopyrightOwnerName=$artworkCopyrightOwnerName, artworkCreator=$artworkCreator, artworkCreatorId=$artworkCreatorId, artworkDateCreated=$artworkDateCreated, artworkLicensorId=$artworkLicensorId, artworkLicensorName=$artworkLicensorName, artworkPhysicalDescription=$artworkPhysicalDescription, artworkSource=$artworkSource, artworkSourceInventoryNo=$artworkSourceInventoryNo, artworkSourceInvUrl=$artworkSourceInvUrl, artworkStylePeriod=$artworkStylePeriod, artworkTitle=$artworkTitle, authorsPosition=$authorsPosition, byline=$byline, bylineTitle=$bylineTitle, caption=$caption, captionAbstract=$captionAbstract, captionWriter=$captionWriter, city=$city, colorSpace=$colorSpace, componentsConfiguration=$componentsConfiguration, copyright=$copyright, copyrightNotice=$copyrightNotice, copyrightOwnerId=$copyrightOwnerId, copyrightOwnerName=$copyrightOwnerName, country=$country, countryCode=$countryCode, countryPrimaryLocationCode=$countryPrimaryLocationCode, countryPrimaryLocationName=$countryPrimaryLocationName, creator=$creator, creatorAddress=$creatorAddress, creatorCity=$creatorCity, creatorCountry=$creatorCountry, creatorPostalCode=$creatorPostalCode, creatorRegion=$creatorRegion, creatorWorkEmail=$creatorWorkEmail, creatorWorkTelephone=$creatorWorkTelephone, creatorWorkUrl=$creatorWorkUrl, credit=$credit, dateCreated=$dateCreated, dateTimeCreated=$dateTimeCreated, dateTimeOriginal=$dateTimeOriginal, description=$description, digitalImageGuid=$digitalImageGuid, digitalSourceType=$digitalSourceType, embeddedEncodedRightsExpr=$embeddedEncodedRightsExpr, embeddedEncodedRightsExprLangId=$embeddedEncodedRightsExprLangId, embeddedEncodedRightsExprType=$embeddedEncodedRightsExprType, event=$event, exifVersion=$exifVersion, flashpixVersion=$flashpixVersion, genreCvId=$genreCvId, genreCvTermId=$genreCvTermId, genreCvTermName=$genreCvTermName, genreCvTermRefinedAbout=$genreCvTermRefinedAbout, headline=$headline, imageCreatorId=$imageCreatorId, imageCreatorImageId=$imageCreatorImageId, imageCreatorName=$imageCreatorName, imageDescription=$imageDescription, imageRegionBoundaryH=$imageRegionBoundaryH, imageRegionBoundaryRx=$imageRegionBoundaryRx, imageRegionBoundaryShape=$imageRegionBoundaryShape, imageRegionBoundaryUnit=$imageRegionBoundaryUnit, imageRegionBoundaryVerticesX=$imageRegionBoundaryVerticesX, imageRegionBoundaryVerticesY=$imageRegionBoundaryVerticesY, imageRegionBoundaryW=$imageRegionBoundaryW, imageRegionBoundaryX=$imageRegionBoundaryX, imageRegionBoundaryY=$imageRegionBoundaryY, imageRegionCtypeIdentifier=$imageRegionCtypeIdentifier, imageRegionCtypeName=$imageRegionCtypeName, imageRegionId=$imageRegionId, imageRegionName=$imageRegionName, imageRegionOrganisationInImageName=$imageRegionOrganisationInImageName, imageRegionPersonInImage=$imageRegionPersonInImage, imageRegionRoleIdentifier=$imageRegionRoleIdentifier, imageRegionRoleName=$imageRegionRoleName, imageSupplierId=$imageSupplierId, imageSupplierImageId=$imageSupplierImageId, imageSupplierName=$imageSupplierName, instructions=$instructions, intellectualGenre=$intellectualGenre, keywords=$keywords, licensorCity=$licensorCity, licensorCountry=$licensorCountry, licensorEmail=$licensorEmail, licensorExtendedAddress=$licensorExtendedAddress, licensorId=$licensorId, licensorName=$licensorName, licensorPostalCode=$licensorPostalCode, licensorRegion=$licensorRegion, licensorStreetAddress=$licensorStreetAddress, licensorTelephone1=$licensorTelephone1, licensorTelephone2=$licensorTelephone2, licensorUrl=$licensorUrl, linkedEncodedRightsExpr=$linkedEncodedRightsExpr, linkedEncodedRightsExprLangId=$linkedEncodedRightsExprLangId, linkedEncodedRightsExprType=$linkedEncodedRightsExprType, location=$location, locationCreatedCity=$locationCreatedCity, locationCreatedCountryCode=$locationCreatedCountryCode, locationCreatedCountryName=$locationCreatedCountryName, locationCreatedGpsAltitude=$locationCreatedGpsAltitude, locationCreatedGpsLatitude=$locationCreatedGpsLatitude, locationCreatedGpsLongitude=$locationCreatedGpsLongitude, locationCreatedLocationId=$locationCreatedLocationId, locationCreatedLocationName=$locationCreatedLocationName, locationCreatedProvinceState=$locationCreatedProvinceState, locationCreatedSublocation=$locationCreatedSublocation, locationCreatedWorldRegion=$locationCreatedWorldRegion, locationShownCity=$locationShownCity, locationShownCountryCode=$locationShownCountryCode, locationShownCountryName=$locationShownCountryName, locationShownGpsAltitude=$locationShownGpsAltitude, locationShownGpsLatitude=$locationShownGpsLatitude, locationShownGpsLongitude=$locationShownGpsLongitude, locationShownLocationId=$locationShownLocationId, locationShownLocationName=$locationShownLocationName, locationShownProvinceState=$locationShownProvinceState, locationShownSublocation=$locationShownSublocation, locationShownWorldRegion=$locationShownWorldRegion, maxAvailHeight=$maxAvailHeight, maxAvailWidth=$maxAvailWidth, modelAge=$modelAge, modelReleaseId=$modelReleaseId, objectAttributeReference=$objectAttributeReference, objectName=$objectName, offsetTimeOriginal=$offsetTimeOriginal, organisationInImageCode=$organisationInImageCode, organisationInImageName=$organisationInImageName, orientation=$orientation, originalTransmissionReference=$originalTransmissionReference, personInImage=$personInImage, personInImageCvTermCvId=$personInImageCvTermCvId, personInImageCvTermId=$personInImageCvTermId, personInImageCvTermName=$personInImageCvTermName, personInImageCvTermRefinedAbout=$personInImageCvTermRefinedAbout, personInImageDescription=$personInImageDescription, personInImageId=$personInImageId, personInImageName=$personInImageName, productInImageDescription=$productInImageDescription, productInImageGtin=$productInImageGtin, productInImageName=$productInImageName, propertyReleaseId=$propertyReleaseId, provinceState=$provinceState, rating=$rating, registryEntryRole=$registryEntryRole, registryItemId=$registryItemId, registryOrganisationId=$registryOrganisationId, resolutionUnit=$resolutionUnit, rights=$rights, scene=$scene, source=$source, specialInstructions=$specialInstructions, state=$state, subject=$subject, subjectCode=$subjectCode, subjectReference=$subjectReference, sublocation=$sublocation, timeCreated=$timeCreated, title=$title, transmissionReference=$transmissionReference, usageTerms=$usageTerms, webStatement=$webStatement, writer=$writer, writerEditor=$writerEditor, xResolution=$xResolution, yResolution=$yResolution, 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 awsAutoTagging: JsonField, - private val googleAutoTagging: JsonField, - private val removeBg: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @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(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 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 [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 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 { - awsAutoTagging = extensionStatus.awsAutoTagging - googleAutoTagging = extensionStatus.googleAutoTagging - removeBg = extensionStatus.removeBg - additionalProperties = extensionStatus.additionalProperties.toMutableMap() - } - - 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( - awsAutoTagging, - googleAutoTagging, - removeBg, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ExtensionStatus = apply { - if (validated) { - return@apply - } - - 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 = - (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + - (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + - (removeBg.asKnown().getOrNull()?.validity() ?: 0) - - 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 && - awsAutoTagging == other.awsAutoTagging && - googleAutoTagging == other.googleAutoTagging && - removeBg == other.removeBg && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" - } - - /** - * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the - * upload API response. - */ - 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: ExifDetails) = exif(JsonField.of(exif)) - - /** - * Sets [Builder.exif] to an arbitrary JSON value. - * - * 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 } - - /** 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: ExifImage) = image(JsonField.of(image)) - - /** - * Sets [Builder.image] to an arbitrary JSON value. - * - * You should usually call [Builder.image] with a well-typed [ExifImage] 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) - - 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}" - } - - 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}" - } - - /** 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 FileUploadV1Response && - aiTags == other.aiTags && - audioCodec == other.audioCodec && - bitRate == other.bitRate && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - 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, - 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() = - "FileUploadV1Response{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/FileUploadV2Params.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Params.kt deleted file mode 100644 index 7d4a8217..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Params.kt +++ /dev/null @@ -1,2861 +0,0 @@ -// 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.JsonValue -import com.imagekit.api.core.MultipartField -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 com.imagekit.api.errors.ImageKitInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional - -/** - * 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 FileUploadV2Params -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please ensure - * that our servers can access the URL. In case ImageKit is unable to download the file from the - * specified URL, a `400` error response is returned. This will also result in a `400` error if - * the file download request is aborted if response headers are not received in 8 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 file(): String = 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() - - /** - * Stringified JSON key-value data to be associated with the asset. - * - * @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() - - /** - * Stringified JSON object with an array of extensions to be applied to the image. Refer to - * extensions schema in - * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). - * - * @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() - - /** - * Comma-separated values of the fields that you want the API to return in the response. - * - * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get the - * value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. - * - * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, - * `isPublished`, `customMetadata`, and `metadata`. - * - * @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. - * - * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all - * characters should not exceed 500. `%` is not allowed. - * - * If this field is not specified and the file is overwritten then the 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() - - /** - * Stringified JSON object with properties for pre and post transformations: - * - * `pre` - Accepts a "string" containing a valid transformation used for requesting a - * pre-transformation for an image or a video file. - * - * `post` - Accepts an array of objects with properties: - * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive bitrate - * streaming). - * - `value`: A "string" corresponding to the required transformation. Required if `type` is - * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. - * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. - * - * Read more about [Adaptive bitrate streaming (ABS)](/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 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 [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 [FileUploadV2Params]. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileUploadV2Params]. */ - 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(fileUploadV2Params: FileUploadV2Params) = apply { - body = fileUploadV2Params.body.toBuilder() - additionalHeaders = fileUploadV2Params.additionalHeaders.toBuilder() - additionalQueryParams = fileUploadV2Params.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() } - - /** - * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please - * ensure that our servers can access the URL. In case ImageKit is unable to download the - * file from the specified URL, a `400` error response is returned. This will also result in - * a `400` error if the file download request is aborted if response headers are not - * received in 8 seconds. - */ - 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 [String] 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 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) - } - - /** Stringified JSON key-value data to be associated with the asset. */ - fun customMetadata(customMetadata: String) = apply { body.customMetadata(customMetadata) } - - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed [String] 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) - } - - /** - * Stringified JSON object with an array of extensions to be applied to the image. Refer to - * extensions schema in - * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). - */ - fun extensions(extensions: String) = apply { body.extensions(extensions) } - - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed [String] 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) } - - /** - * 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: IsPrivateFile) = apply { - body.isPrivateFile(isPrivateFile) - } - - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [IsPrivateFile] 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: IsPublished) = apply { body.isPublished(isPublished) } - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [IsPublished] 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: OverwriteAiTags) = apply { - body.overwriteAiTags(overwriteAiTags) - } - - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [OverwriteAiTags] - * 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: OverwriteCustomMetadata) = apply { - body.overwriteCustomMetadata(overwriteCustomMetadata) - } - - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed - * [OverwriteCustomMetadata] 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: String) = apply { body.overwriteFile(overwriteFile) } - - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [String] 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: OverwriteTags) = apply { - body.overwriteTags(overwriteTags) - } - - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [OverwriteTags] 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) - } - - /** - * Comma-separated values of the fields that you want the API to return in the response. - * - * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get - * the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. - * - * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, - * `isPublished`, `customMetadata`, and `metadata`. - */ - fun responseFields(responseFields: String) = apply { body.responseFields(responseFields) } - - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] 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(responseFields: MultipartField) = apply { - body.responseFields(responseFields) - } - - /** - * Set the tags while uploading the file. - * - * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all - * characters should not exceed 500. `%` is not allowed. - * - * If this field is not specified and the file is overwritten then the tags will be removed. - */ - fun tags(tags: String) = apply { body.tags(tags) } - - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed [String] 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) } - - /** - * Stringified JSON object with properties for pre and post transformations: - * - * `pre` - Accepts a "string" containing a valid transformation used for requesting a - * pre-transformation for an image or a video file. - * - * `post` - Accepts an array of objects with properties: - * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive - * bitrate streaming). - * - `value`: A "string" corresponding to the required transformation. Required if `type` is - * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. - * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. - * - * Read more about [Adaptive bitrate streaming (ABS)](/docs/adaptive-bitrate-streaming). - */ - fun transformation(transformation: String) = apply { body.transformation(transformation) } - - /** - * Sets [Builder.transformation] to an arbitrary multipart 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: 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: UseUniqueFileName) = apply { - body.useUniqueFileName(useUniqueFileName) - } - - /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. - * - * You should usually call [Builder.useUniqueFileName] with a well-typed [UseUniqueFileName] - * 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 [FileUploadV2Params]. - * - * 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(): FileUploadV2Params = - FileUploadV2Params( - 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(), - "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 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, - ) { - - /** - * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please - * ensure that our servers can access the URL. In case ImageKit is unable to download the - * file from the specified URL, a `400` error response is returned. This will also result in - * a `400` error if the file download request is aborted if response headers are not - * received in 8 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 file(): String = 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") - - /** - * Stringified JSON key-value data to be associated with the asset. - * - * @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") - - /** - * Stringified JSON object with an array of extensions to be applied to the image. Refer to - * extensions schema in - * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). - * - * @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") - - /** - * Comma-separated values of the fields that you want the API to return in the response. - * - * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to get - * the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. - * - * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, `embeddedMetadata`, - * `isPublished`, `customMetadata`, and `metadata`. - * - * @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. - * - * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of all - * characters should not exceed 500. `%` is not allowed. - * - * If this field is not specified and the file is overwritten then the 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") - - /** - * Stringified JSON object with properties for pre and post transformations: - * - * `pre` - Accepts a "string" containing a valid transformation used for requesting a - * pre-transformation for an image or a video file. - * - * `post` - Accepts an array of objects with properties: - * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive - * bitrate streaming). - * - `value`: A "string" corresponding to the required transformation. Required if `type` is - * `transformation` or `abs`. Optional if `type` is `gif-to-video` or `thumbnail`. - * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. - * - * Read more about [Adaptive bitrate streaming (ABS)](/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 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 [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 extensions: MultipartField = MultipartField.of(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 = MultipartField.of(null) - private var tags: 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() - - @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 - extensions = body.extensions - folder = body.folder - isPrivateFile = body.isPrivateFile - isPublished = body.isPublished - overwriteAiTags = body.overwriteAiTags - overwriteCustomMetadata = body.overwriteCustomMetadata - overwriteFile = body.overwriteFile - overwriteTags = body.overwriteTags - responseFields = body.responseFields - tags = body.tags - transformation = body.transformation - useUniqueFileName = body.useUniqueFileName - webhookUrl = body.webhookUrl - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * Pass the HTTP URL or base64 string. When passing a URL in the file parameter, please - * ensure that our servers can access the URL. In case ImageKit is unable to download - * the file from the specified URL, a `400` error response is returned. This will also - * result in a `400` error if the file download request is aborted if response headers - * are not received in 8 seconds. - */ - 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 [String] 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 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 - } - - /** Stringified JSON key-value data to be associated with the asset. */ - fun customMetadata(customMetadata: String) = - customMetadata(MultipartField.of(customMetadata)) - - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed [String] 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 - } - - /** - * Stringified JSON object with an array of extensions to be applied to the image. Refer - * to extensions schema in - * [update file API request body](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#request-body). - */ - fun extensions(extensions: String) = extensions(MultipartField.of(extensions)) - - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed [String] 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 - } - - /** - * 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: IsPrivateFile) = - isPrivateFile(MultipartField.of(isPrivateFile)) - - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [IsPrivateFile] - * 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: IsPublished) = isPublished(MultipartField.of(isPublished)) - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [IsPublished] 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: OverwriteAiTags) = - overwriteAiTags(MultipartField.of(overwriteAiTags)) - - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [OverwriteAiTags] - * 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: OverwriteCustomMetadata) = - overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) - - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed - * [OverwriteCustomMetadata] 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: String) = - overwriteFile(MultipartField.of(overwriteFile)) - - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [String] 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: OverwriteTags) = - overwriteTags(MultipartField.of(overwriteTags)) - - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [OverwriteTags] - * 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 - } - - /** - * Comma-separated values of the fields that you want the API to return in the response. - * - * For example, set the value of this field to `tags,customCoordinates,isPrivateFile` to - * get the value of `tags`, `customCoordinates`, and `isPrivateFile` in the response. - * - * Accepts combination of `tags`, `customCoordinates`, `isPrivateFile`, - * `embeddedMetadata`, `isPublished`, `customMetadata`, and `metadata`. - */ - fun responseFields(responseFields: String) = - responseFields(MultipartField.of(responseFields)) - - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] 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(responseFields: MultipartField) = apply { - this.responseFields = responseFields - } - - /** - * Set the tags while uploading the file. - * - * Comma-separated value of tags in the format `tag1,tag2,tag3`. The maximum length of - * all characters should not exceed 500. `%` is not allowed. - * - * If this field is not specified and the file is overwritten then the tags will be - * removed. - */ - fun tags(tags: String) = tags(MultipartField.of(tags)) - - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed [String] 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 } - - /** - * Stringified JSON object with properties for pre and post transformations: - * - * `pre` - Accepts a "string" containing a valid transformation used for requesting a - * pre-transformation for an image or a video file. - * - * `post` - Accepts an array of objects with properties: - * - `type`: One of `transformation`, `gif-to-video`, `thumbnail`, or `abs` (Adaptive - * bitrate streaming). - * - `value`: A "string" corresponding to the required transformation. Required if - * `type` is `transformation` or `abs`. Optional if `type` is `gif-to-video` or - * `thumbnail`. - * - `protocol`: Either `hls` or `dash`, applicable only if `type` is `abs`. - * - * Read more about [Adaptive bitrate streaming (ABS)](/docs/adaptive-bitrate-streaming). - */ - fun transformation(transformation: String) = - transformation(MultipartField.of(transformation)) - - /** - * Sets [Builder.transformation] to an arbitrary multipart 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: 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: UseUniqueFileName) = - useUniqueFileName(MultipartField.of(useUniqueFileName)) - - /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. - * - * You should usually call [Builder.useUniqueFileName] with a well-typed - * [UseUniqueFileName] 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, - extensions, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - responseFields, - tags, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - file() - fileName() - token() - checks() - customCoordinates() - customMetadata() - extensions() - folder() - isPrivateFile().ifPresent { it.validate() } - isPublished().ifPresent { it.validate() } - overwriteAiTags().ifPresent { it.validate() } - overwriteCustomMetadata().ifPresent { it.validate() } - overwriteFile() - overwriteTags().ifPresent { it.validate() } - responseFields() - tags() - transformation() - useUniqueFileName().ifPresent { it.validate() } - 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 && - 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, - 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, 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}" - } - - /** - * 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. - */ - class IsPrivateFile @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = IsPrivateFile(JsonField.of(value)) - } - - /** An enum containing [IsPrivateFile]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [IsPrivateFile]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [IsPrivateFile] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [IsPrivateFile] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown IsPrivateFile: $value") - } - - /** - * Returns this class 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(): IsPrivateFile = 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 IsPrivateFile && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * 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. - */ - class IsPublished @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = IsPublished(JsonField.of(value)) - } - - /** An enum containing [IsPublished]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [IsPublished]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [IsPublished] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [IsPublished] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown IsPublished: $value") - } - - /** - * Returns this class 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(): IsPublished = 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 IsPublished && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * 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. - */ - class OverwriteAiTags @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = OverwriteAiTags(JsonField.of(value)) - } - - /** An enum containing [OverwriteAiTags]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [OverwriteAiTags]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [OverwriteAiTags] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [OverwriteAiTags] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown OverwriteAiTags: $value") - } - - /** - * Returns this class 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(): OverwriteAiTags = 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 OverwriteAiTags && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - */ - class OverwriteCustomMetadata - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = OverwriteCustomMetadata(JsonField.of(value)) - } - - /** An enum containing [OverwriteCustomMetadata]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [OverwriteCustomMetadata]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [OverwriteCustomMetadata] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [OverwriteCustomMetadata] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> - throw ImageKitInvalidDataException("Unknown OverwriteCustomMetadata: $value") - } - - /** - * Returns this class 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(): OverwriteCustomMetadata = 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 OverwriteCustomMetadata && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - */ - class OverwriteTags @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = OverwriteTags(JsonField.of(value)) - } - - /** An enum containing [OverwriteTags]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [OverwriteTags]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [OverwriteTags] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [OverwriteTags] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown OverwriteTags: $value") - } - - /** - * Returns this class 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(): OverwriteTags = 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 OverwriteTags && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * 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. - */ - class UseUniqueFileName @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API 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") - - @JvmField val FALSE = of("false") - - @JvmStatic fun of(value: String) = UseUniqueFileName(JsonField.of(value)) - } - - /** An enum containing [UseUniqueFileName]'s known values. */ - enum class Known { - TRUE, - FALSE, - } - - /** - * An enum containing [UseUniqueFileName]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UseUniqueFileName] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may 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, - FALSE, - /** - * An enum member indicating that [UseUniqueFileName] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - FALSE -> Value.FALSE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - FALSE -> Known.FALSE - else -> throw ImageKitInvalidDataException("Unknown UseUniqueFileName: $value") - } - - /** - * Returns this class 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(): UseUniqueFileName = 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 UseUniqueFileName && 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 FileUploadV2Params && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "FileUploadV2Params{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Response.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Response.kt deleted file mode 100644 index 8a87fcf9..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadV2Response.kt +++ /dev/null @@ -1,11793 +0,0 @@ -// 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 successful upload. */ -class FileUploadV2Response -private constructor( - private val aiTags: JsonField>, - private val audioCodec: JsonField, - private val bitRate: JsonField, - private val customCoordinates: JsonField, - private val customMetadata: JsonValue, - 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: JsonValue = 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, - 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. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata - - /** - * 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 [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 [FileUploadV2Response]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileUploadV2Response]. */ - 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: JsonValue = 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(fileUploadV2Response: FileUploadV2Response) = apply { - aiTags = fileUploadV2Response.aiTags.map { it.toMutableList() } - audioCodec = fileUploadV2Response.audioCodec - bitRate = fileUploadV2Response.bitRate - customCoordinates = fileUploadV2Response.customCoordinates - customMetadata = fileUploadV2Response.customMetadata - duration = fileUploadV2Response.duration - embeddedMetadata = fileUploadV2Response.embeddedMetadata - extensionStatus = fileUploadV2Response.extensionStatus - fileId = fileUploadV2Response.fileId - filePath = fileUploadV2Response.filePath - fileType = fileUploadV2Response.fileType - height = fileUploadV2Response.height - isPrivateFile = fileUploadV2Response.isPrivateFile - isPublished = fileUploadV2Response.isPublished - metadata = fileUploadV2Response.metadata - name = fileUploadV2Response.name - size = fileUploadV2Response.size - tags = fileUploadV2Response.tags.map { it.toMutableList() } - thumbnailUrl = fileUploadV2Response.thumbnailUrl - url = fileUploadV2Response.url - versionInfo = fileUploadV2Response.versionInfo - videoCodec = fileUploadV2Response.videoCodec - width = fileUploadV2Response.width - additionalProperties = fileUploadV2Response.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: JsonValue) = apply { - this.customMetadata = customMetadata - } - - /** 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 [FileUploadV2Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FileUploadV2Response = - FileUploadV2Response( - (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, - audioCodec, - bitRate, - customCoordinates, - customMetadata, - 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(): FileUploadV2Response = apply { - if (validated) { - return@apply - } - - aiTags().ifPresent { it.forEach { it.validate() } } - audioCodec() - bitRate() - customCoordinates() - 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) + - (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}" - } - - /** - * 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 - private constructor( - private val aboutCvTermCvId: JsonField, - private val aboutCvTermId: JsonField, - private val aboutCvTermName: JsonField, - private val aboutCvTermRefinedAbout: JsonField, - private val additionalModelInformation: JsonField, - private val applicationRecordVersion: JsonField, - private val artist: JsonField, - private val artworkCircaDateCreated: JsonField, - private val artworkContentDescription: JsonField, - private val artworkContributionDescription: JsonField, - private val artworkCopyrightNotice: JsonField, - private val artworkCopyrightOwnerId: JsonField, - private val artworkCopyrightOwnerName: JsonField, - private val artworkCreator: JsonField>, - private val artworkCreatorId: JsonField>, - private val artworkDateCreated: JsonField, - private val artworkLicensorId: JsonField, - private val artworkLicensorName: JsonField, - private val artworkPhysicalDescription: JsonField, - private val artworkSource: JsonField, - private val artworkSourceInventoryNo: JsonField, - private val artworkSourceInvUrl: JsonField, - private val artworkStylePeriod: JsonField>, - private val artworkTitle: JsonField, - private val authorsPosition: JsonField, - private val byline: JsonField, - private val bylineTitle: JsonField, - private val caption: JsonField, - private val captionAbstract: JsonField, - private val captionWriter: JsonField, - private val city: JsonField, - private val colorSpace: JsonField, - private val componentsConfiguration: JsonField, - private val copyright: JsonField, - private val copyrightNotice: JsonField, - private val copyrightOwnerId: JsonField>, - private val copyrightOwnerName: JsonField>, - private val country: JsonField, - private val countryCode: JsonField, - private val countryPrimaryLocationCode: JsonField, - private val countryPrimaryLocationName: JsonField, - private val creator: JsonField, - private val creatorAddress: JsonField, - private val creatorCity: JsonField, - private val creatorCountry: JsonField, - private val creatorPostalCode: JsonField, - private val creatorRegion: JsonField, - private val creatorWorkEmail: JsonField, - private val creatorWorkTelephone: JsonField, - private val creatorWorkUrl: JsonField, - private val credit: JsonField, - private val dateCreated: JsonField, - private val dateTimeCreated: JsonField, - private val dateTimeOriginal: JsonField, - private val description: JsonField, - private val digitalImageGuid: JsonField, - private val digitalSourceType: JsonField, - private val embeddedEncodedRightsExpr: JsonField, - private val embeddedEncodedRightsExprLangId: JsonField, - private val embeddedEncodedRightsExprType: JsonField, - private val event: JsonField, - private val exifVersion: JsonField, - private val flashpixVersion: JsonField, - private val genreCvId: JsonField, - private val genreCvTermId: JsonField, - private val genreCvTermName: JsonField, - private val genreCvTermRefinedAbout: JsonField, - private val headline: JsonField, - private val imageCreatorId: JsonField, - private val imageCreatorImageId: JsonField, - private val imageCreatorName: JsonField, - private val imageDescription: JsonField, - private val imageRegionBoundaryH: JsonField>, - private val imageRegionBoundaryRx: JsonField>, - private val imageRegionBoundaryShape: JsonField>, - private val imageRegionBoundaryUnit: JsonField>, - private val imageRegionBoundaryVerticesX: JsonField>, - private val imageRegionBoundaryVerticesY: JsonField>, - private val imageRegionBoundaryW: JsonField>, - private val imageRegionBoundaryX: JsonField>, - private val imageRegionBoundaryY: JsonField>, - private val imageRegionCtypeIdentifier: JsonField>, - private val imageRegionCtypeName: JsonField>, - private val imageRegionId: JsonField>, - private val imageRegionName: JsonField>, - private val imageRegionOrganisationInImageName: JsonField>, - private val imageRegionPersonInImage: JsonField>, - private val imageRegionRoleIdentifier: JsonField>, - private val imageRegionRoleName: JsonField>, - private val imageSupplierId: JsonField, - private val imageSupplierImageId: JsonField, - private val imageSupplierName: JsonField, - private val instructions: JsonField, - private val intellectualGenre: JsonField, - private val keywords: JsonField>, - private val licensorCity: JsonField>, - private val licensorCountry: JsonField>, - private val licensorEmail: JsonField>, - private val licensorExtendedAddress: JsonField>, - private val licensorId: JsonField>, - private val licensorName: JsonField>, - private val licensorPostalCode: JsonField>, - private val licensorRegion: JsonField>, - private val licensorStreetAddress: JsonField>, - private val licensorTelephone1: JsonField>, - private val licensorTelephone2: JsonField>, - private val licensorUrl: JsonField>, - private val linkedEncodedRightsExpr: JsonField, - private val linkedEncodedRightsExprLangId: JsonField, - private val linkedEncodedRightsExprType: JsonField, - private val location: JsonField, - private val locationCreatedCity: JsonField, - private val locationCreatedCountryCode: JsonField, - private val locationCreatedCountryName: JsonField, - private val locationCreatedGpsAltitude: JsonField, - private val locationCreatedGpsLatitude: JsonField, - private val locationCreatedGpsLongitude: JsonField, - private val locationCreatedLocationId: JsonField, - private val locationCreatedLocationName: JsonField, - private val locationCreatedProvinceState: JsonField, - private val locationCreatedSublocation: JsonField, - private val locationCreatedWorldRegion: JsonField, - private val locationShownCity: JsonField>, - private val locationShownCountryCode: JsonField>, - private val locationShownCountryName: JsonField>, - private val locationShownGpsAltitude: JsonField>, - private val locationShownGpsLatitude: JsonField>, - private val locationShownGpsLongitude: JsonField>, - private val locationShownLocationId: JsonField>, - private val locationShownLocationName: JsonField>, - private val locationShownProvinceState: JsonField>, - private val locationShownSublocation: JsonField>, - private val locationShownWorldRegion: JsonField>, - private val maxAvailHeight: JsonField, - private val maxAvailWidth: JsonField, - private val modelAge: JsonField>, - private val modelReleaseId: JsonField>, - private val objectAttributeReference: JsonField, - private val objectName: JsonField, - private val offsetTimeOriginal: JsonField, - private val organisationInImageCode: JsonField>, - private val organisationInImageName: JsonField>, - private val orientation: JsonField, - private val originalTransmissionReference: JsonField, - private val personInImage: JsonField>, - private val personInImageCvTermCvId: JsonField>, - private val personInImageCvTermId: JsonField>, - private val personInImageCvTermName: JsonField>, - private val personInImageCvTermRefinedAbout: JsonField>, - private val personInImageDescription: JsonField>, - private val personInImageId: JsonField>, - private val personInImageName: JsonField>, - private val productInImageDescription: JsonField>, - private val productInImageGtin: JsonField>, - private val productInImageName: JsonField>, - private val propertyReleaseId: JsonField>, - private val provinceState: JsonField, - private val rating: JsonField, - private val registryEntryRole: JsonField>, - private val registryItemId: JsonField>, - private val registryOrganisationId: JsonField>, - private val resolutionUnit: JsonField, - private val rights: JsonField, - private val scene: JsonField>, - private val source: JsonField, - private val specialInstructions: JsonField, - private val state: JsonField, - private val subject: JsonField>, - private val subjectCode: JsonField>, - private val subjectReference: JsonField>, - private val sublocation: JsonField, - private val timeCreated: JsonField, - private val title: JsonField, - private val transmissionReference: JsonField, - private val usageTerms: JsonField, - private val webStatement: JsonField, - private val writer: JsonField, - private val writerEditor: JsonField, - private val xResolution: JsonField, - private val yResolution: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("AboutCvTermCvId") - @ExcludeMissing - aboutCvTermCvId: JsonField = JsonMissing.of(), - @JsonProperty("AboutCvTermId") - @ExcludeMissing - aboutCvTermId: JsonField = JsonMissing.of(), - @JsonProperty("AboutCvTermName") - @ExcludeMissing - aboutCvTermName: JsonField = JsonMissing.of(), - @JsonProperty("AboutCvTermRefinedAbout") - @ExcludeMissing - aboutCvTermRefinedAbout: JsonField = JsonMissing.of(), - @JsonProperty("AdditionalModelInformation") - @ExcludeMissing - additionalModelInformation: JsonField = JsonMissing.of(), - @JsonProperty("ApplicationRecordVersion") - @ExcludeMissing - applicationRecordVersion: JsonField = JsonMissing.of(), - @JsonProperty("Artist") @ExcludeMissing artist: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCircaDateCreated") - @ExcludeMissing - artworkCircaDateCreated: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkContentDescription") - @ExcludeMissing - artworkContentDescription: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkContributionDescription") - @ExcludeMissing - artworkContributionDescription: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCopyrightNotice") - @ExcludeMissing - artworkCopyrightNotice: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCopyrightOwnerID") - @ExcludeMissing - artworkCopyrightOwnerId: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCopyrightOwnerName") - @ExcludeMissing - artworkCopyrightOwnerName: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkCreator") - @ExcludeMissing - artworkCreator: JsonField> = JsonMissing.of(), - @JsonProperty("ArtworkCreatorID") - @ExcludeMissing - artworkCreatorId: JsonField> = JsonMissing.of(), - @JsonProperty("ArtworkDateCreated") - @ExcludeMissing - artworkDateCreated: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkLicensorID") - @ExcludeMissing - artworkLicensorId: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkLicensorName") - @ExcludeMissing - artworkLicensorName: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkPhysicalDescription") - @ExcludeMissing - artworkPhysicalDescription: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkSource") - @ExcludeMissing - artworkSource: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkSourceInventoryNo") - @ExcludeMissing - artworkSourceInventoryNo: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkSourceInvURL") - @ExcludeMissing - artworkSourceInvUrl: JsonField = JsonMissing.of(), - @JsonProperty("ArtworkStylePeriod") - @ExcludeMissing - artworkStylePeriod: JsonField> = JsonMissing.of(), - @JsonProperty("ArtworkTitle") - @ExcludeMissing - artworkTitle: JsonField = JsonMissing.of(), - @JsonProperty("AuthorsPosition") - @ExcludeMissing - authorsPosition: JsonField = JsonMissing.of(), - @JsonProperty("Byline") @ExcludeMissing byline: JsonField = JsonMissing.of(), - @JsonProperty("BylineTitle") - @ExcludeMissing - bylineTitle: JsonField = JsonMissing.of(), - @JsonProperty("Caption") @ExcludeMissing caption: JsonField = JsonMissing.of(), - @JsonProperty("CaptionAbstract") - @ExcludeMissing - captionAbstract: JsonField = JsonMissing.of(), - @JsonProperty("CaptionWriter") - @ExcludeMissing - captionWriter: JsonField = JsonMissing.of(), - @JsonProperty("City") @ExcludeMissing city: JsonField = JsonMissing.of(), - @JsonProperty("ColorSpace") - @ExcludeMissing - colorSpace: JsonField = JsonMissing.of(), - @JsonProperty("ComponentsConfiguration") - @ExcludeMissing - componentsConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("Copyright") - @ExcludeMissing - copyright: JsonField = JsonMissing.of(), - @JsonProperty("CopyrightNotice") - @ExcludeMissing - copyrightNotice: JsonField = JsonMissing.of(), - @JsonProperty("CopyrightOwnerID") - @ExcludeMissing - copyrightOwnerId: JsonField> = JsonMissing.of(), - @JsonProperty("CopyrightOwnerName") - @ExcludeMissing - copyrightOwnerName: JsonField> = JsonMissing.of(), - @JsonProperty("Country") @ExcludeMissing country: JsonField = JsonMissing.of(), - @JsonProperty("CountryCode") - @ExcludeMissing - countryCode: JsonField = JsonMissing.of(), - @JsonProperty("CountryPrimaryLocationCode") - @ExcludeMissing - countryPrimaryLocationCode: JsonField = JsonMissing.of(), - @JsonProperty("CountryPrimaryLocationName") - @ExcludeMissing - countryPrimaryLocationName: JsonField = JsonMissing.of(), - @JsonProperty("Creator") @ExcludeMissing creator: JsonField = JsonMissing.of(), - @JsonProperty("CreatorAddress") - @ExcludeMissing - creatorAddress: JsonField = JsonMissing.of(), - @JsonProperty("CreatorCity") - @ExcludeMissing - creatorCity: JsonField = JsonMissing.of(), - @JsonProperty("CreatorCountry") - @ExcludeMissing - creatorCountry: JsonField = JsonMissing.of(), - @JsonProperty("CreatorPostalCode") - @ExcludeMissing - creatorPostalCode: JsonField = JsonMissing.of(), - @JsonProperty("CreatorRegion") - @ExcludeMissing - creatorRegion: JsonField = JsonMissing.of(), - @JsonProperty("CreatorWorkEmail") - @ExcludeMissing - creatorWorkEmail: JsonField = JsonMissing.of(), - @JsonProperty("CreatorWorkTelephone") - @ExcludeMissing - creatorWorkTelephone: JsonField = JsonMissing.of(), - @JsonProperty("CreatorWorkURL") - @ExcludeMissing - creatorWorkUrl: JsonField = JsonMissing.of(), - @JsonProperty("Credit") @ExcludeMissing credit: JsonField = JsonMissing.of(), - @JsonProperty("DateCreated") - @ExcludeMissing - dateCreated: JsonField = JsonMissing.of(), - @JsonProperty("DateTimeCreated") - @ExcludeMissing - dateTimeCreated: JsonField = JsonMissing.of(), - @JsonProperty("DateTimeOriginal") - @ExcludeMissing - dateTimeOriginal: JsonField = JsonMissing.of(), - @JsonProperty("Description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("DigitalImageGUID") - @ExcludeMissing - digitalImageGuid: JsonField = JsonMissing.of(), - @JsonProperty("DigitalSourceType") - @ExcludeMissing - digitalSourceType: JsonField = JsonMissing.of(), - @JsonProperty("EmbeddedEncodedRightsExpr") - @ExcludeMissing - embeddedEncodedRightsExpr: JsonField = JsonMissing.of(), - @JsonProperty("EmbeddedEncodedRightsExprLangID") - @ExcludeMissing - embeddedEncodedRightsExprLangId: JsonField = JsonMissing.of(), - @JsonProperty("EmbeddedEncodedRightsExprType") - @ExcludeMissing - embeddedEncodedRightsExprType: JsonField = JsonMissing.of(), - @JsonProperty("Event") @ExcludeMissing event: JsonField = JsonMissing.of(), - @JsonProperty("ExifVersion") - @ExcludeMissing - exifVersion: JsonField = JsonMissing.of(), - @JsonProperty("FlashpixVersion") - @ExcludeMissing - flashpixVersion: JsonField = JsonMissing.of(), - @JsonProperty("GenreCvId") - @ExcludeMissing - genreCvId: JsonField = JsonMissing.of(), - @JsonProperty("GenreCvTermId") - @ExcludeMissing - genreCvTermId: JsonField = JsonMissing.of(), - @JsonProperty("GenreCvTermName") - @ExcludeMissing - genreCvTermName: JsonField = JsonMissing.of(), - @JsonProperty("GenreCvTermRefinedAbout") - @ExcludeMissing - genreCvTermRefinedAbout: JsonField = JsonMissing.of(), - @JsonProperty("Headline") - @ExcludeMissing - headline: JsonField = JsonMissing.of(), - @JsonProperty("ImageCreatorID") - @ExcludeMissing - imageCreatorId: JsonField = JsonMissing.of(), - @JsonProperty("ImageCreatorImageID") - @ExcludeMissing - imageCreatorImageId: JsonField = JsonMissing.of(), - @JsonProperty("ImageCreatorName") - @ExcludeMissing - imageCreatorName: JsonField = JsonMissing.of(), - @JsonProperty("ImageDescription") - @ExcludeMissing - imageDescription: JsonField = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryH") - @ExcludeMissing - imageRegionBoundaryH: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryRx") - @ExcludeMissing - imageRegionBoundaryRx: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryShape") - @ExcludeMissing - imageRegionBoundaryShape: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryUnit") - @ExcludeMissing - imageRegionBoundaryUnit: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryVerticesX") - @ExcludeMissing - imageRegionBoundaryVerticesX: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryVerticesY") - @ExcludeMissing - imageRegionBoundaryVerticesY: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryW") - @ExcludeMissing - imageRegionBoundaryW: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryX") - @ExcludeMissing - imageRegionBoundaryX: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionBoundaryY") - @ExcludeMissing - imageRegionBoundaryY: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionCtypeIdentifier") - @ExcludeMissing - imageRegionCtypeIdentifier: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionCtypeName") - @ExcludeMissing - imageRegionCtypeName: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionID") - @ExcludeMissing - imageRegionId: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionName") - @ExcludeMissing - imageRegionName: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionOrganisationInImageName") - @ExcludeMissing - imageRegionOrganisationInImageName: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionPersonInImage") - @ExcludeMissing - imageRegionPersonInImage: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionRoleIdentifier") - @ExcludeMissing - imageRegionRoleIdentifier: JsonField> = JsonMissing.of(), - @JsonProperty("ImageRegionRoleName") - @ExcludeMissing - imageRegionRoleName: JsonField> = JsonMissing.of(), - @JsonProperty("ImageSupplierID") - @ExcludeMissing - imageSupplierId: JsonField = JsonMissing.of(), - @JsonProperty("ImageSupplierImageID") - @ExcludeMissing - imageSupplierImageId: JsonField = JsonMissing.of(), - @JsonProperty("ImageSupplierName") - @ExcludeMissing - imageSupplierName: JsonField = JsonMissing.of(), - @JsonProperty("Instructions") - @ExcludeMissing - instructions: JsonField = JsonMissing.of(), - @JsonProperty("IntellectualGenre") - @ExcludeMissing - intellectualGenre: JsonField = JsonMissing.of(), - @JsonProperty("Keywords") - @ExcludeMissing - keywords: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorCity") - @ExcludeMissing - licensorCity: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorCountry") - @ExcludeMissing - licensorCountry: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorEmail") - @ExcludeMissing - licensorEmail: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorExtendedAddress") - @ExcludeMissing - licensorExtendedAddress: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorID") - @ExcludeMissing - licensorId: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorName") - @ExcludeMissing - licensorName: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorPostalCode") - @ExcludeMissing - licensorPostalCode: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorRegion") - @ExcludeMissing - licensorRegion: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorStreetAddress") - @ExcludeMissing - licensorStreetAddress: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorTelephone1") - @ExcludeMissing - licensorTelephone1: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorTelephone2") - @ExcludeMissing - licensorTelephone2: JsonField> = JsonMissing.of(), - @JsonProperty("LicensorURL") - @ExcludeMissing - licensorUrl: JsonField> = JsonMissing.of(), - @JsonProperty("LinkedEncodedRightsExpr") - @ExcludeMissing - linkedEncodedRightsExpr: JsonField = JsonMissing.of(), - @JsonProperty("LinkedEncodedRightsExprLangID") - @ExcludeMissing - linkedEncodedRightsExprLangId: JsonField = JsonMissing.of(), - @JsonProperty("LinkedEncodedRightsExprType") - @ExcludeMissing - linkedEncodedRightsExprType: JsonField = JsonMissing.of(), - @JsonProperty("Location") - @ExcludeMissing - location: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedCity") - @ExcludeMissing - locationCreatedCity: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedCountryCode") - @ExcludeMissing - locationCreatedCountryCode: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedCountryName") - @ExcludeMissing - locationCreatedCountryName: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedGPSAltitude") - @ExcludeMissing - locationCreatedGpsAltitude: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedGPSLatitude") - @ExcludeMissing - locationCreatedGpsLatitude: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedGPSLongitude") - @ExcludeMissing - locationCreatedGpsLongitude: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedLocationId") - @ExcludeMissing - locationCreatedLocationId: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedLocationName") - @ExcludeMissing - locationCreatedLocationName: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedProvinceState") - @ExcludeMissing - locationCreatedProvinceState: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedSublocation") - @ExcludeMissing - locationCreatedSublocation: JsonField = JsonMissing.of(), - @JsonProperty("LocationCreatedWorldRegion") - @ExcludeMissing - locationCreatedWorldRegion: JsonField = JsonMissing.of(), - @JsonProperty("LocationShownCity") - @ExcludeMissing - locationShownCity: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownCountryCode") - @ExcludeMissing - locationShownCountryCode: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownCountryName") - @ExcludeMissing - locationShownCountryName: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownGPSAltitude") - @ExcludeMissing - locationShownGpsAltitude: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownGPSLatitude") - @ExcludeMissing - locationShownGpsLatitude: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownGPSLongitude") - @ExcludeMissing - locationShownGpsLongitude: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownLocationId") - @ExcludeMissing - locationShownLocationId: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownLocationName") - @ExcludeMissing - locationShownLocationName: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownProvinceState") - @ExcludeMissing - locationShownProvinceState: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownSublocation") - @ExcludeMissing - locationShownSublocation: JsonField> = JsonMissing.of(), - @JsonProperty("LocationShownWorldRegion") - @ExcludeMissing - locationShownWorldRegion: JsonField> = JsonMissing.of(), - @JsonProperty("MaxAvailHeight") - @ExcludeMissing - maxAvailHeight: JsonField = JsonMissing.of(), - @JsonProperty("MaxAvailWidth") - @ExcludeMissing - maxAvailWidth: JsonField = JsonMissing.of(), - @JsonProperty("ModelAge") - @ExcludeMissing - modelAge: JsonField> = JsonMissing.of(), - @JsonProperty("ModelReleaseID") - @ExcludeMissing - modelReleaseId: JsonField> = JsonMissing.of(), - @JsonProperty("ObjectAttributeReference") - @ExcludeMissing - objectAttributeReference: JsonField = JsonMissing.of(), - @JsonProperty("ObjectName") - @ExcludeMissing - objectName: JsonField = JsonMissing.of(), - @JsonProperty("OffsetTimeOriginal") - @ExcludeMissing - offsetTimeOriginal: JsonField = JsonMissing.of(), - @JsonProperty("OrganisationInImageCode") - @ExcludeMissing - organisationInImageCode: JsonField> = JsonMissing.of(), - @JsonProperty("OrganisationInImageName") - @ExcludeMissing - organisationInImageName: JsonField> = JsonMissing.of(), - @JsonProperty("Orientation") - @ExcludeMissing - orientation: JsonField = JsonMissing.of(), - @JsonProperty("OriginalTransmissionReference") - @ExcludeMissing - originalTransmissionReference: JsonField = JsonMissing.of(), - @JsonProperty("PersonInImage") - @ExcludeMissing - personInImage: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageCvTermCvId") - @ExcludeMissing - personInImageCvTermCvId: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageCvTermId") - @ExcludeMissing - personInImageCvTermId: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageCvTermName") - @ExcludeMissing - personInImageCvTermName: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageCvTermRefinedAbout") - @ExcludeMissing - personInImageCvTermRefinedAbout: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageDescription") - @ExcludeMissing - personInImageDescription: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageId") - @ExcludeMissing - personInImageId: JsonField> = JsonMissing.of(), - @JsonProperty("PersonInImageName") - @ExcludeMissing - personInImageName: JsonField> = JsonMissing.of(), - @JsonProperty("ProductInImageDescription") - @ExcludeMissing - productInImageDescription: JsonField> = JsonMissing.of(), - @JsonProperty("ProductInImageGTIN") - @ExcludeMissing - productInImageGtin: JsonField> = JsonMissing.of(), - @JsonProperty("ProductInImageName") - @ExcludeMissing - productInImageName: JsonField> = JsonMissing.of(), - @JsonProperty("PropertyReleaseID") - @ExcludeMissing - propertyReleaseId: JsonField> = JsonMissing.of(), - @JsonProperty("ProvinceState") - @ExcludeMissing - provinceState: JsonField = JsonMissing.of(), - @JsonProperty("Rating") @ExcludeMissing rating: JsonField = JsonMissing.of(), - @JsonProperty("RegistryEntryRole") - @ExcludeMissing - registryEntryRole: JsonField> = JsonMissing.of(), - @JsonProperty("RegistryItemID") - @ExcludeMissing - registryItemId: JsonField> = JsonMissing.of(), - @JsonProperty("RegistryOrganisationID") - @ExcludeMissing - registryOrganisationId: JsonField> = JsonMissing.of(), - @JsonProperty("ResolutionUnit") - @ExcludeMissing - resolutionUnit: JsonField = JsonMissing.of(), - @JsonProperty("Rights") @ExcludeMissing rights: JsonField = JsonMissing.of(), - @JsonProperty("Scene") - @ExcludeMissing - scene: JsonField> = JsonMissing.of(), - @JsonProperty("Source") @ExcludeMissing source: JsonField = JsonMissing.of(), - @JsonProperty("SpecialInstructions") - @ExcludeMissing - specialInstructions: JsonField = JsonMissing.of(), - @JsonProperty("State") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("Subject") - @ExcludeMissing - subject: JsonField> = JsonMissing.of(), - @JsonProperty("SubjectCode") - @ExcludeMissing - subjectCode: JsonField> = JsonMissing.of(), - @JsonProperty("SubjectReference") - @ExcludeMissing - subjectReference: JsonField> = JsonMissing.of(), - @JsonProperty("Sublocation") - @ExcludeMissing - sublocation: JsonField = JsonMissing.of(), - @JsonProperty("TimeCreated") - @ExcludeMissing - timeCreated: JsonField = JsonMissing.of(), - @JsonProperty("Title") @ExcludeMissing title: JsonField = JsonMissing.of(), - @JsonProperty("TransmissionReference") - @ExcludeMissing - transmissionReference: JsonField = JsonMissing.of(), - @JsonProperty("UsageTerms") - @ExcludeMissing - usageTerms: JsonField = JsonMissing.of(), - @JsonProperty("WebStatement") - @ExcludeMissing - webStatement: JsonField = JsonMissing.of(), - @JsonProperty("Writer") @ExcludeMissing writer: JsonField = JsonMissing.of(), - @JsonProperty("WriterEditor") - @ExcludeMissing - writerEditor: JsonField = JsonMissing.of(), - @JsonProperty("XResolution") - @ExcludeMissing - xResolution: JsonField = JsonMissing.of(), - @JsonProperty("YResolution") - @ExcludeMissing - yResolution: JsonField = JsonMissing.of(), - ) : this( - aboutCvTermCvId, - aboutCvTermId, - aboutCvTermName, - aboutCvTermRefinedAbout, - additionalModelInformation, - applicationRecordVersion, - artist, - artworkCircaDateCreated, - artworkContentDescription, - artworkContributionDescription, - artworkCopyrightNotice, - artworkCopyrightOwnerId, - artworkCopyrightOwnerName, - artworkCreator, - artworkCreatorId, - artworkDateCreated, - artworkLicensorId, - artworkLicensorName, - artworkPhysicalDescription, - artworkSource, - artworkSourceInventoryNo, - artworkSourceInvUrl, - artworkStylePeriod, - artworkTitle, - authorsPosition, - byline, - bylineTitle, - caption, - captionAbstract, - captionWriter, - city, - colorSpace, - componentsConfiguration, - copyright, - copyrightNotice, - copyrightOwnerId, - copyrightOwnerName, - country, - countryCode, - countryPrimaryLocationCode, - countryPrimaryLocationName, - creator, - creatorAddress, - creatorCity, - creatorCountry, - creatorPostalCode, - creatorRegion, - creatorWorkEmail, - creatorWorkTelephone, - creatorWorkUrl, - credit, - dateCreated, - dateTimeCreated, - dateTimeOriginal, - description, - digitalImageGuid, - digitalSourceType, - embeddedEncodedRightsExpr, - embeddedEncodedRightsExprLangId, - embeddedEncodedRightsExprType, - event, - exifVersion, - flashpixVersion, - genreCvId, - genreCvTermId, - genreCvTermName, - genreCvTermRefinedAbout, - headline, - imageCreatorId, - imageCreatorImageId, - imageCreatorName, - imageDescription, - imageRegionBoundaryH, - imageRegionBoundaryRx, - imageRegionBoundaryShape, - imageRegionBoundaryUnit, - imageRegionBoundaryVerticesX, - imageRegionBoundaryVerticesY, - imageRegionBoundaryW, - imageRegionBoundaryX, - imageRegionBoundaryY, - imageRegionCtypeIdentifier, - imageRegionCtypeName, - imageRegionId, - imageRegionName, - imageRegionOrganisationInImageName, - imageRegionPersonInImage, - imageRegionRoleIdentifier, - imageRegionRoleName, - imageSupplierId, - imageSupplierImageId, - imageSupplierName, - instructions, - intellectualGenre, - keywords, - licensorCity, - licensorCountry, - licensorEmail, - licensorExtendedAddress, - licensorId, - licensorName, - licensorPostalCode, - licensorRegion, - licensorStreetAddress, - licensorTelephone1, - licensorTelephone2, - licensorUrl, - linkedEncodedRightsExpr, - linkedEncodedRightsExprLangId, - linkedEncodedRightsExprType, - location, - locationCreatedCity, - locationCreatedCountryCode, - locationCreatedCountryName, - locationCreatedGpsAltitude, - locationCreatedGpsLatitude, - locationCreatedGpsLongitude, - locationCreatedLocationId, - locationCreatedLocationName, - locationCreatedProvinceState, - locationCreatedSublocation, - locationCreatedWorldRegion, - locationShownCity, - locationShownCountryCode, - locationShownCountryName, - locationShownGpsAltitude, - locationShownGpsLatitude, - locationShownGpsLongitude, - locationShownLocationId, - locationShownLocationName, - locationShownProvinceState, - locationShownSublocation, - locationShownWorldRegion, - maxAvailHeight, - maxAvailWidth, - modelAge, - modelReleaseId, - objectAttributeReference, - objectName, - offsetTimeOriginal, - organisationInImageCode, - organisationInImageName, - orientation, - originalTransmissionReference, - personInImage, - personInImageCvTermCvId, - personInImageCvTermId, - personInImageCvTermName, - personInImageCvTermRefinedAbout, - personInImageDescription, - personInImageId, - personInImageName, - productInImageDescription, - productInImageGtin, - productInImageName, - propertyReleaseId, - provinceState, - rating, - registryEntryRole, - registryItemId, - registryOrganisationId, - resolutionUnit, - rights, - scene, - source, - specialInstructions, - state, - subject, - subjectCode, - subjectReference, - sublocation, - timeCreated, - title, - transmissionReference, - usageTerms, - webStatement, - writer, - writerEditor, - xResolution, - yResolution, - mutableMapOf(), - ) - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun aboutCvTermCvId(): Optional = aboutCvTermCvId.getOptional("AboutCvTermCvId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun aboutCvTermId(): Optional = aboutCvTermId.getOptional("AboutCvTermId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun aboutCvTermName(): Optional = aboutCvTermName.getOptional("AboutCvTermName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun aboutCvTermRefinedAbout(): Optional = - aboutCvTermRefinedAbout.getOptional("AboutCvTermRefinedAbout") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun additionalModelInformation(): Optional = - additionalModelInformation.getOptional("AdditionalModelInformation") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun applicationRecordVersion(): Optional = - applicationRecordVersion.getOptional("ApplicationRecordVersion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artist(): Optional = artist.getOptional("Artist") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCircaDateCreated(): Optional = - artworkCircaDateCreated.getOptional("ArtworkCircaDateCreated") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkContentDescription(): Optional = - artworkContentDescription.getOptional("ArtworkContentDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkContributionDescription(): Optional = - artworkContributionDescription.getOptional("ArtworkContributionDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCopyrightNotice(): Optional = - artworkCopyrightNotice.getOptional("ArtworkCopyrightNotice") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCopyrightOwnerId(): Optional = - artworkCopyrightOwnerId.getOptional("ArtworkCopyrightOwnerID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCopyrightOwnerName(): Optional = - artworkCopyrightOwnerName.getOptional("ArtworkCopyrightOwnerName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCreator(): Optional> = artworkCreator.getOptional("ArtworkCreator") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkCreatorId(): Optional> = - artworkCreatorId.getOptional("ArtworkCreatorID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkDateCreated(): Optional = - artworkDateCreated.getOptional("ArtworkDateCreated") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkLicensorId(): Optional = - artworkLicensorId.getOptional("ArtworkLicensorID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkLicensorName(): Optional = - artworkLicensorName.getOptional("ArtworkLicensorName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkPhysicalDescription(): Optional = - artworkPhysicalDescription.getOptional("ArtworkPhysicalDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkSource(): Optional = artworkSource.getOptional("ArtworkSource") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkSourceInventoryNo(): Optional = - artworkSourceInventoryNo.getOptional("ArtworkSourceInventoryNo") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkSourceInvUrl(): Optional = - artworkSourceInvUrl.getOptional("ArtworkSourceInvURL") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkStylePeriod(): Optional> = - artworkStylePeriod.getOptional("ArtworkStylePeriod") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun artworkTitle(): Optional = artworkTitle.getOptional("ArtworkTitle") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun authorsPosition(): Optional = authorsPosition.getOptional("AuthorsPosition") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun byline(): Optional = byline.getOptional("Byline") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun bylineTitle(): Optional = bylineTitle.getOptional("BylineTitle") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun caption(): Optional = caption.getOptional("Caption") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun captionAbstract(): Optional = captionAbstract.getOptional("CaptionAbstract") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun captionWriter(): Optional = captionWriter.getOptional("CaptionWriter") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun city(): Optional = city.getOptional("City") - - /** - * @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 componentsConfiguration(): Optional = - componentsConfiguration.getOptional("ComponentsConfiguration") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun copyright(): Optional = copyright.getOptional("Copyright") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun copyrightNotice(): Optional = copyrightNotice.getOptional("CopyrightNotice") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun copyrightOwnerId(): Optional> = - copyrightOwnerId.getOptional("CopyrightOwnerID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun copyrightOwnerName(): Optional> = - copyrightOwnerName.getOptional("CopyrightOwnerName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun country(): Optional = country.getOptional("Country") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun countryCode(): Optional = countryCode.getOptional("CountryCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun countryPrimaryLocationCode(): Optional = - countryPrimaryLocationCode.getOptional("CountryPrimaryLocationCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun countryPrimaryLocationName(): Optional = - countryPrimaryLocationName.getOptional("CountryPrimaryLocationName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creator(): Optional = creator.getOptional("Creator") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorAddress(): Optional = creatorAddress.getOptional("CreatorAddress") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorCity(): Optional = creatorCity.getOptional("CreatorCity") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorCountry(): Optional = creatorCountry.getOptional("CreatorCountry") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorPostalCode(): Optional = - creatorPostalCode.getOptional("CreatorPostalCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorRegion(): Optional = creatorRegion.getOptional("CreatorRegion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorWorkEmail(): Optional = creatorWorkEmail.getOptional("CreatorWorkEmail") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorWorkTelephone(): Optional = - creatorWorkTelephone.getOptional("CreatorWorkTelephone") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun creatorWorkUrl(): Optional = creatorWorkUrl.getOptional("CreatorWorkURL") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun credit(): Optional = credit.getOptional("Credit") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dateCreated(): Optional = dateCreated.getOptional("DateCreated") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun dateTimeCreated(): Optional = - dateTimeCreated.getOptional("DateTimeCreated") - - /** - * @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 description(): Optional = description.getOptional("Description") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun digitalImageGuid(): Optional = digitalImageGuid.getOptional("DigitalImageGUID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun digitalSourceType(): Optional = - digitalSourceType.getOptional("DigitalSourceType") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun embeddedEncodedRightsExpr(): Optional = - embeddedEncodedRightsExpr.getOptional("EmbeddedEncodedRightsExpr") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun embeddedEncodedRightsExprLangId(): Optional = - embeddedEncodedRightsExprLangId.getOptional("EmbeddedEncodedRightsExprLangID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun embeddedEncodedRightsExprType(): Optional = - embeddedEncodedRightsExprType.getOptional("EmbeddedEncodedRightsExprType") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun event(): Optional = event.getOptional("Event") - - /** - * @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 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 genreCvId(): Optional = genreCvId.getOptional("GenreCvId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun genreCvTermId(): Optional = genreCvTermId.getOptional("GenreCvTermId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun genreCvTermName(): Optional = genreCvTermName.getOptional("GenreCvTermName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun genreCvTermRefinedAbout(): Optional = - genreCvTermRefinedAbout.getOptional("GenreCvTermRefinedAbout") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun headline(): Optional = headline.getOptional("Headline") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageCreatorId(): Optional = imageCreatorId.getOptional("ImageCreatorID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageCreatorImageId(): Optional = - imageCreatorImageId.getOptional("ImageCreatorImageID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageCreatorName(): Optional = imageCreatorName.getOptional("ImageCreatorName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageDescription(): Optional = imageDescription.getOptional("ImageDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryH(): Optional> = - imageRegionBoundaryH.getOptional("ImageRegionBoundaryH") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryRx(): Optional> = - imageRegionBoundaryRx.getOptional("ImageRegionBoundaryRx") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryShape(): Optional> = - imageRegionBoundaryShape.getOptional("ImageRegionBoundaryShape") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryUnit(): Optional> = - imageRegionBoundaryUnit.getOptional("ImageRegionBoundaryUnit") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryVerticesX(): Optional> = - imageRegionBoundaryVerticesX.getOptional("ImageRegionBoundaryVerticesX") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryVerticesY(): Optional> = - imageRegionBoundaryVerticesY.getOptional("ImageRegionBoundaryVerticesY") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryW(): Optional> = - imageRegionBoundaryW.getOptional("ImageRegionBoundaryW") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryX(): Optional> = - imageRegionBoundaryX.getOptional("ImageRegionBoundaryX") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionBoundaryY(): Optional> = - imageRegionBoundaryY.getOptional("ImageRegionBoundaryY") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionCtypeIdentifier(): Optional> = - imageRegionCtypeIdentifier.getOptional("ImageRegionCtypeIdentifier") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionCtypeName(): Optional> = - imageRegionCtypeName.getOptional("ImageRegionCtypeName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionId(): Optional> = imageRegionId.getOptional("ImageRegionID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionName(): Optional> = - imageRegionName.getOptional("ImageRegionName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionOrganisationInImageName(): Optional> = - imageRegionOrganisationInImageName.getOptional("ImageRegionOrganisationInImageName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionPersonInImage(): Optional> = - imageRegionPersonInImage.getOptional("ImageRegionPersonInImage") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionRoleIdentifier(): Optional> = - imageRegionRoleIdentifier.getOptional("ImageRegionRoleIdentifier") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageRegionRoleName(): Optional> = - imageRegionRoleName.getOptional("ImageRegionRoleName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageSupplierId(): Optional = imageSupplierId.getOptional("ImageSupplierID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageSupplierImageId(): Optional = - imageSupplierImageId.getOptional("ImageSupplierImageID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun imageSupplierName(): Optional = - imageSupplierName.getOptional("ImageSupplierName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun instructions(): Optional = instructions.getOptional("Instructions") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun intellectualGenre(): Optional = - intellectualGenre.getOptional("IntellectualGenre") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun keywords(): Optional> = keywords.getOptional("Keywords") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorCity(): Optional> = licensorCity.getOptional("LicensorCity") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorCountry(): Optional> = - licensorCountry.getOptional("LicensorCountry") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorEmail(): Optional> = licensorEmail.getOptional("LicensorEmail") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorExtendedAddress(): Optional> = - licensorExtendedAddress.getOptional("LicensorExtendedAddress") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorId(): Optional> = licensorId.getOptional("LicensorID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorName(): Optional> = licensorName.getOptional("LicensorName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorPostalCode(): Optional> = - licensorPostalCode.getOptional("LicensorPostalCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorRegion(): Optional> = licensorRegion.getOptional("LicensorRegion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorStreetAddress(): Optional> = - licensorStreetAddress.getOptional("LicensorStreetAddress") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorTelephone1(): Optional> = - licensorTelephone1.getOptional("LicensorTelephone1") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorTelephone2(): Optional> = - licensorTelephone2.getOptional("LicensorTelephone2") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun licensorUrl(): Optional> = licensorUrl.getOptional("LicensorURL") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun linkedEncodedRightsExpr(): Optional = - linkedEncodedRightsExpr.getOptional("LinkedEncodedRightsExpr") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun linkedEncodedRightsExprLangId(): Optional = - linkedEncodedRightsExprLangId.getOptional("LinkedEncodedRightsExprLangID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun linkedEncodedRightsExprType(): Optional = - linkedEncodedRightsExprType.getOptional("LinkedEncodedRightsExprType") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun location(): Optional = location.getOptional("Location") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedCity(): Optional = - locationCreatedCity.getOptional("LocationCreatedCity") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedCountryCode(): Optional = - locationCreatedCountryCode.getOptional("LocationCreatedCountryCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedCountryName(): Optional = - locationCreatedCountryName.getOptional("LocationCreatedCountryName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedGpsAltitude(): Optional = - locationCreatedGpsAltitude.getOptional("LocationCreatedGPSAltitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedGpsLatitude(): Optional = - locationCreatedGpsLatitude.getOptional("LocationCreatedGPSLatitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedGpsLongitude(): Optional = - locationCreatedGpsLongitude.getOptional("LocationCreatedGPSLongitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedLocationId(): Optional = - locationCreatedLocationId.getOptional("LocationCreatedLocationId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedLocationName(): Optional = - locationCreatedLocationName.getOptional("LocationCreatedLocationName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedProvinceState(): Optional = - locationCreatedProvinceState.getOptional("LocationCreatedProvinceState") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedSublocation(): Optional = - locationCreatedSublocation.getOptional("LocationCreatedSublocation") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationCreatedWorldRegion(): Optional = - locationCreatedWorldRegion.getOptional("LocationCreatedWorldRegion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownCity(): Optional> = - locationShownCity.getOptional("LocationShownCity") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownCountryCode(): Optional> = - locationShownCountryCode.getOptional("LocationShownCountryCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownCountryName(): Optional> = - locationShownCountryName.getOptional("LocationShownCountryName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownGpsAltitude(): Optional> = - locationShownGpsAltitude.getOptional("LocationShownGPSAltitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownGpsLatitude(): Optional> = - locationShownGpsLatitude.getOptional("LocationShownGPSLatitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownGpsLongitude(): Optional> = - locationShownGpsLongitude.getOptional("LocationShownGPSLongitude") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownLocationId(): Optional> = - locationShownLocationId.getOptional("LocationShownLocationId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownLocationName(): Optional> = - locationShownLocationName.getOptional("LocationShownLocationName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownProvinceState(): Optional> = - locationShownProvinceState.getOptional("LocationShownProvinceState") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownSublocation(): Optional> = - locationShownSublocation.getOptional("LocationShownSublocation") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun locationShownWorldRegion(): Optional> = - locationShownWorldRegion.getOptional("LocationShownWorldRegion") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun maxAvailHeight(): Optional = maxAvailHeight.getOptional("MaxAvailHeight") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun maxAvailWidth(): Optional = maxAvailWidth.getOptional("MaxAvailWidth") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun modelAge(): Optional> = modelAge.getOptional("ModelAge") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun modelReleaseId(): Optional> = modelReleaseId.getOptional("ModelReleaseID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun objectAttributeReference(): Optional = - objectAttributeReference.getOptional("ObjectAttributeReference") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun objectName(): Optional = objectName.getOptional("ObjectName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun offsetTimeOriginal(): Optional = - offsetTimeOriginal.getOptional("OffsetTimeOriginal") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun organisationInImageCode(): Optional> = - organisationInImageCode.getOptional("OrganisationInImageCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun organisationInImageName(): Optional> = - organisationInImageName.getOptional("OrganisationInImageName") - - /** - * @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 originalTransmissionReference(): Optional = - originalTransmissionReference.getOptional("OriginalTransmissionReference") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImage(): Optional> = personInImage.getOptional("PersonInImage") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageCvTermCvId(): Optional> = - personInImageCvTermCvId.getOptional("PersonInImageCvTermCvId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageCvTermId(): Optional> = - personInImageCvTermId.getOptional("PersonInImageCvTermId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageCvTermName(): Optional> = - personInImageCvTermName.getOptional("PersonInImageCvTermName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageCvTermRefinedAbout(): Optional> = - personInImageCvTermRefinedAbout.getOptional("PersonInImageCvTermRefinedAbout") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageDescription(): Optional> = - personInImageDescription.getOptional("PersonInImageDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageId(): Optional> = - personInImageId.getOptional("PersonInImageId") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun personInImageName(): Optional> = - personInImageName.getOptional("PersonInImageName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productInImageDescription(): Optional> = - productInImageDescription.getOptional("ProductInImageDescription") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productInImageGtin(): Optional> = - productInImageGtin.getOptional("ProductInImageGTIN") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productInImageName(): Optional> = - productInImageName.getOptional("ProductInImageName") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun propertyReleaseId(): Optional> = - propertyReleaseId.getOptional("PropertyReleaseID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun provinceState(): Optional = provinceState.getOptional("ProvinceState") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun rating(): Optional = rating.getOptional("Rating") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun registryEntryRole(): Optional> = - registryEntryRole.getOptional("RegistryEntryRole") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun registryItemId(): Optional> = registryItemId.getOptional("RegistryItemID") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun registryOrganisationId(): Optional> = - registryOrganisationId.getOptional("RegistryOrganisationID") - - /** - * @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 rights(): Optional = rights.getOptional("Rights") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun scene(): Optional> = scene.getOptional("Scene") - - /** - * @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") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun specialInstructions(): Optional = - specialInstructions.getOptional("SpecialInstructions") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun state(): Optional = state.getOptional("State") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subject(): Optional> = subject.getOptional("Subject") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subjectCode(): Optional> = subjectCode.getOptional("SubjectCode") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subjectReference(): Optional> = - subjectReference.getOptional("SubjectReference") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun sublocation(): Optional = sublocation.getOptional("Sublocation") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun timeCreated(): Optional = timeCreated.getOptional("TimeCreated") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun title(): Optional = title.getOptional("Title") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun transmissionReference(): Optional = - transmissionReference.getOptional("TransmissionReference") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun usageTerms(): Optional = usageTerms.getOptional("UsageTerms") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webStatement(): Optional = webStatement.getOptional("WebStatement") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun writer(): Optional = writer.getOptional("Writer") - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun writerEditor(): Optional = writerEditor.getOptional("WriterEditor") - - /** - * @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 [aboutCvTermCvId]. - * - * Unlike [aboutCvTermCvId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("AboutCvTermCvId") - @ExcludeMissing - fun _aboutCvTermCvId(): JsonField = aboutCvTermCvId - - /** - * Returns the raw JSON value of [aboutCvTermId]. - * - * Unlike [aboutCvTermId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("AboutCvTermId") - @ExcludeMissing - fun _aboutCvTermId(): JsonField = aboutCvTermId - - /** - * Returns the raw JSON value of [aboutCvTermName]. - * - * Unlike [aboutCvTermName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("AboutCvTermName") - @ExcludeMissing - fun _aboutCvTermName(): JsonField = aboutCvTermName - - /** - * Returns the raw JSON value of [aboutCvTermRefinedAbout]. - * - * Unlike [aboutCvTermRefinedAbout], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("AboutCvTermRefinedAbout") - @ExcludeMissing - fun _aboutCvTermRefinedAbout(): JsonField = aboutCvTermRefinedAbout - - /** - * Returns the raw JSON value of [additionalModelInformation]. - * - * Unlike [additionalModelInformation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("AdditionalModelInformation") - @ExcludeMissing - fun _additionalModelInformation(): JsonField = additionalModelInformation - - /** - * Returns the raw JSON value of [applicationRecordVersion]. - * - * Unlike [applicationRecordVersion], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ApplicationRecordVersion") - @ExcludeMissing - fun _applicationRecordVersion(): JsonField = applicationRecordVersion - - /** - * Returns the raw JSON value of [artist]. - * - * Unlike [artist], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Artist") @ExcludeMissing fun _artist(): JsonField = artist - - /** - * Returns the raw JSON value of [artworkCircaDateCreated]. - * - * Unlike [artworkCircaDateCreated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkCircaDateCreated") - @ExcludeMissing - fun _artworkCircaDateCreated(): JsonField = artworkCircaDateCreated - - /** - * Returns the raw JSON value of [artworkContentDescription]. - * - * Unlike [artworkContentDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkContentDescription") - @ExcludeMissing - fun _artworkContentDescription(): JsonField = artworkContentDescription - - /** - * Returns the raw JSON value of [artworkContributionDescription]. - * - * Unlike [artworkContributionDescription], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("ArtworkContributionDescription") - @ExcludeMissing - fun _artworkContributionDescription(): JsonField = artworkContributionDescription - - /** - * Returns the raw JSON value of [artworkCopyrightNotice]. - * - * Unlike [artworkCopyrightNotice], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkCopyrightNotice") - @ExcludeMissing - fun _artworkCopyrightNotice(): JsonField = artworkCopyrightNotice - - /** - * Returns the raw JSON value of [artworkCopyrightOwnerId]. - * - * Unlike [artworkCopyrightOwnerId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkCopyrightOwnerID") - @ExcludeMissing - fun _artworkCopyrightOwnerId(): JsonField = artworkCopyrightOwnerId - - /** - * Returns the raw JSON value of [artworkCopyrightOwnerName]. - * - * Unlike [artworkCopyrightOwnerName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkCopyrightOwnerName") - @ExcludeMissing - fun _artworkCopyrightOwnerName(): JsonField = artworkCopyrightOwnerName - - /** - * Returns the raw JSON value of [artworkCreator]. - * - * Unlike [artworkCreator], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkCreator") - @ExcludeMissing - fun _artworkCreator(): JsonField> = artworkCreator - - /** - * Returns the raw JSON value of [artworkCreatorId]. - * - * Unlike [artworkCreatorId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkCreatorID") - @ExcludeMissing - fun _artworkCreatorId(): JsonField> = artworkCreatorId - - /** - * Returns the raw JSON value of [artworkDateCreated]. - * - * Unlike [artworkDateCreated], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkDateCreated") - @ExcludeMissing - fun _artworkDateCreated(): JsonField = artworkDateCreated - - /** - * Returns the raw JSON value of [artworkLicensorId]. - * - * Unlike [artworkLicensorId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkLicensorID") - @ExcludeMissing - fun _artworkLicensorId(): JsonField = artworkLicensorId - - /** - * Returns the raw JSON value of [artworkLicensorName]. - * - * Unlike [artworkLicensorName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkLicensorName") - @ExcludeMissing - fun _artworkLicensorName(): JsonField = artworkLicensorName - - /** - * Returns the raw JSON value of [artworkPhysicalDescription]. - * - * Unlike [artworkPhysicalDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkPhysicalDescription") - @ExcludeMissing - fun _artworkPhysicalDescription(): JsonField = artworkPhysicalDescription - - /** - * Returns the raw JSON value of [artworkSource]. - * - * Unlike [artworkSource], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkSource") - @ExcludeMissing - fun _artworkSource(): JsonField = artworkSource - - /** - * Returns the raw JSON value of [artworkSourceInventoryNo]. - * - * Unlike [artworkSourceInventoryNo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkSourceInventoryNo") - @ExcludeMissing - fun _artworkSourceInventoryNo(): JsonField = artworkSourceInventoryNo - - /** - * Returns the raw JSON value of [artworkSourceInvUrl]. - * - * Unlike [artworkSourceInvUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkSourceInvURL") - @ExcludeMissing - fun _artworkSourceInvUrl(): JsonField = artworkSourceInvUrl - - /** - * Returns the raw JSON value of [artworkStylePeriod]. - * - * Unlike [artworkStylePeriod], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ArtworkStylePeriod") - @ExcludeMissing - fun _artworkStylePeriod(): JsonField> = artworkStylePeriod - - /** - * Returns the raw JSON value of [artworkTitle]. - * - * Unlike [artworkTitle], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ArtworkTitle") - @ExcludeMissing - fun _artworkTitle(): JsonField = artworkTitle - - /** - * Returns the raw JSON value of [authorsPosition]. - * - * Unlike [authorsPosition], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("AuthorsPosition") - @ExcludeMissing - fun _authorsPosition(): JsonField = authorsPosition - - /** - * Returns the raw JSON value of [byline]. - * - * Unlike [byline], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Byline") @ExcludeMissing fun _byline(): JsonField = byline - - /** - * Returns the raw JSON value of [bylineTitle]. - * - * Unlike [bylineTitle], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("BylineTitle") - @ExcludeMissing - fun _bylineTitle(): JsonField = bylineTitle - - /** - * Returns the raw JSON value of [caption]. - * - * Unlike [caption], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Caption") @ExcludeMissing fun _caption(): JsonField = caption - - /** - * Returns the raw JSON value of [captionAbstract]. - * - * Unlike [captionAbstract], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CaptionAbstract") - @ExcludeMissing - fun _captionAbstract(): JsonField = captionAbstract - - /** - * Returns the raw JSON value of [captionWriter]. - * - * Unlike [captionWriter], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CaptionWriter") - @ExcludeMissing - fun _captionWriter(): JsonField = captionWriter - - /** - * Returns the raw JSON value of [city]. - * - * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("City") @ExcludeMissing fun _city(): JsonField = city - - /** - * 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 [componentsConfiguration]. - * - * Unlike [componentsConfiguration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ComponentsConfiguration") - @ExcludeMissing - fun _componentsConfiguration(): JsonField = componentsConfiguration - - /** - * Returns the raw JSON value of [copyright]. - * - * Unlike [copyright], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Copyright") @ExcludeMissing fun _copyright(): JsonField = copyright - - /** - * Returns the raw JSON value of [copyrightNotice]. - * - * Unlike [copyrightNotice], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CopyrightNotice") - @ExcludeMissing - fun _copyrightNotice(): JsonField = copyrightNotice - - /** - * Returns the raw JSON value of [copyrightOwnerId]. - * - * Unlike [copyrightOwnerId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CopyrightOwnerID") - @ExcludeMissing - fun _copyrightOwnerId(): JsonField> = copyrightOwnerId - - /** - * Returns the raw JSON value of [copyrightOwnerName]. - * - * Unlike [copyrightOwnerName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("CopyrightOwnerName") - @ExcludeMissing - fun _copyrightOwnerName(): JsonField> = copyrightOwnerName - - /** - * Returns the raw JSON value of [country]. - * - * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Country") @ExcludeMissing fun _country(): JsonField = country - - /** - * Returns the raw JSON value of [countryCode]. - * - * Unlike [countryCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("CountryCode") - @ExcludeMissing - fun _countryCode(): JsonField = countryCode - - /** - * Returns the raw JSON value of [countryPrimaryLocationCode]. - * - * Unlike [countryPrimaryLocationCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("CountryPrimaryLocationCode") - @ExcludeMissing - fun _countryPrimaryLocationCode(): JsonField = countryPrimaryLocationCode - - /** - * Returns the raw JSON value of [countryPrimaryLocationName]. - * - * Unlike [countryPrimaryLocationName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("CountryPrimaryLocationName") - @ExcludeMissing - fun _countryPrimaryLocationName(): JsonField = countryPrimaryLocationName - - /** - * Returns the raw JSON value of [creator]. - * - * Unlike [creator], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Creator") @ExcludeMissing fun _creator(): JsonField = creator - - /** - * Returns the raw JSON value of [creatorAddress]. - * - * Unlike [creatorAddress], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorAddress") - @ExcludeMissing - fun _creatorAddress(): JsonField = creatorAddress - - /** - * Returns the raw JSON value of [creatorCity]. - * - * Unlike [creatorCity], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("CreatorCity") - @ExcludeMissing - fun _creatorCity(): JsonField = creatorCity - - /** - * Returns the raw JSON value of [creatorCountry]. - * - * Unlike [creatorCountry], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorCountry") - @ExcludeMissing - fun _creatorCountry(): JsonField = creatorCountry - - /** - * Returns the raw JSON value of [creatorPostalCode]. - * - * Unlike [creatorPostalCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorPostalCode") - @ExcludeMissing - fun _creatorPostalCode(): JsonField = creatorPostalCode - - /** - * Returns the raw JSON value of [creatorRegion]. - * - * Unlike [creatorRegion], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorRegion") - @ExcludeMissing - fun _creatorRegion(): JsonField = creatorRegion - - /** - * Returns the raw JSON value of [creatorWorkEmail]. - * - * Unlike [creatorWorkEmail], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorWorkEmail") - @ExcludeMissing - fun _creatorWorkEmail(): JsonField = creatorWorkEmail - - /** - * Returns the raw JSON value of [creatorWorkTelephone]. - * - * Unlike [creatorWorkTelephone], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("CreatorWorkTelephone") - @ExcludeMissing - fun _creatorWorkTelephone(): JsonField = creatorWorkTelephone - - /** - * Returns the raw JSON value of [creatorWorkUrl]. - * - * Unlike [creatorWorkUrl], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("CreatorWorkURL") - @ExcludeMissing - fun _creatorWorkUrl(): JsonField = creatorWorkUrl - - /** - * Returns the raw JSON value of [credit]. - * - * Unlike [credit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Credit") @ExcludeMissing fun _credit(): JsonField = credit - - /** - * Returns the raw JSON value of [dateCreated]. - * - * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("DateCreated") - @ExcludeMissing - fun _dateCreated(): JsonField = dateCreated - - /** - * Returns the raw JSON value of [dateTimeCreated]. - * - * Unlike [dateTimeCreated], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("DateTimeCreated") - @ExcludeMissing - fun _dateTimeCreated(): JsonField = dateTimeCreated - - /** - * 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 [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 [digitalImageGuid]. - * - * Unlike [digitalImageGuid], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("DigitalImageGUID") - @ExcludeMissing - fun _digitalImageGuid(): JsonField = digitalImageGuid - - /** - * Returns the raw JSON value of [digitalSourceType]. - * - * Unlike [digitalSourceType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("DigitalSourceType") - @ExcludeMissing - fun _digitalSourceType(): JsonField = digitalSourceType - - /** - * Returns the raw JSON value of [embeddedEncodedRightsExpr]. - * - * Unlike [embeddedEncodedRightsExpr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("EmbeddedEncodedRightsExpr") - @ExcludeMissing - fun _embeddedEncodedRightsExpr(): JsonField = embeddedEncodedRightsExpr - - /** - * Returns the raw JSON value of [embeddedEncodedRightsExprLangId]. - * - * Unlike [embeddedEncodedRightsExprLangId], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("EmbeddedEncodedRightsExprLangID") - @ExcludeMissing - fun _embeddedEncodedRightsExprLangId(): JsonField = embeddedEncodedRightsExprLangId - - /** - * Returns the raw JSON value of [embeddedEncodedRightsExprType]. - * - * Unlike [embeddedEncodedRightsExprType], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("EmbeddedEncodedRightsExprType") - @ExcludeMissing - fun _embeddedEncodedRightsExprType(): JsonField = embeddedEncodedRightsExprType - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Event") @ExcludeMissing fun _event(): JsonField = event - - /** - * 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 [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 [genreCvId]. - * - * Unlike [genreCvId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("GenreCvId") @ExcludeMissing fun _genreCvId(): JsonField = genreCvId - - /** - * Returns the raw JSON value of [genreCvTermId]. - * - * Unlike [genreCvTermId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GenreCvTermId") - @ExcludeMissing - fun _genreCvTermId(): JsonField = genreCvTermId - - /** - * Returns the raw JSON value of [genreCvTermName]. - * - * Unlike [genreCvTermName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("GenreCvTermName") - @ExcludeMissing - fun _genreCvTermName(): JsonField = genreCvTermName - - /** - * Returns the raw JSON value of [genreCvTermRefinedAbout]. - * - * Unlike [genreCvTermRefinedAbout], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("GenreCvTermRefinedAbout") - @ExcludeMissing - fun _genreCvTermRefinedAbout(): JsonField = genreCvTermRefinedAbout - - /** - * Returns the raw JSON value of [headline]. - * - * Unlike [headline], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Headline") @ExcludeMissing fun _headline(): JsonField = headline - - /** - * Returns the raw JSON value of [imageCreatorId]. - * - * Unlike [imageCreatorId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageCreatorID") - @ExcludeMissing - fun _imageCreatorId(): JsonField = imageCreatorId - - /** - * Returns the raw JSON value of [imageCreatorImageId]. - * - * Unlike [imageCreatorImageId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageCreatorImageID") - @ExcludeMissing - fun _imageCreatorImageId(): JsonField = imageCreatorImageId - - /** - * Returns the raw JSON value of [imageCreatorName]. - * - * Unlike [imageCreatorName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageCreatorName") - @ExcludeMissing - fun _imageCreatorName(): JsonField = imageCreatorName - - /** - * Returns the raw JSON value of [imageDescription]. - * - * Unlike [imageDescription], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageDescription") - @ExcludeMissing - fun _imageDescription(): JsonField = imageDescription - - /** - * Returns the raw JSON value of [imageRegionBoundaryH]. - * - * Unlike [imageRegionBoundaryH], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryH") - @ExcludeMissing - fun _imageRegionBoundaryH(): JsonField> = imageRegionBoundaryH - - /** - * Returns the raw JSON value of [imageRegionBoundaryRx]. - * - * Unlike [imageRegionBoundaryRx], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryRx") - @ExcludeMissing - fun _imageRegionBoundaryRx(): JsonField> = imageRegionBoundaryRx - - /** - * Returns the raw JSON value of [imageRegionBoundaryShape]. - * - * Unlike [imageRegionBoundaryShape], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryShape") - @ExcludeMissing - fun _imageRegionBoundaryShape(): JsonField> = imageRegionBoundaryShape - - /** - * Returns the raw JSON value of [imageRegionBoundaryUnit]. - * - * Unlike [imageRegionBoundaryUnit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryUnit") - @ExcludeMissing - fun _imageRegionBoundaryUnit(): JsonField> = imageRegionBoundaryUnit - - /** - * Returns the raw JSON value of [imageRegionBoundaryVerticesX]. - * - * Unlike [imageRegionBoundaryVerticesX], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryVerticesX") - @ExcludeMissing - fun _imageRegionBoundaryVerticesX(): JsonField> = imageRegionBoundaryVerticesX - - /** - * Returns the raw JSON value of [imageRegionBoundaryVerticesY]. - * - * Unlike [imageRegionBoundaryVerticesY], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryVerticesY") - @ExcludeMissing - fun _imageRegionBoundaryVerticesY(): JsonField> = imageRegionBoundaryVerticesY - - /** - * Returns the raw JSON value of [imageRegionBoundaryW]. - * - * Unlike [imageRegionBoundaryW], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryW") - @ExcludeMissing - fun _imageRegionBoundaryW(): JsonField> = imageRegionBoundaryW - - /** - * Returns the raw JSON value of [imageRegionBoundaryX]. - * - * Unlike [imageRegionBoundaryX], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryX") - @ExcludeMissing - fun _imageRegionBoundaryX(): JsonField> = imageRegionBoundaryX - - /** - * Returns the raw JSON value of [imageRegionBoundaryY]. - * - * Unlike [imageRegionBoundaryY], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionBoundaryY") - @ExcludeMissing - fun _imageRegionBoundaryY(): JsonField> = imageRegionBoundaryY - - /** - * Returns the raw JSON value of [imageRegionCtypeIdentifier]. - * - * Unlike [imageRegionCtypeIdentifier], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionCtypeIdentifier") - @ExcludeMissing - fun _imageRegionCtypeIdentifier(): JsonField> = imageRegionCtypeIdentifier - - /** - * Returns the raw JSON value of [imageRegionCtypeName]. - * - * Unlike [imageRegionCtypeName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionCtypeName") - @ExcludeMissing - fun _imageRegionCtypeName(): JsonField> = imageRegionCtypeName - - /** - * Returns the raw JSON value of [imageRegionId]. - * - * Unlike [imageRegionId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageRegionID") - @ExcludeMissing - fun _imageRegionId(): JsonField> = imageRegionId - - /** - * Returns the raw JSON value of [imageRegionName]. - * - * Unlike [imageRegionName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageRegionName") - @ExcludeMissing - fun _imageRegionName(): JsonField> = imageRegionName - - /** - * Returns the raw JSON value of [imageRegionOrganisationInImageName]. - * - * Unlike [imageRegionOrganisationInImageName], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("ImageRegionOrganisationInImageName") - @ExcludeMissing - fun _imageRegionOrganisationInImageName(): JsonField> = - imageRegionOrganisationInImageName - - /** - * Returns the raw JSON value of [imageRegionPersonInImage]. - * - * Unlike [imageRegionPersonInImage], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionPersonInImage") - @ExcludeMissing - fun _imageRegionPersonInImage(): JsonField> = imageRegionPersonInImage - - /** - * Returns the raw JSON value of [imageRegionRoleIdentifier]. - * - * Unlike [imageRegionRoleIdentifier], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionRoleIdentifier") - @ExcludeMissing - fun _imageRegionRoleIdentifier(): JsonField> = imageRegionRoleIdentifier - - /** - * Returns the raw JSON value of [imageRegionRoleName]. - * - * Unlike [imageRegionRoleName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageRegionRoleName") - @ExcludeMissing - fun _imageRegionRoleName(): JsonField> = imageRegionRoleName - - /** - * Returns the raw JSON value of [imageSupplierId]. - * - * Unlike [imageSupplierId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageSupplierID") - @ExcludeMissing - fun _imageSupplierId(): JsonField = imageSupplierId - - /** - * Returns the raw JSON value of [imageSupplierImageId]. - * - * Unlike [imageSupplierImageId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ImageSupplierImageID") - @ExcludeMissing - fun _imageSupplierImageId(): JsonField = imageSupplierImageId - - /** - * Returns the raw JSON value of [imageSupplierName]. - * - * Unlike [imageSupplierName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ImageSupplierName") - @ExcludeMissing - fun _imageSupplierName(): JsonField = imageSupplierName - - /** - * Returns the raw JSON value of [instructions]. - * - * Unlike [instructions], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("Instructions") - @ExcludeMissing - fun _instructions(): JsonField = instructions - - /** - * Returns the raw JSON value of [intellectualGenre]. - * - * Unlike [intellectualGenre], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("IntellectualGenre") - @ExcludeMissing - fun _intellectualGenre(): JsonField = intellectualGenre - - /** - * Returns the raw JSON value of [keywords]. - * - * Unlike [keywords], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Keywords") - @ExcludeMissing - fun _keywords(): JsonField> = keywords - - /** - * Returns the raw JSON value of [licensorCity]. - * - * Unlike [licensorCity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorCity") - @ExcludeMissing - fun _licensorCity(): JsonField> = licensorCity - - /** - * Returns the raw JSON value of [licensorCountry]. - * - * Unlike [licensorCountry], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorCountry") - @ExcludeMissing - fun _licensorCountry(): JsonField> = licensorCountry - - /** - * Returns the raw JSON value of [licensorEmail]. - * - * Unlike [licensorEmail], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorEmail") - @ExcludeMissing - fun _licensorEmail(): JsonField> = licensorEmail - - /** - * Returns the raw JSON value of [licensorExtendedAddress]. - * - * Unlike [licensorExtendedAddress], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorExtendedAddress") - @ExcludeMissing - fun _licensorExtendedAddress(): JsonField> = licensorExtendedAddress - - /** - * Returns the raw JSON value of [licensorId]. - * - * Unlike [licensorId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("LicensorID") - @ExcludeMissing - fun _licensorId(): JsonField> = licensorId - - /** - * Returns the raw JSON value of [licensorName]. - * - * Unlike [licensorName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorName") - @ExcludeMissing - fun _licensorName(): JsonField> = licensorName - - /** - * Returns the raw JSON value of [licensorPostalCode]. - * - * Unlike [licensorPostalCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorPostalCode") - @ExcludeMissing - fun _licensorPostalCode(): JsonField> = licensorPostalCode - - /** - * Returns the raw JSON value of [licensorRegion]. - * - * Unlike [licensorRegion], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LicensorRegion") - @ExcludeMissing - fun _licensorRegion(): JsonField> = licensorRegion - - /** - * Returns the raw JSON value of [licensorStreetAddress]. - * - * Unlike [licensorStreetAddress], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorStreetAddress") - @ExcludeMissing - fun _licensorStreetAddress(): JsonField> = licensorStreetAddress - - /** - * Returns the raw JSON value of [licensorTelephone1]. - * - * Unlike [licensorTelephone1], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorTelephone1") - @ExcludeMissing - fun _licensorTelephone1(): JsonField> = licensorTelephone1 - - /** - * Returns the raw JSON value of [licensorTelephone2]. - * - * Unlike [licensorTelephone2], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LicensorTelephone2") - @ExcludeMissing - fun _licensorTelephone2(): JsonField> = licensorTelephone2 - - /** - * Returns the raw JSON value of [licensorUrl]. - * - * Unlike [licensorUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("LicensorURL") - @ExcludeMissing - fun _licensorUrl(): JsonField> = licensorUrl - - /** - * Returns the raw JSON value of [linkedEncodedRightsExpr]. - * - * Unlike [linkedEncodedRightsExpr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LinkedEncodedRightsExpr") - @ExcludeMissing - fun _linkedEncodedRightsExpr(): JsonField = linkedEncodedRightsExpr - - /** - * Returns the raw JSON value of [linkedEncodedRightsExprLangId]. - * - * Unlike [linkedEncodedRightsExprLangId], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("LinkedEncodedRightsExprLangID") - @ExcludeMissing - fun _linkedEncodedRightsExprLangId(): JsonField = linkedEncodedRightsExprLangId - - /** - * Returns the raw JSON value of [linkedEncodedRightsExprType]. - * - * Unlike [linkedEncodedRightsExprType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LinkedEncodedRightsExprType") - @ExcludeMissing - fun _linkedEncodedRightsExprType(): JsonField = linkedEncodedRightsExprType - - /** - * Returns the raw JSON value of [location]. - * - * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Location") @ExcludeMissing fun _location(): JsonField = location - - /** - * Returns the raw JSON value of [locationCreatedCity]. - * - * Unlike [locationCreatedCity], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedCity") - @ExcludeMissing - fun _locationCreatedCity(): JsonField = locationCreatedCity - - /** - * Returns the raw JSON value of [locationCreatedCountryCode]. - * - * Unlike [locationCreatedCountryCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedCountryCode") - @ExcludeMissing - fun _locationCreatedCountryCode(): JsonField = locationCreatedCountryCode - - /** - * Returns the raw JSON value of [locationCreatedCountryName]. - * - * Unlike [locationCreatedCountryName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedCountryName") - @ExcludeMissing - fun _locationCreatedCountryName(): JsonField = locationCreatedCountryName - - /** - * Returns the raw JSON value of [locationCreatedGpsAltitude]. - * - * Unlike [locationCreatedGpsAltitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedGPSAltitude") - @ExcludeMissing - fun _locationCreatedGpsAltitude(): JsonField = locationCreatedGpsAltitude - - /** - * Returns the raw JSON value of [locationCreatedGpsLatitude]. - * - * Unlike [locationCreatedGpsLatitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedGPSLatitude") - @ExcludeMissing - fun _locationCreatedGpsLatitude(): JsonField = locationCreatedGpsLatitude - - /** - * Returns the raw JSON value of [locationCreatedGpsLongitude]. - * - * Unlike [locationCreatedGpsLongitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedGPSLongitude") - @ExcludeMissing - fun _locationCreatedGpsLongitude(): JsonField = locationCreatedGpsLongitude - - /** - * Returns the raw JSON value of [locationCreatedLocationId]. - * - * Unlike [locationCreatedLocationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedLocationId") - @ExcludeMissing - fun _locationCreatedLocationId(): JsonField = locationCreatedLocationId - - /** - * Returns the raw JSON value of [locationCreatedLocationName]. - * - * Unlike [locationCreatedLocationName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedLocationName") - @ExcludeMissing - fun _locationCreatedLocationName(): JsonField = locationCreatedLocationName - - /** - * Returns the raw JSON value of [locationCreatedProvinceState]. - * - * Unlike [locationCreatedProvinceState], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedProvinceState") - @ExcludeMissing - fun _locationCreatedProvinceState(): JsonField = locationCreatedProvinceState - - /** - * Returns the raw JSON value of [locationCreatedSublocation]. - * - * Unlike [locationCreatedSublocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedSublocation") - @ExcludeMissing - fun _locationCreatedSublocation(): JsonField = locationCreatedSublocation - - /** - * Returns the raw JSON value of [locationCreatedWorldRegion]. - * - * Unlike [locationCreatedWorldRegion], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationCreatedWorldRegion") - @ExcludeMissing - fun _locationCreatedWorldRegion(): JsonField = locationCreatedWorldRegion - - /** - * Returns the raw JSON value of [locationShownCity]. - * - * Unlike [locationShownCity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("LocationShownCity") - @ExcludeMissing - fun _locationShownCity(): JsonField> = locationShownCity - - /** - * Returns the raw JSON value of [locationShownCountryCode]. - * - * Unlike [locationShownCountryCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownCountryCode") - @ExcludeMissing - fun _locationShownCountryCode(): JsonField> = locationShownCountryCode - - /** - * Returns the raw JSON value of [locationShownCountryName]. - * - * Unlike [locationShownCountryName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownCountryName") - @ExcludeMissing - fun _locationShownCountryName(): JsonField> = locationShownCountryName - - /** - * Returns the raw JSON value of [locationShownGpsAltitude]. - * - * Unlike [locationShownGpsAltitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownGPSAltitude") - @ExcludeMissing - fun _locationShownGpsAltitude(): JsonField> = locationShownGpsAltitude - - /** - * Returns the raw JSON value of [locationShownGpsLatitude]. - * - * Unlike [locationShownGpsLatitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownGPSLatitude") - @ExcludeMissing - fun _locationShownGpsLatitude(): JsonField> = locationShownGpsLatitude - - /** - * Returns the raw JSON value of [locationShownGpsLongitude]. - * - * Unlike [locationShownGpsLongitude], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownGPSLongitude") - @ExcludeMissing - fun _locationShownGpsLongitude(): JsonField> = locationShownGpsLongitude - - /** - * Returns the raw JSON value of [locationShownLocationId]. - * - * Unlike [locationShownLocationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownLocationId") - @ExcludeMissing - fun _locationShownLocationId(): JsonField> = locationShownLocationId - - /** - * Returns the raw JSON value of [locationShownLocationName]. - * - * Unlike [locationShownLocationName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownLocationName") - @ExcludeMissing - fun _locationShownLocationName(): JsonField> = locationShownLocationName - - /** - * Returns the raw JSON value of [locationShownProvinceState]. - * - * Unlike [locationShownProvinceState], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownProvinceState") - @ExcludeMissing - fun _locationShownProvinceState(): JsonField> = locationShownProvinceState - - /** - * Returns the raw JSON value of [locationShownSublocation]. - * - * Unlike [locationShownSublocation], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownSublocation") - @ExcludeMissing - fun _locationShownSublocation(): JsonField> = locationShownSublocation - - /** - * Returns the raw JSON value of [locationShownWorldRegion]. - * - * Unlike [locationShownWorldRegion], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("LocationShownWorldRegion") - @ExcludeMissing - fun _locationShownWorldRegion(): JsonField> = locationShownWorldRegion - - /** - * Returns the raw JSON value of [maxAvailHeight]. - * - * Unlike [maxAvailHeight], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("MaxAvailHeight") - @ExcludeMissing - fun _maxAvailHeight(): JsonField = maxAvailHeight - - /** - * Returns the raw JSON value of [maxAvailWidth]. - * - * Unlike [maxAvailWidth], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("MaxAvailWidth") - @ExcludeMissing - fun _maxAvailWidth(): JsonField = maxAvailWidth - - /** - * Returns the raw JSON value of [modelAge]. - * - * Unlike [modelAge], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ModelAge") - @ExcludeMissing - fun _modelAge(): JsonField> = modelAge - - /** - * Returns the raw JSON value of [modelReleaseId]. - * - * Unlike [modelReleaseId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ModelReleaseID") - @ExcludeMissing - fun _modelReleaseId(): JsonField> = modelReleaseId - - /** - * Returns the raw JSON value of [objectAttributeReference]. - * - * Unlike [objectAttributeReference], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ObjectAttributeReference") - @ExcludeMissing - fun _objectAttributeReference(): JsonField = objectAttributeReference - - /** - * Returns the raw JSON value of [objectName]. - * - * Unlike [objectName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ObjectName") - @ExcludeMissing - fun _objectName(): JsonField = objectName - - /** - * Returns the raw JSON value of [offsetTimeOriginal]. - * - * Unlike [offsetTimeOriginal], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("OffsetTimeOriginal") - @ExcludeMissing - fun _offsetTimeOriginal(): JsonField = offsetTimeOriginal - - /** - * Returns the raw JSON value of [organisationInImageCode]. - * - * Unlike [organisationInImageCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("OrganisationInImageCode") - @ExcludeMissing - fun _organisationInImageCode(): JsonField> = organisationInImageCode - - /** - * Returns the raw JSON value of [organisationInImageName]. - * - * Unlike [organisationInImageName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("OrganisationInImageName") - @ExcludeMissing - fun _organisationInImageName(): JsonField> = organisationInImageName - - /** - * 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 [originalTransmissionReference]. - * - * Unlike [originalTransmissionReference], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("OriginalTransmissionReference") - @ExcludeMissing - fun _originalTransmissionReference(): JsonField = originalTransmissionReference - - /** - * Returns the raw JSON value of [personInImage]. - * - * Unlike [personInImage], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("PersonInImage") - @ExcludeMissing - fun _personInImage(): JsonField> = personInImage - - /** - * Returns the raw JSON value of [personInImageCvTermCvId]. - * - * Unlike [personInImageCvTermCvId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("PersonInImageCvTermCvId") - @ExcludeMissing - fun _personInImageCvTermCvId(): JsonField> = personInImageCvTermCvId - - /** - * Returns the raw JSON value of [personInImageCvTermId]. - * - * Unlike [personInImageCvTermId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("PersonInImageCvTermId") - @ExcludeMissing - fun _personInImageCvTermId(): JsonField> = personInImageCvTermId - - /** - * Returns the raw JSON value of [personInImageCvTermName]. - * - * Unlike [personInImageCvTermName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("PersonInImageCvTermName") - @ExcludeMissing - fun _personInImageCvTermName(): JsonField> = personInImageCvTermName - - /** - * Returns the raw JSON value of [personInImageCvTermRefinedAbout]. - * - * Unlike [personInImageCvTermRefinedAbout], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("PersonInImageCvTermRefinedAbout") - @ExcludeMissing - fun _personInImageCvTermRefinedAbout(): JsonField> = - personInImageCvTermRefinedAbout - - /** - * Returns the raw JSON value of [personInImageDescription]. - * - * Unlike [personInImageDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("PersonInImageDescription") - @ExcludeMissing - fun _personInImageDescription(): JsonField> = personInImageDescription - - /** - * Returns the raw JSON value of [personInImageId]. - * - * Unlike [personInImageId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("PersonInImageId") - @ExcludeMissing - fun _personInImageId(): JsonField> = personInImageId - - /** - * Returns the raw JSON value of [personInImageName]. - * - * Unlike [personInImageName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("PersonInImageName") - @ExcludeMissing - fun _personInImageName(): JsonField> = personInImageName - - /** - * Returns the raw JSON value of [productInImageDescription]. - * - * Unlike [productInImageDescription], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ProductInImageDescription") - @ExcludeMissing - fun _productInImageDescription(): JsonField> = productInImageDescription - - /** - * Returns the raw JSON value of [productInImageGtin]. - * - * Unlike [productInImageGtin], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ProductInImageGTIN") - @ExcludeMissing - fun _productInImageGtin(): JsonField> = productInImageGtin - - /** - * Returns the raw JSON value of [productInImageName]. - * - * Unlike [productInImageName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("ProductInImageName") - @ExcludeMissing - fun _productInImageName(): JsonField> = productInImageName - - /** - * Returns the raw JSON value of [propertyReleaseId]. - * - * Unlike [propertyReleaseId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("PropertyReleaseID") - @ExcludeMissing - fun _propertyReleaseId(): JsonField> = propertyReleaseId - - /** - * Returns the raw JSON value of [provinceState]. - * - * Unlike [provinceState], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ProvinceState") - @ExcludeMissing - fun _provinceState(): JsonField = provinceState - - /** - * Returns the raw JSON value of [rating]. - * - * Unlike [rating], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Rating") @ExcludeMissing fun _rating(): JsonField = rating - - /** - * Returns the raw JSON value of [registryEntryRole]. - * - * Unlike [registryEntryRole], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("RegistryEntryRole") - @ExcludeMissing - fun _registryEntryRole(): JsonField> = registryEntryRole - - /** - * Returns the raw JSON value of [registryItemId]. - * - * Unlike [registryItemId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("RegistryItemID") - @ExcludeMissing - fun _registryItemId(): JsonField> = registryItemId - - /** - * Returns the raw JSON value of [registryOrganisationId]. - * - * Unlike [registryOrganisationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("RegistryOrganisationID") - @ExcludeMissing - fun _registryOrganisationId(): JsonField> = registryOrganisationId - - /** - * 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 [rights]. - * - * Unlike [rights], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Rights") @ExcludeMissing fun _rights(): JsonField = rights - - /** - * Returns the raw JSON value of [scene]. - * - * Unlike [scene], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Scene") @ExcludeMissing fun _scene(): JsonField> = scene - - /** - * 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 - - /** - * Returns the raw JSON value of [specialInstructions]. - * - * Unlike [specialInstructions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("SpecialInstructions") - @ExcludeMissing - fun _specialInstructions(): JsonField = specialInstructions - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("State") @ExcludeMissing fun _state(): JsonField = state - - /** - * Returns the raw JSON value of [subject]. - * - * Unlike [subject], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Subject") @ExcludeMissing fun _subject(): JsonField> = subject - - /** - * Returns the raw JSON value of [subjectCode]. - * - * Unlike [subjectCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("SubjectCode") - @ExcludeMissing - fun _subjectCode(): JsonField> = subjectCode - - /** - * Returns the raw JSON value of [subjectReference]. - * - * Unlike [subjectReference], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("SubjectReference") - @ExcludeMissing - fun _subjectReference(): JsonField> = subjectReference - - /** - * Returns the raw JSON value of [sublocation]. - * - * Unlike [sublocation], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Sublocation") - @ExcludeMissing - fun _sublocation(): JsonField = sublocation - - /** - * Returns the raw JSON value of [timeCreated]. - * - * Unlike [timeCreated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("TimeCreated") - @ExcludeMissing - fun _timeCreated(): JsonField = timeCreated - - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Title") @ExcludeMissing fun _title(): JsonField = title - - /** - * Returns the raw JSON value of [transmissionReference]. - * - * Unlike [transmissionReference], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("TransmissionReference") - @ExcludeMissing - fun _transmissionReference(): JsonField = transmissionReference - - /** - * Returns the raw JSON value of [usageTerms]. - * - * Unlike [usageTerms], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("UsageTerms") - @ExcludeMissing - fun _usageTerms(): JsonField = usageTerms - - /** - * Returns the raw JSON value of [webStatement]. - * - * Unlike [webStatement], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("WebStatement") - @ExcludeMissing - fun _webStatement(): JsonField = webStatement - - /** - * Returns the raw JSON value of [writer]. - * - * Unlike [writer], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("Writer") @ExcludeMissing fun _writer(): JsonField = writer - - /** - * Returns the raw JSON value of [writerEditor]. - * - * Unlike [writerEditor], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("WriterEditor") - @ExcludeMissing - fun _writerEditor(): JsonField = writerEditor - - /** - * 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 [EmbeddedMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmbeddedMetadata]. */ - class Builder internal constructor() { - - private var aboutCvTermCvId: JsonField = JsonMissing.of() - private var aboutCvTermId: JsonField = JsonMissing.of() - private var aboutCvTermName: JsonField = JsonMissing.of() - private var aboutCvTermRefinedAbout: JsonField = JsonMissing.of() - private var additionalModelInformation: JsonField = JsonMissing.of() - private var applicationRecordVersion: JsonField = JsonMissing.of() - private var artist: JsonField = JsonMissing.of() - private var artworkCircaDateCreated: JsonField = JsonMissing.of() - private var artworkContentDescription: JsonField = JsonMissing.of() - private var artworkContributionDescription: JsonField = JsonMissing.of() - private var artworkCopyrightNotice: JsonField = JsonMissing.of() - private var artworkCopyrightOwnerId: JsonField = JsonMissing.of() - private var artworkCopyrightOwnerName: JsonField = JsonMissing.of() - private var artworkCreator: JsonField>? = null - private var artworkCreatorId: JsonField>? = null - private var artworkDateCreated: JsonField = JsonMissing.of() - private var artworkLicensorId: JsonField = JsonMissing.of() - private var artworkLicensorName: JsonField = JsonMissing.of() - private var artworkPhysicalDescription: JsonField = JsonMissing.of() - private var artworkSource: JsonField = JsonMissing.of() - private var artworkSourceInventoryNo: JsonField = JsonMissing.of() - private var artworkSourceInvUrl: JsonField = JsonMissing.of() - private var artworkStylePeriod: JsonField>? = null - private var artworkTitle: JsonField = JsonMissing.of() - private var authorsPosition: JsonField = JsonMissing.of() - private var byline: JsonField = JsonMissing.of() - private var bylineTitle: JsonField = JsonMissing.of() - private var caption: JsonField = JsonMissing.of() - private var captionAbstract: JsonField = JsonMissing.of() - private var captionWriter: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var colorSpace: JsonField = JsonMissing.of() - private var componentsConfiguration: JsonField = JsonMissing.of() - private var copyright: JsonField = JsonMissing.of() - private var copyrightNotice: JsonField = JsonMissing.of() - private var copyrightOwnerId: JsonField>? = null - private var copyrightOwnerName: JsonField>? = null - private var country: JsonField = JsonMissing.of() - private var countryCode: JsonField = JsonMissing.of() - private var countryPrimaryLocationCode: JsonField = JsonMissing.of() - private var countryPrimaryLocationName: JsonField = JsonMissing.of() - private var creator: JsonField = JsonMissing.of() - private var creatorAddress: JsonField = JsonMissing.of() - private var creatorCity: JsonField = JsonMissing.of() - private var creatorCountry: JsonField = JsonMissing.of() - private var creatorPostalCode: JsonField = JsonMissing.of() - private var creatorRegion: JsonField = JsonMissing.of() - private var creatorWorkEmail: JsonField = JsonMissing.of() - private var creatorWorkTelephone: JsonField = JsonMissing.of() - private var creatorWorkUrl: JsonField = JsonMissing.of() - private var credit: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateTimeCreated: JsonField = JsonMissing.of() - private var dateTimeOriginal: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var digitalImageGuid: JsonField = JsonMissing.of() - private var digitalSourceType: JsonField = JsonMissing.of() - private var embeddedEncodedRightsExpr: JsonField = JsonMissing.of() - private var embeddedEncodedRightsExprLangId: JsonField = JsonMissing.of() - private var embeddedEncodedRightsExprType: JsonField = JsonMissing.of() - private var event: JsonField = JsonMissing.of() - private var exifVersion: JsonField = JsonMissing.of() - private var flashpixVersion: JsonField = JsonMissing.of() - private var genreCvId: JsonField = JsonMissing.of() - private var genreCvTermId: JsonField = JsonMissing.of() - private var genreCvTermName: JsonField = JsonMissing.of() - private var genreCvTermRefinedAbout: JsonField = JsonMissing.of() - private var headline: JsonField = JsonMissing.of() - private var imageCreatorId: JsonField = JsonMissing.of() - private var imageCreatorImageId: JsonField = JsonMissing.of() - private var imageCreatorName: JsonField = JsonMissing.of() - private var imageDescription: JsonField = JsonMissing.of() - private var imageRegionBoundaryH: JsonField>? = null - private var imageRegionBoundaryRx: JsonField>? = null - private var imageRegionBoundaryShape: JsonField>? = null - private var imageRegionBoundaryUnit: JsonField>? = null - private var imageRegionBoundaryVerticesX: JsonField>? = null - private var imageRegionBoundaryVerticesY: JsonField>? = null - private var imageRegionBoundaryW: JsonField>? = null - private var imageRegionBoundaryX: JsonField>? = null - private var imageRegionBoundaryY: JsonField>? = null - private var imageRegionCtypeIdentifier: JsonField>? = null - private var imageRegionCtypeName: JsonField>? = null - private var imageRegionId: JsonField>? = null - private var imageRegionName: JsonField>? = null - private var imageRegionOrganisationInImageName: JsonField>? = null - private var imageRegionPersonInImage: JsonField>? = null - private var imageRegionRoleIdentifier: JsonField>? = null - private var imageRegionRoleName: JsonField>? = null - private var imageSupplierId: JsonField = JsonMissing.of() - private var imageSupplierImageId: JsonField = JsonMissing.of() - private var imageSupplierName: JsonField = JsonMissing.of() - private var instructions: JsonField = JsonMissing.of() - private var intellectualGenre: JsonField = JsonMissing.of() - private var keywords: JsonField>? = null - private var licensorCity: JsonField>? = null - private var licensorCountry: JsonField>? = null - private var licensorEmail: JsonField>? = null - private var licensorExtendedAddress: JsonField>? = null - private var licensorId: JsonField>? = null - private var licensorName: JsonField>? = null - private var licensorPostalCode: JsonField>? = null - private var licensorRegion: JsonField>? = null - private var licensorStreetAddress: JsonField>? = null - private var licensorTelephone1: JsonField>? = null - private var licensorTelephone2: JsonField>? = null - private var licensorUrl: JsonField>? = null - private var linkedEncodedRightsExpr: JsonField = JsonMissing.of() - private var linkedEncodedRightsExprLangId: JsonField = JsonMissing.of() - private var linkedEncodedRightsExprType: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var locationCreatedCity: JsonField = JsonMissing.of() - private var locationCreatedCountryCode: JsonField = JsonMissing.of() - private var locationCreatedCountryName: JsonField = JsonMissing.of() - private var locationCreatedGpsAltitude: JsonField = JsonMissing.of() - private var locationCreatedGpsLatitude: JsonField = JsonMissing.of() - private var locationCreatedGpsLongitude: JsonField = JsonMissing.of() - private var locationCreatedLocationId: JsonField = JsonMissing.of() - private var locationCreatedLocationName: JsonField = JsonMissing.of() - private var locationCreatedProvinceState: JsonField = JsonMissing.of() - private var locationCreatedSublocation: JsonField = JsonMissing.of() - private var locationCreatedWorldRegion: JsonField = JsonMissing.of() - private var locationShownCity: JsonField>? = null - private var locationShownCountryCode: JsonField>? = null - private var locationShownCountryName: JsonField>? = null - private var locationShownGpsAltitude: JsonField>? = null - private var locationShownGpsLatitude: JsonField>? = null - private var locationShownGpsLongitude: JsonField>? = null - private var locationShownLocationId: JsonField>? = null - private var locationShownLocationName: JsonField>? = null - private var locationShownProvinceState: JsonField>? = null - private var locationShownSublocation: JsonField>? = null - private var locationShownWorldRegion: JsonField>? = null - private var maxAvailHeight: JsonField = JsonMissing.of() - private var maxAvailWidth: JsonField = JsonMissing.of() - private var modelAge: JsonField>? = null - private var modelReleaseId: JsonField>? = null - private var objectAttributeReference: JsonField = JsonMissing.of() - private var objectName: JsonField = JsonMissing.of() - private var offsetTimeOriginal: JsonField = JsonMissing.of() - private var organisationInImageCode: JsonField>? = null - private var organisationInImageName: JsonField>? = null - private var orientation: JsonField = JsonMissing.of() - private var originalTransmissionReference: JsonField = JsonMissing.of() - private var personInImage: JsonField>? = null - private var personInImageCvTermCvId: JsonField>? = null - private var personInImageCvTermId: JsonField>? = null - private var personInImageCvTermName: JsonField>? = null - private var personInImageCvTermRefinedAbout: JsonField>? = null - private var personInImageDescription: JsonField>? = null - private var personInImageId: JsonField>? = null - private var personInImageName: JsonField>? = null - private var productInImageDescription: JsonField>? = null - private var productInImageGtin: JsonField>? = null - private var productInImageName: JsonField>? = null - private var propertyReleaseId: JsonField>? = null - private var provinceState: JsonField = JsonMissing.of() - private var rating: JsonField = JsonMissing.of() - private var registryEntryRole: JsonField>? = null - private var registryItemId: JsonField>? = null - private var registryOrganisationId: JsonField>? = null - private var resolutionUnit: JsonField = JsonMissing.of() - private var rights: JsonField = JsonMissing.of() - private var scene: JsonField>? = null - private var source: JsonField = JsonMissing.of() - private var specialInstructions: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var subject: JsonField>? = null - private var subjectCode: JsonField>? = null - private var subjectReference: JsonField>? = null - private var sublocation: JsonField = JsonMissing.of() - private var timeCreated: JsonField = JsonMissing.of() - private var title: JsonField = JsonMissing.of() - private var transmissionReference: JsonField = JsonMissing.of() - private var usageTerms: JsonField = JsonMissing.of() - private var webStatement: JsonField = JsonMissing.of() - private var writer: JsonField = JsonMissing.of() - private var writerEditor: JsonField = JsonMissing.of() - private var xResolution: JsonField = JsonMissing.of() - private var yResolution: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { - aboutCvTermCvId = embeddedMetadata.aboutCvTermCvId - aboutCvTermId = embeddedMetadata.aboutCvTermId - aboutCvTermName = embeddedMetadata.aboutCvTermName - aboutCvTermRefinedAbout = embeddedMetadata.aboutCvTermRefinedAbout - additionalModelInformation = embeddedMetadata.additionalModelInformation - applicationRecordVersion = embeddedMetadata.applicationRecordVersion - artist = embeddedMetadata.artist - artworkCircaDateCreated = embeddedMetadata.artworkCircaDateCreated - artworkContentDescription = embeddedMetadata.artworkContentDescription - artworkContributionDescription = embeddedMetadata.artworkContributionDescription - artworkCopyrightNotice = embeddedMetadata.artworkCopyrightNotice - artworkCopyrightOwnerId = embeddedMetadata.artworkCopyrightOwnerId - artworkCopyrightOwnerName = embeddedMetadata.artworkCopyrightOwnerName - artworkCreator = embeddedMetadata.artworkCreator.map { it.toMutableList() } - artworkCreatorId = embeddedMetadata.artworkCreatorId.map { it.toMutableList() } - artworkDateCreated = embeddedMetadata.artworkDateCreated - artworkLicensorId = embeddedMetadata.artworkLicensorId - artworkLicensorName = embeddedMetadata.artworkLicensorName - artworkPhysicalDescription = embeddedMetadata.artworkPhysicalDescription - artworkSource = embeddedMetadata.artworkSource - artworkSourceInventoryNo = embeddedMetadata.artworkSourceInventoryNo - artworkSourceInvUrl = embeddedMetadata.artworkSourceInvUrl - artworkStylePeriod = embeddedMetadata.artworkStylePeriod.map { it.toMutableList() } - artworkTitle = embeddedMetadata.artworkTitle - authorsPosition = embeddedMetadata.authorsPosition - byline = embeddedMetadata.byline - bylineTitle = embeddedMetadata.bylineTitle - caption = embeddedMetadata.caption - captionAbstract = embeddedMetadata.captionAbstract - captionWriter = embeddedMetadata.captionWriter - city = embeddedMetadata.city - colorSpace = embeddedMetadata.colorSpace - componentsConfiguration = embeddedMetadata.componentsConfiguration - copyright = embeddedMetadata.copyright - copyrightNotice = embeddedMetadata.copyrightNotice - copyrightOwnerId = embeddedMetadata.copyrightOwnerId.map { it.toMutableList() } - copyrightOwnerName = embeddedMetadata.copyrightOwnerName.map { it.toMutableList() } - country = embeddedMetadata.country - countryCode = embeddedMetadata.countryCode - countryPrimaryLocationCode = embeddedMetadata.countryPrimaryLocationCode - countryPrimaryLocationName = embeddedMetadata.countryPrimaryLocationName - creator = embeddedMetadata.creator - creatorAddress = embeddedMetadata.creatorAddress - creatorCity = embeddedMetadata.creatorCity - creatorCountry = embeddedMetadata.creatorCountry - creatorPostalCode = embeddedMetadata.creatorPostalCode - creatorRegion = embeddedMetadata.creatorRegion - creatorWorkEmail = embeddedMetadata.creatorWorkEmail - creatorWorkTelephone = embeddedMetadata.creatorWorkTelephone - creatorWorkUrl = embeddedMetadata.creatorWorkUrl - credit = embeddedMetadata.credit - dateCreated = embeddedMetadata.dateCreated - dateTimeCreated = embeddedMetadata.dateTimeCreated - dateTimeOriginal = embeddedMetadata.dateTimeOriginal - description = embeddedMetadata.description - digitalImageGuid = embeddedMetadata.digitalImageGuid - digitalSourceType = embeddedMetadata.digitalSourceType - embeddedEncodedRightsExpr = embeddedMetadata.embeddedEncodedRightsExpr - embeddedEncodedRightsExprLangId = embeddedMetadata.embeddedEncodedRightsExprLangId - embeddedEncodedRightsExprType = embeddedMetadata.embeddedEncodedRightsExprType - event = embeddedMetadata.event - exifVersion = embeddedMetadata.exifVersion - flashpixVersion = embeddedMetadata.flashpixVersion - genreCvId = embeddedMetadata.genreCvId - genreCvTermId = embeddedMetadata.genreCvTermId - genreCvTermName = embeddedMetadata.genreCvTermName - genreCvTermRefinedAbout = embeddedMetadata.genreCvTermRefinedAbout - headline = embeddedMetadata.headline - imageCreatorId = embeddedMetadata.imageCreatorId - imageCreatorImageId = embeddedMetadata.imageCreatorImageId - imageCreatorName = embeddedMetadata.imageCreatorName - imageDescription = embeddedMetadata.imageDescription - imageRegionBoundaryH = - embeddedMetadata.imageRegionBoundaryH.map { it.toMutableList() } - imageRegionBoundaryRx = - embeddedMetadata.imageRegionBoundaryRx.map { it.toMutableList() } - imageRegionBoundaryShape = - embeddedMetadata.imageRegionBoundaryShape.map { it.toMutableList() } - imageRegionBoundaryUnit = - embeddedMetadata.imageRegionBoundaryUnit.map { it.toMutableList() } - imageRegionBoundaryVerticesX = - embeddedMetadata.imageRegionBoundaryVerticesX.map { it.toMutableList() } - imageRegionBoundaryVerticesY = - embeddedMetadata.imageRegionBoundaryVerticesY.map { it.toMutableList() } - imageRegionBoundaryW = - embeddedMetadata.imageRegionBoundaryW.map { it.toMutableList() } - imageRegionBoundaryX = - embeddedMetadata.imageRegionBoundaryX.map { it.toMutableList() } - imageRegionBoundaryY = - embeddedMetadata.imageRegionBoundaryY.map { it.toMutableList() } - imageRegionCtypeIdentifier = - embeddedMetadata.imageRegionCtypeIdentifier.map { it.toMutableList() } - imageRegionCtypeName = - embeddedMetadata.imageRegionCtypeName.map { it.toMutableList() } - imageRegionId = embeddedMetadata.imageRegionId.map { it.toMutableList() } - imageRegionName = embeddedMetadata.imageRegionName.map { it.toMutableList() } - imageRegionOrganisationInImageName = - embeddedMetadata.imageRegionOrganisationInImageName.map { it.toMutableList() } - imageRegionPersonInImage = - embeddedMetadata.imageRegionPersonInImage.map { it.toMutableList() } - imageRegionRoleIdentifier = - embeddedMetadata.imageRegionRoleIdentifier.map { it.toMutableList() } - imageRegionRoleName = - embeddedMetadata.imageRegionRoleName.map { it.toMutableList() } - imageSupplierId = embeddedMetadata.imageSupplierId - imageSupplierImageId = embeddedMetadata.imageSupplierImageId - imageSupplierName = embeddedMetadata.imageSupplierName - instructions = embeddedMetadata.instructions - intellectualGenre = embeddedMetadata.intellectualGenre - keywords = embeddedMetadata.keywords.map { it.toMutableList() } - licensorCity = embeddedMetadata.licensorCity.map { it.toMutableList() } - licensorCountry = embeddedMetadata.licensorCountry.map { it.toMutableList() } - licensorEmail = embeddedMetadata.licensorEmail.map { it.toMutableList() } - licensorExtendedAddress = - embeddedMetadata.licensorExtendedAddress.map { it.toMutableList() } - licensorId = embeddedMetadata.licensorId.map { it.toMutableList() } - licensorName = embeddedMetadata.licensorName.map { it.toMutableList() } - licensorPostalCode = embeddedMetadata.licensorPostalCode.map { it.toMutableList() } - licensorRegion = embeddedMetadata.licensorRegion.map { it.toMutableList() } - licensorStreetAddress = - embeddedMetadata.licensorStreetAddress.map { it.toMutableList() } - licensorTelephone1 = embeddedMetadata.licensorTelephone1.map { it.toMutableList() } - licensorTelephone2 = embeddedMetadata.licensorTelephone2.map { it.toMutableList() } - licensorUrl = embeddedMetadata.licensorUrl.map { it.toMutableList() } - linkedEncodedRightsExpr = embeddedMetadata.linkedEncodedRightsExpr - linkedEncodedRightsExprLangId = embeddedMetadata.linkedEncodedRightsExprLangId - linkedEncodedRightsExprType = embeddedMetadata.linkedEncodedRightsExprType - location = embeddedMetadata.location - locationCreatedCity = embeddedMetadata.locationCreatedCity - locationCreatedCountryCode = embeddedMetadata.locationCreatedCountryCode - locationCreatedCountryName = embeddedMetadata.locationCreatedCountryName - locationCreatedGpsAltitude = embeddedMetadata.locationCreatedGpsAltitude - locationCreatedGpsLatitude = embeddedMetadata.locationCreatedGpsLatitude - locationCreatedGpsLongitude = embeddedMetadata.locationCreatedGpsLongitude - locationCreatedLocationId = embeddedMetadata.locationCreatedLocationId - locationCreatedLocationName = embeddedMetadata.locationCreatedLocationName - locationCreatedProvinceState = embeddedMetadata.locationCreatedProvinceState - locationCreatedSublocation = embeddedMetadata.locationCreatedSublocation - locationCreatedWorldRegion = embeddedMetadata.locationCreatedWorldRegion - locationShownCity = embeddedMetadata.locationShownCity.map { it.toMutableList() } - locationShownCountryCode = - embeddedMetadata.locationShownCountryCode.map { it.toMutableList() } - locationShownCountryName = - embeddedMetadata.locationShownCountryName.map { it.toMutableList() } - locationShownGpsAltitude = - embeddedMetadata.locationShownGpsAltitude.map { it.toMutableList() } - locationShownGpsLatitude = - embeddedMetadata.locationShownGpsLatitude.map { it.toMutableList() } - locationShownGpsLongitude = - embeddedMetadata.locationShownGpsLongitude.map { it.toMutableList() } - locationShownLocationId = - embeddedMetadata.locationShownLocationId.map { it.toMutableList() } - locationShownLocationName = - embeddedMetadata.locationShownLocationName.map { it.toMutableList() } - locationShownProvinceState = - embeddedMetadata.locationShownProvinceState.map { it.toMutableList() } - locationShownSublocation = - embeddedMetadata.locationShownSublocation.map { it.toMutableList() } - locationShownWorldRegion = - embeddedMetadata.locationShownWorldRegion.map { it.toMutableList() } - maxAvailHeight = embeddedMetadata.maxAvailHeight - maxAvailWidth = embeddedMetadata.maxAvailWidth - modelAge = embeddedMetadata.modelAge.map { it.toMutableList() } - modelReleaseId = embeddedMetadata.modelReleaseId.map { it.toMutableList() } - objectAttributeReference = embeddedMetadata.objectAttributeReference - objectName = embeddedMetadata.objectName - offsetTimeOriginal = embeddedMetadata.offsetTimeOriginal - organisationInImageCode = - embeddedMetadata.organisationInImageCode.map { it.toMutableList() } - organisationInImageName = - embeddedMetadata.organisationInImageName.map { it.toMutableList() } - orientation = embeddedMetadata.orientation - originalTransmissionReference = embeddedMetadata.originalTransmissionReference - personInImage = embeddedMetadata.personInImage.map { it.toMutableList() } - personInImageCvTermCvId = - embeddedMetadata.personInImageCvTermCvId.map { it.toMutableList() } - personInImageCvTermId = - embeddedMetadata.personInImageCvTermId.map { it.toMutableList() } - personInImageCvTermName = - embeddedMetadata.personInImageCvTermName.map { it.toMutableList() } - personInImageCvTermRefinedAbout = - embeddedMetadata.personInImageCvTermRefinedAbout.map { it.toMutableList() } - personInImageDescription = - embeddedMetadata.personInImageDescription.map { it.toMutableList() } - personInImageId = embeddedMetadata.personInImageId.map { it.toMutableList() } - personInImageName = embeddedMetadata.personInImageName.map { it.toMutableList() } - productInImageDescription = - embeddedMetadata.productInImageDescription.map { it.toMutableList() } - productInImageGtin = embeddedMetadata.productInImageGtin.map { it.toMutableList() } - productInImageName = embeddedMetadata.productInImageName.map { it.toMutableList() } - propertyReleaseId = embeddedMetadata.propertyReleaseId.map { it.toMutableList() } - provinceState = embeddedMetadata.provinceState - rating = embeddedMetadata.rating - registryEntryRole = embeddedMetadata.registryEntryRole.map { it.toMutableList() } - registryItemId = embeddedMetadata.registryItemId.map { it.toMutableList() } - registryOrganisationId = - embeddedMetadata.registryOrganisationId.map { it.toMutableList() } - resolutionUnit = embeddedMetadata.resolutionUnit - rights = embeddedMetadata.rights - scene = embeddedMetadata.scene.map { it.toMutableList() } - source = embeddedMetadata.source - specialInstructions = embeddedMetadata.specialInstructions - state = embeddedMetadata.state - subject = embeddedMetadata.subject.map { it.toMutableList() } - subjectCode = embeddedMetadata.subjectCode.map { it.toMutableList() } - subjectReference = embeddedMetadata.subjectReference.map { it.toMutableList() } - sublocation = embeddedMetadata.sublocation - timeCreated = embeddedMetadata.timeCreated - title = embeddedMetadata.title - transmissionReference = embeddedMetadata.transmissionReference - usageTerms = embeddedMetadata.usageTerms - webStatement = embeddedMetadata.webStatement - writer = embeddedMetadata.writer - writerEditor = embeddedMetadata.writerEditor - xResolution = embeddedMetadata.xResolution - yResolution = embeddedMetadata.yResolution - additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() - } - - fun aboutCvTermCvId(aboutCvTermCvId: String) = - aboutCvTermCvId(JsonField.of(aboutCvTermCvId)) - - /** - * Sets [Builder.aboutCvTermCvId] to an arbitrary JSON value. - * - * You should usually call [Builder.aboutCvTermCvId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun aboutCvTermCvId(aboutCvTermCvId: JsonField) = apply { - this.aboutCvTermCvId = aboutCvTermCvId - } - - fun aboutCvTermId(aboutCvTermId: String) = aboutCvTermId(JsonField.of(aboutCvTermId)) - - /** - * Sets [Builder.aboutCvTermId] to an arbitrary JSON value. - * - * You should usually call [Builder.aboutCvTermId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun aboutCvTermId(aboutCvTermId: JsonField) = apply { - this.aboutCvTermId = aboutCvTermId - } - - fun aboutCvTermName(aboutCvTermName: String) = - aboutCvTermName(JsonField.of(aboutCvTermName)) - - /** - * Sets [Builder.aboutCvTermName] to an arbitrary JSON value. - * - * You should usually call [Builder.aboutCvTermName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun aboutCvTermName(aboutCvTermName: JsonField) = apply { - this.aboutCvTermName = aboutCvTermName - } - - fun aboutCvTermRefinedAbout(aboutCvTermRefinedAbout: String) = - aboutCvTermRefinedAbout(JsonField.of(aboutCvTermRefinedAbout)) - - /** - * Sets [Builder.aboutCvTermRefinedAbout] to an arbitrary JSON value. - * - * You should usually call [Builder.aboutCvTermRefinedAbout] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun aboutCvTermRefinedAbout(aboutCvTermRefinedAbout: JsonField) = apply { - this.aboutCvTermRefinedAbout = aboutCvTermRefinedAbout - } - - fun additionalModelInformation(additionalModelInformation: String) = - additionalModelInformation(JsonField.of(additionalModelInformation)) - - /** - * Sets [Builder.additionalModelInformation] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalModelInformation] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun additionalModelInformation(additionalModelInformation: JsonField) = apply { - this.additionalModelInformation = additionalModelInformation - } - - fun applicationRecordVersion(applicationRecordVersion: Long) = - applicationRecordVersion(JsonField.of(applicationRecordVersion)) - - /** - * Sets [Builder.applicationRecordVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.applicationRecordVersion] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun applicationRecordVersion(applicationRecordVersion: JsonField) = apply { - this.applicationRecordVersion = applicationRecordVersion - } - - fun artist(artist: String) = artist(JsonField.of(artist)) - - /** - * Sets [Builder.artist] to an arbitrary JSON value. - * - * You should usually call [Builder.artist] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun artist(artist: JsonField) = apply { this.artist = artist } - - fun artworkCircaDateCreated(artworkCircaDateCreated: String) = - artworkCircaDateCreated(JsonField.of(artworkCircaDateCreated)) - - /** - * Sets [Builder.artworkCircaDateCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCircaDateCreated] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCircaDateCreated(artworkCircaDateCreated: JsonField) = apply { - this.artworkCircaDateCreated = artworkCircaDateCreated - } - - fun artworkContentDescription(artworkContentDescription: String) = - artworkContentDescription(JsonField.of(artworkContentDescription)) - - /** - * Sets [Builder.artworkContentDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkContentDescription] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkContentDescription(artworkContentDescription: JsonField) = apply { - this.artworkContentDescription = artworkContentDescription - } - - fun artworkContributionDescription(artworkContributionDescription: String) = - artworkContributionDescription(JsonField.of(artworkContributionDescription)) - - /** - * Sets [Builder.artworkContributionDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkContributionDescription] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkContributionDescription(artworkContributionDescription: JsonField) = - apply { - this.artworkContributionDescription = artworkContributionDescription - } - - fun artworkCopyrightNotice(artworkCopyrightNotice: String) = - artworkCopyrightNotice(JsonField.of(artworkCopyrightNotice)) - - /** - * Sets [Builder.artworkCopyrightNotice] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCopyrightNotice] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCopyrightNotice(artworkCopyrightNotice: JsonField) = apply { - this.artworkCopyrightNotice = artworkCopyrightNotice - } - - fun artworkCopyrightOwnerId(artworkCopyrightOwnerId: String) = - artworkCopyrightOwnerId(JsonField.of(artworkCopyrightOwnerId)) - - /** - * Sets [Builder.artworkCopyrightOwnerId] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCopyrightOwnerId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCopyrightOwnerId(artworkCopyrightOwnerId: JsonField) = apply { - this.artworkCopyrightOwnerId = artworkCopyrightOwnerId - } - - fun artworkCopyrightOwnerName(artworkCopyrightOwnerName: String) = - artworkCopyrightOwnerName(JsonField.of(artworkCopyrightOwnerName)) - - /** - * Sets [Builder.artworkCopyrightOwnerName] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCopyrightOwnerName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkCopyrightOwnerName(artworkCopyrightOwnerName: JsonField) = apply { - this.artworkCopyrightOwnerName = artworkCopyrightOwnerName - } - - fun artworkCreator(artworkCreator: List) = - artworkCreator(JsonField.of(artworkCreator)) - - /** - * Sets [Builder.artworkCreator] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCreator] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCreator(artworkCreator: JsonField>) = apply { - this.artworkCreator = artworkCreator.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.artworkCreator]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addArtworkCreator(artworkCreator: String) = apply { - this.artworkCreator = - (this.artworkCreator ?: JsonField.of(mutableListOf())).also { - checkKnown("artworkCreator", it).add(artworkCreator) - } - } - - fun artworkCreatorId(artworkCreatorId: List) = - artworkCreatorId(JsonField.of(artworkCreatorId)) - - /** - * Sets [Builder.artworkCreatorId] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkCreatorId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkCreatorId(artworkCreatorId: JsonField>) = apply { - this.artworkCreatorId = artworkCreatorId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.artworkCreatorId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addArtworkCreatorId(artworkCreatorId: String) = apply { - this.artworkCreatorId = - (this.artworkCreatorId ?: JsonField.of(mutableListOf())).also { - checkKnown("artworkCreatorId", it).add(artworkCreatorId) - } - } - - fun artworkDateCreated(artworkDateCreated: OffsetDateTime) = - artworkDateCreated(JsonField.of(artworkDateCreated)) - - /** - * Sets [Builder.artworkDateCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkDateCreated] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkDateCreated(artworkDateCreated: JsonField) = apply { - this.artworkDateCreated = artworkDateCreated - } - - fun artworkLicensorId(artworkLicensorId: String) = - artworkLicensorId(JsonField.of(artworkLicensorId)) - - /** - * Sets [Builder.artworkLicensorId] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkLicensorId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun artworkLicensorId(artworkLicensorId: JsonField) = apply { - this.artworkLicensorId = artworkLicensorId - } - - fun artworkLicensorName(artworkLicensorName: String) = - artworkLicensorName(JsonField.of(artworkLicensorName)) - - /** - * Sets [Builder.artworkLicensorName] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkLicensorName] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkLicensorName(artworkLicensorName: JsonField) = apply { - this.artworkLicensorName = artworkLicensorName - } - - fun artworkPhysicalDescription(artworkPhysicalDescription: String) = - artworkPhysicalDescription(JsonField.of(artworkPhysicalDescription)) - - /** - * Sets [Builder.artworkPhysicalDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkPhysicalDescription] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun artworkPhysicalDescription(artworkPhysicalDescription: JsonField) = apply { - this.artworkPhysicalDescription = artworkPhysicalDescription - } - - fun artworkSource(artworkSource: String) = artworkSource(JsonField.of(artworkSource)) - - /** - * Sets [Builder.artworkSource] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkSource] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun artworkSource(artworkSource: JsonField) = apply { - this.artworkSource = artworkSource - } - - fun artworkSourceInventoryNo(artworkSourceInventoryNo: String) = - artworkSourceInventoryNo(JsonField.of(artworkSourceInventoryNo)) - - /** - * Sets [Builder.artworkSourceInventoryNo] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkSourceInventoryNo] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkSourceInventoryNo(artworkSourceInventoryNo: JsonField) = apply { - this.artworkSourceInventoryNo = artworkSourceInventoryNo - } - - fun artworkSourceInvUrl(artworkSourceInvUrl: String) = - artworkSourceInvUrl(JsonField.of(artworkSourceInvUrl)) - - /** - * Sets [Builder.artworkSourceInvUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkSourceInvUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkSourceInvUrl(artworkSourceInvUrl: JsonField) = apply { - this.artworkSourceInvUrl = artworkSourceInvUrl - } - - fun artworkStylePeriod(artworkStylePeriod: List) = - artworkStylePeriod(JsonField.of(artworkStylePeriod)) - - /** - * Sets [Builder.artworkStylePeriod] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkStylePeriod] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun artworkStylePeriod(artworkStylePeriod: JsonField>) = apply { - this.artworkStylePeriod = artworkStylePeriod.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.artworkStylePeriod]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addArtworkStylePeriod(artworkStylePeriod: String) = apply { - this.artworkStylePeriod = - (this.artworkStylePeriod ?: JsonField.of(mutableListOf())).also { - checkKnown("artworkStylePeriod", it).add(artworkStylePeriod) - } - } - - fun artworkTitle(artworkTitle: String) = artworkTitle(JsonField.of(artworkTitle)) - - /** - * Sets [Builder.artworkTitle] to an arbitrary JSON value. - * - * You should usually call [Builder.artworkTitle] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun artworkTitle(artworkTitle: JsonField) = apply { - this.artworkTitle = artworkTitle - } - - fun authorsPosition(authorsPosition: String) = - authorsPosition(JsonField.of(authorsPosition)) - - /** - * Sets [Builder.authorsPosition] to an arbitrary JSON value. - * - * You should usually call [Builder.authorsPosition] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun authorsPosition(authorsPosition: JsonField) = apply { - this.authorsPosition = authorsPosition - } - - fun byline(byline: String) = byline(JsonField.of(byline)) - - /** - * Sets [Builder.byline] to an arbitrary JSON value. - * - * You should usually call [Builder.byline] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun byline(byline: JsonField) = apply { this.byline = byline } - - fun bylineTitle(bylineTitle: String) = bylineTitle(JsonField.of(bylineTitle)) - - /** - * Sets [Builder.bylineTitle] to an arbitrary JSON value. - * - * You should usually call [Builder.bylineTitle] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun bylineTitle(bylineTitle: JsonField) = apply { - this.bylineTitle = bylineTitle - } - - fun caption(caption: String) = caption(JsonField.of(caption)) - - /** - * Sets [Builder.caption] to an arbitrary JSON value. - * - * You should usually call [Builder.caption] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun caption(caption: JsonField) = apply { this.caption = caption } - - fun captionAbstract(captionAbstract: String) = - captionAbstract(JsonField.of(captionAbstract)) - - /** - * Sets [Builder.captionAbstract] to an arbitrary JSON value. - * - * You should usually call [Builder.captionAbstract] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun captionAbstract(captionAbstract: JsonField) = apply { - this.captionAbstract = captionAbstract - } - - fun captionWriter(captionWriter: String) = captionWriter(JsonField.of(captionWriter)) - - /** - * Sets [Builder.captionWriter] to an arbitrary JSON value. - * - * You should usually call [Builder.captionWriter] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun captionWriter(captionWriter: JsonField) = apply { - this.captionWriter = captionWriter - } - - fun city(city: String) = city(JsonField.of(city)) - - /** - * Sets [Builder.city] to an arbitrary JSON value. - * - * You should usually call [Builder.city] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun city(city: JsonField) = apply { this.city = city } - - fun colorSpace(colorSpace: String) = colorSpace(JsonField.of(colorSpace)) - - /** - * Sets [Builder.colorSpace] to an arbitrary JSON value. - * - * You should usually call [Builder.colorSpace] with a well-typed [String] 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 componentsConfiguration(componentsConfiguration: String) = - componentsConfiguration(JsonField.of(componentsConfiguration)) - - /** - * Sets [Builder.componentsConfiguration] to an arbitrary JSON value. - * - * You should usually call [Builder.componentsConfiguration] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun componentsConfiguration(componentsConfiguration: JsonField) = apply { - this.componentsConfiguration = componentsConfiguration - } - - fun copyright(copyright: String) = copyright(JsonField.of(copyright)) - - /** - * Sets [Builder.copyright] to an arbitrary JSON value. - * - * You should usually call [Builder.copyright] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun copyright(copyright: JsonField) = apply { this.copyright = copyright } - - fun copyrightNotice(copyrightNotice: String) = - copyrightNotice(JsonField.of(copyrightNotice)) - - /** - * Sets [Builder.copyrightNotice] to an arbitrary JSON value. - * - * You should usually call [Builder.copyrightNotice] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun copyrightNotice(copyrightNotice: JsonField) = apply { - this.copyrightNotice = copyrightNotice - } - - fun copyrightOwnerId(copyrightOwnerId: List) = - copyrightOwnerId(JsonField.of(copyrightOwnerId)) - - /** - * Sets [Builder.copyrightOwnerId] to an arbitrary JSON value. - * - * You should usually call [Builder.copyrightOwnerId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun copyrightOwnerId(copyrightOwnerId: JsonField>) = apply { - this.copyrightOwnerId = copyrightOwnerId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.copyrightOwnerId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCopyrightOwnerId(copyrightOwnerId: String) = apply { - this.copyrightOwnerId = - (this.copyrightOwnerId ?: JsonField.of(mutableListOf())).also { - checkKnown("copyrightOwnerId", it).add(copyrightOwnerId) - } - } - - fun copyrightOwnerName(copyrightOwnerName: List) = - copyrightOwnerName(JsonField.of(copyrightOwnerName)) - - /** - * Sets [Builder.copyrightOwnerName] to an arbitrary JSON value. - * - * You should usually call [Builder.copyrightOwnerName] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun copyrightOwnerName(copyrightOwnerName: JsonField>) = apply { - this.copyrightOwnerName = copyrightOwnerName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.copyrightOwnerName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCopyrightOwnerName(copyrightOwnerName: String) = apply { - this.copyrightOwnerName = - (this.copyrightOwnerName ?: JsonField.of(mutableListOf())).also { - checkKnown("copyrightOwnerName", it).add(copyrightOwnerName) - } - } - - fun country(country: String) = country(JsonField.of(country)) - - /** - * Sets [Builder.country] to an arbitrary JSON value. - * - * You should usually call [Builder.country] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun country(country: JsonField) = apply { this.country = country } - - fun countryCode(countryCode: String) = countryCode(JsonField.of(countryCode)) - - /** - * Sets [Builder.countryCode] to an arbitrary JSON value. - * - * You should usually call [Builder.countryCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun countryCode(countryCode: JsonField) = apply { - this.countryCode = countryCode - } - - fun countryPrimaryLocationCode(countryPrimaryLocationCode: String) = - countryPrimaryLocationCode(JsonField.of(countryPrimaryLocationCode)) - - /** - * Sets [Builder.countryPrimaryLocationCode] to an arbitrary JSON value. - * - * You should usually call [Builder.countryPrimaryLocationCode] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun countryPrimaryLocationCode(countryPrimaryLocationCode: JsonField) = apply { - this.countryPrimaryLocationCode = countryPrimaryLocationCode - } - - fun countryPrimaryLocationName(countryPrimaryLocationName: String) = - countryPrimaryLocationName(JsonField.of(countryPrimaryLocationName)) - - /** - * Sets [Builder.countryPrimaryLocationName] to an arbitrary JSON value. - * - * You should usually call [Builder.countryPrimaryLocationName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun countryPrimaryLocationName(countryPrimaryLocationName: JsonField) = apply { - this.countryPrimaryLocationName = countryPrimaryLocationName - } - - fun creator(creator: String) = creator(JsonField.of(creator)) - - /** - * Sets [Builder.creator] to an arbitrary JSON value. - * - * You should usually call [Builder.creator] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creator(creator: JsonField) = apply { this.creator = creator } - - fun creatorAddress(creatorAddress: String) = - creatorAddress(JsonField.of(creatorAddress)) - - /** - * Sets [Builder.creatorAddress] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorAddress] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorAddress(creatorAddress: JsonField) = apply { - this.creatorAddress = creatorAddress - } - - fun creatorCity(creatorCity: String) = creatorCity(JsonField.of(creatorCity)) - - /** - * Sets [Builder.creatorCity] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorCity] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorCity(creatorCity: JsonField) = apply { - this.creatorCity = creatorCity - } - - fun creatorCountry(creatorCountry: String) = - creatorCountry(JsonField.of(creatorCountry)) - - /** - * Sets [Builder.creatorCountry] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorCountry] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorCountry(creatorCountry: JsonField) = apply { - this.creatorCountry = creatorCountry - } - - fun creatorPostalCode(creatorPostalCode: String) = - creatorPostalCode(JsonField.of(creatorPostalCode)) - - /** - * Sets [Builder.creatorPostalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorPostalCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorPostalCode(creatorPostalCode: JsonField) = apply { - this.creatorPostalCode = creatorPostalCode - } - - fun creatorRegion(creatorRegion: String) = creatorRegion(JsonField.of(creatorRegion)) - - /** - * Sets [Builder.creatorRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorRegion] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorRegion(creatorRegion: JsonField) = apply { - this.creatorRegion = creatorRegion - } - - fun creatorWorkEmail(creatorWorkEmail: String) = - creatorWorkEmail(JsonField.of(creatorWorkEmail)) - - /** - * Sets [Builder.creatorWorkEmail] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorWorkEmail] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorWorkEmail(creatorWorkEmail: JsonField) = apply { - this.creatorWorkEmail = creatorWorkEmail - } - - fun creatorWorkTelephone(creatorWorkTelephone: String) = - creatorWorkTelephone(JsonField.of(creatorWorkTelephone)) - - /** - * Sets [Builder.creatorWorkTelephone] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorWorkTelephone] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun creatorWorkTelephone(creatorWorkTelephone: JsonField) = apply { - this.creatorWorkTelephone = creatorWorkTelephone - } - - fun creatorWorkUrl(creatorWorkUrl: String) = - creatorWorkUrl(JsonField.of(creatorWorkUrl)) - - /** - * Sets [Builder.creatorWorkUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.creatorWorkUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun creatorWorkUrl(creatorWorkUrl: JsonField) = apply { - this.creatorWorkUrl = creatorWorkUrl - } - - fun credit(credit: String) = credit(JsonField.of(credit)) - - /** - * Sets [Builder.credit] to an arbitrary JSON value. - * - * You should usually call [Builder.credit] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun credit(credit: JsonField) = apply { this.credit = credit } - - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** - * Sets [Builder.dateCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - fun dateTimeCreated(dateTimeCreated: OffsetDateTime) = - dateTimeCreated(JsonField.of(dateTimeCreated)) - - /** - * Sets [Builder.dateTimeCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.dateTimeCreated] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun dateTimeCreated(dateTimeCreated: JsonField) = apply { - this.dateTimeCreated = dateTimeCreated - } - - fun dateTimeOriginal(dateTimeOriginal: OffsetDateTime) = - dateTimeOriginal(JsonField.of(dateTimeOriginal)) - - /** - * Sets [Builder.dateTimeOriginal] to an arbitrary JSON value. - * - * You should usually call [Builder.dateTimeOriginal] with a well-typed [OffsetDateTime] - * 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 description(description: String) = description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - fun digitalImageGuid(digitalImageGuid: String) = - digitalImageGuid(JsonField.of(digitalImageGuid)) - - /** - * Sets [Builder.digitalImageGuid] to an arbitrary JSON value. - * - * You should usually call [Builder.digitalImageGuid] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun digitalImageGuid(digitalImageGuid: JsonField) = apply { - this.digitalImageGuid = digitalImageGuid - } - - fun digitalSourceType(digitalSourceType: String) = - digitalSourceType(JsonField.of(digitalSourceType)) - - /** - * Sets [Builder.digitalSourceType] to an arbitrary JSON value. - * - * You should usually call [Builder.digitalSourceType] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun digitalSourceType(digitalSourceType: JsonField) = apply { - this.digitalSourceType = digitalSourceType - } - - fun embeddedEncodedRightsExpr(embeddedEncodedRightsExpr: String) = - embeddedEncodedRightsExpr(JsonField.of(embeddedEncodedRightsExpr)) - - /** - * Sets [Builder.embeddedEncodedRightsExpr] to an arbitrary JSON value. - * - * You should usually call [Builder.embeddedEncodedRightsExpr] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun embeddedEncodedRightsExpr(embeddedEncodedRightsExpr: JsonField) = apply { - this.embeddedEncodedRightsExpr = embeddedEncodedRightsExpr - } - - fun embeddedEncodedRightsExprLangId(embeddedEncodedRightsExprLangId: String) = - embeddedEncodedRightsExprLangId(JsonField.of(embeddedEncodedRightsExprLangId)) - - /** - * Sets [Builder.embeddedEncodedRightsExprLangId] to an arbitrary JSON value. - * - * You should usually call [Builder.embeddedEncodedRightsExprLangId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun embeddedEncodedRightsExprLangId( - embeddedEncodedRightsExprLangId: JsonField - ) = apply { this.embeddedEncodedRightsExprLangId = embeddedEncodedRightsExprLangId } - - fun embeddedEncodedRightsExprType(embeddedEncodedRightsExprType: String) = - embeddedEncodedRightsExprType(JsonField.of(embeddedEncodedRightsExprType)) - - /** - * Sets [Builder.embeddedEncodedRightsExprType] to an arbitrary JSON value. - * - * You should usually call [Builder.embeddedEncodedRightsExprType] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun embeddedEncodedRightsExprType(embeddedEncodedRightsExprType: JsonField) = - apply { - this.embeddedEncodedRightsExprType = embeddedEncodedRightsExprType - } - - fun event(event: String) = event(JsonField.of(event)) - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun event(event: JsonField) = apply { this.event = event } - - 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 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 genreCvId(genreCvId: String) = genreCvId(JsonField.of(genreCvId)) - - /** - * Sets [Builder.genreCvId] to an arbitrary JSON value. - * - * You should usually call [Builder.genreCvId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun genreCvId(genreCvId: JsonField) = apply { this.genreCvId = genreCvId } - - fun genreCvTermId(genreCvTermId: String) = genreCvTermId(JsonField.of(genreCvTermId)) - - /** - * Sets [Builder.genreCvTermId] to an arbitrary JSON value. - * - * You should usually call [Builder.genreCvTermId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun genreCvTermId(genreCvTermId: JsonField) = apply { - this.genreCvTermId = genreCvTermId - } - - fun genreCvTermName(genreCvTermName: String) = - genreCvTermName(JsonField.of(genreCvTermName)) - - /** - * Sets [Builder.genreCvTermName] to an arbitrary JSON value. - * - * You should usually call [Builder.genreCvTermName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun genreCvTermName(genreCvTermName: JsonField) = apply { - this.genreCvTermName = genreCvTermName - } - - fun genreCvTermRefinedAbout(genreCvTermRefinedAbout: String) = - genreCvTermRefinedAbout(JsonField.of(genreCvTermRefinedAbout)) - - /** - * Sets [Builder.genreCvTermRefinedAbout] to an arbitrary JSON value. - * - * You should usually call [Builder.genreCvTermRefinedAbout] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun genreCvTermRefinedAbout(genreCvTermRefinedAbout: JsonField) = apply { - this.genreCvTermRefinedAbout = genreCvTermRefinedAbout - } - - fun headline(headline: String) = headline(JsonField.of(headline)) - - /** - * Sets [Builder.headline] to an arbitrary JSON value. - * - * You should usually call [Builder.headline] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun headline(headline: JsonField) = apply { this.headline = headline } - - fun imageCreatorId(imageCreatorId: String) = - imageCreatorId(JsonField.of(imageCreatorId)) - - /** - * Sets [Builder.imageCreatorId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageCreatorId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageCreatorId(imageCreatorId: JsonField) = apply { - this.imageCreatorId = imageCreatorId - } - - fun imageCreatorImageId(imageCreatorImageId: String) = - imageCreatorImageId(JsonField.of(imageCreatorImageId)) - - /** - * Sets [Builder.imageCreatorImageId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageCreatorImageId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageCreatorImageId(imageCreatorImageId: JsonField) = apply { - this.imageCreatorImageId = imageCreatorImageId - } - - fun imageCreatorName(imageCreatorName: String) = - imageCreatorName(JsonField.of(imageCreatorName)) - - /** - * Sets [Builder.imageCreatorName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageCreatorName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageCreatorName(imageCreatorName: JsonField) = apply { - this.imageCreatorName = imageCreatorName - } - - fun imageDescription(imageDescription: String) = - imageDescription(JsonField.of(imageDescription)) - - /** - * Sets [Builder.imageDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.imageDescription] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageDescription(imageDescription: JsonField) = apply { - this.imageDescription = imageDescription - } - - fun imageRegionBoundaryH(imageRegionBoundaryH: List) = - imageRegionBoundaryH(JsonField.of(imageRegionBoundaryH)) - - /** - * Sets [Builder.imageRegionBoundaryH] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryH] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryH(imageRegionBoundaryH: JsonField>) = apply { - this.imageRegionBoundaryH = imageRegionBoundaryH.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryH]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryH(imageRegionBoundaryH: Double) = apply { - this.imageRegionBoundaryH = - (this.imageRegionBoundaryH ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryH", it).add(imageRegionBoundaryH) - } - } - - fun imageRegionBoundaryRx(imageRegionBoundaryRx: List) = - imageRegionBoundaryRx(JsonField.of(imageRegionBoundaryRx)) - - /** - * Sets [Builder.imageRegionBoundaryRx] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryRx] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryRx(imageRegionBoundaryRx: JsonField>) = apply { - this.imageRegionBoundaryRx = imageRegionBoundaryRx.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryRx]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryRx(imageRegionBoundaryRx: Double) = apply { - this.imageRegionBoundaryRx = - (this.imageRegionBoundaryRx ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryRx", it).add(imageRegionBoundaryRx) - } - } - - fun imageRegionBoundaryShape(imageRegionBoundaryShape: List) = - imageRegionBoundaryShape(JsonField.of(imageRegionBoundaryShape)) - - /** - * Sets [Builder.imageRegionBoundaryShape] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryShape] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryShape(imageRegionBoundaryShape: JsonField>) = - apply { - this.imageRegionBoundaryShape = - imageRegionBoundaryShape.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionBoundaryShape]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryShape(imageRegionBoundaryShape: String) = apply { - this.imageRegionBoundaryShape = - (this.imageRegionBoundaryShape ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryShape", it).add(imageRegionBoundaryShape) - } - } - - fun imageRegionBoundaryUnit(imageRegionBoundaryUnit: List) = - imageRegionBoundaryUnit(JsonField.of(imageRegionBoundaryUnit)) - - /** - * Sets [Builder.imageRegionBoundaryUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryUnit] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryUnit(imageRegionBoundaryUnit: JsonField>) = apply { - this.imageRegionBoundaryUnit = imageRegionBoundaryUnit.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionBoundaryUnit]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryUnit(imageRegionBoundaryUnit: String) = apply { - this.imageRegionBoundaryUnit = - (this.imageRegionBoundaryUnit ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryUnit", it).add(imageRegionBoundaryUnit) - } - } - - fun imageRegionBoundaryVerticesX(imageRegionBoundaryVerticesX: List) = - imageRegionBoundaryVerticesX(JsonField.of(imageRegionBoundaryVerticesX)) - - /** - * Sets [Builder.imageRegionBoundaryVerticesX] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryVerticesX] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryVerticesX( - imageRegionBoundaryVerticesX: JsonField> - ) = apply { - this.imageRegionBoundaryVerticesX = - imageRegionBoundaryVerticesX.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryVerticesX]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryVerticesX(imageRegionBoundaryVerticesX: Double) = apply { - this.imageRegionBoundaryVerticesX = - (this.imageRegionBoundaryVerticesX ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryVerticesX", it) - .add(imageRegionBoundaryVerticesX) - } - } - - fun imageRegionBoundaryVerticesY(imageRegionBoundaryVerticesY: List) = - imageRegionBoundaryVerticesY(JsonField.of(imageRegionBoundaryVerticesY)) - - /** - * Sets [Builder.imageRegionBoundaryVerticesY] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryVerticesY] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryVerticesY( - imageRegionBoundaryVerticesY: JsonField> - ) = apply { - this.imageRegionBoundaryVerticesY = - imageRegionBoundaryVerticesY.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryVerticesY]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryVerticesY(imageRegionBoundaryVerticesY: Double) = apply { - this.imageRegionBoundaryVerticesY = - (this.imageRegionBoundaryVerticesY ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryVerticesY", it) - .add(imageRegionBoundaryVerticesY) - } - } - - fun imageRegionBoundaryW(imageRegionBoundaryW: List) = - imageRegionBoundaryW(JsonField.of(imageRegionBoundaryW)) - - /** - * Sets [Builder.imageRegionBoundaryW] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryW] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryW(imageRegionBoundaryW: JsonField>) = apply { - this.imageRegionBoundaryW = imageRegionBoundaryW.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryW]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryW(imageRegionBoundaryW: Double) = apply { - this.imageRegionBoundaryW = - (this.imageRegionBoundaryW ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryW", it).add(imageRegionBoundaryW) - } - } - - fun imageRegionBoundaryX(imageRegionBoundaryX: List) = - imageRegionBoundaryX(JsonField.of(imageRegionBoundaryX)) - - /** - * Sets [Builder.imageRegionBoundaryX] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryX] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryX(imageRegionBoundaryX: JsonField>) = apply { - this.imageRegionBoundaryX = imageRegionBoundaryX.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryX]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryX(imageRegionBoundaryX: Double) = apply { - this.imageRegionBoundaryX = - (this.imageRegionBoundaryX ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryX", it).add(imageRegionBoundaryX) - } - } - - fun imageRegionBoundaryY(imageRegionBoundaryY: List) = - imageRegionBoundaryY(JsonField.of(imageRegionBoundaryY)) - - /** - * Sets [Builder.imageRegionBoundaryY] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionBoundaryY] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionBoundaryY(imageRegionBoundaryY: JsonField>) = apply { - this.imageRegionBoundaryY = imageRegionBoundaryY.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.imageRegionBoundaryY]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionBoundaryY(imageRegionBoundaryY: Double) = apply { - this.imageRegionBoundaryY = - (this.imageRegionBoundaryY ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionBoundaryY", it).add(imageRegionBoundaryY) - } - } - - fun imageRegionCtypeIdentifier(imageRegionCtypeIdentifier: List) = - imageRegionCtypeIdentifier(JsonField.of(imageRegionCtypeIdentifier)) - - /** - * Sets [Builder.imageRegionCtypeIdentifier] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionCtypeIdentifier] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionCtypeIdentifier(imageRegionCtypeIdentifier: JsonField>) = - apply { - this.imageRegionCtypeIdentifier = - imageRegionCtypeIdentifier.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionCtypeIdentifier]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionCtypeIdentifier(imageRegionCtypeIdentifier: String) = apply { - this.imageRegionCtypeIdentifier = - (this.imageRegionCtypeIdentifier ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionCtypeIdentifier", it).add(imageRegionCtypeIdentifier) - } - } - - fun imageRegionCtypeName(imageRegionCtypeName: List) = - imageRegionCtypeName(JsonField.of(imageRegionCtypeName)) - - /** - * Sets [Builder.imageRegionCtypeName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionCtypeName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionCtypeName(imageRegionCtypeName: JsonField>) = apply { - this.imageRegionCtypeName = imageRegionCtypeName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionCtypeName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionCtypeName(imageRegionCtypeName: String) = apply { - this.imageRegionCtypeName = - (this.imageRegionCtypeName ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionCtypeName", it).add(imageRegionCtypeName) - } - } - - fun imageRegionId(imageRegionId: List) = - imageRegionId(JsonField.of(imageRegionId)) - - /** - * Sets [Builder.imageRegionId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageRegionId(imageRegionId: JsonField>) = apply { - this.imageRegionId = imageRegionId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionId(imageRegionId: String) = apply { - this.imageRegionId = - (this.imageRegionId ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionId", it).add(imageRegionId) - } - } - - fun imageRegionName(imageRegionName: List) = - imageRegionName(JsonField.of(imageRegionName)) - - /** - * Sets [Builder.imageRegionName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionName] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageRegionName(imageRegionName: JsonField>) = apply { - this.imageRegionName = imageRegionName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionName(imageRegionName: String) = apply { - this.imageRegionName = - (this.imageRegionName ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionName", it).add(imageRegionName) - } - } - - fun imageRegionOrganisationInImageName( - imageRegionOrganisationInImageName: List - ) = imageRegionOrganisationInImageName(JsonField.of(imageRegionOrganisationInImageName)) - - /** - * Sets [Builder.imageRegionOrganisationInImageName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionOrganisationInImageName] with a - * well-typed `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun imageRegionOrganisationInImageName( - imageRegionOrganisationInImageName: JsonField> - ) = apply { - this.imageRegionOrganisationInImageName = - imageRegionOrganisationInImageName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionOrganisationInImageName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionOrganisationInImageName(imageRegionOrganisationInImageName: String) = - apply { - this.imageRegionOrganisationInImageName = - (this.imageRegionOrganisationInImageName ?: JsonField.of(mutableListOf())) - .also { - checkKnown("imageRegionOrganisationInImageName", it) - .add(imageRegionOrganisationInImageName) - } - } - - fun imageRegionPersonInImage(imageRegionPersonInImage: List) = - imageRegionPersonInImage(JsonField.of(imageRegionPersonInImage)) - - /** - * Sets [Builder.imageRegionPersonInImage] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionPersonInImage] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionPersonInImage(imageRegionPersonInImage: JsonField>) = - apply { - this.imageRegionPersonInImage = - imageRegionPersonInImage.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionPersonInImage]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionPersonInImage(imageRegionPersonInImage: String) = apply { - this.imageRegionPersonInImage = - (this.imageRegionPersonInImage ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionPersonInImage", it).add(imageRegionPersonInImage) - } - } - - fun imageRegionRoleIdentifier(imageRegionRoleIdentifier: List) = - imageRegionRoleIdentifier(JsonField.of(imageRegionRoleIdentifier)) - - /** - * Sets [Builder.imageRegionRoleIdentifier] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionRoleIdentifier] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionRoleIdentifier(imageRegionRoleIdentifier: JsonField>) = - apply { - this.imageRegionRoleIdentifier = - imageRegionRoleIdentifier.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionRoleIdentifier]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionRoleIdentifier(imageRegionRoleIdentifier: String) = apply { - this.imageRegionRoleIdentifier = - (this.imageRegionRoleIdentifier ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionRoleIdentifier", it).add(imageRegionRoleIdentifier) - } - } - - fun imageRegionRoleName(imageRegionRoleName: List) = - imageRegionRoleName(JsonField.of(imageRegionRoleName)) - - /** - * Sets [Builder.imageRegionRoleName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageRegionRoleName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun imageRegionRoleName(imageRegionRoleName: JsonField>) = apply { - this.imageRegionRoleName = imageRegionRoleName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.imageRegionRoleName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImageRegionRoleName(imageRegionRoleName: String) = apply { - this.imageRegionRoleName = - (this.imageRegionRoleName ?: JsonField.of(mutableListOf())).also { - checkKnown("imageRegionRoleName", it).add(imageRegionRoleName) - } - } - - fun imageSupplierId(imageSupplierId: String) = - imageSupplierId(JsonField.of(imageSupplierId)) - - /** - * Sets [Builder.imageSupplierId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageSupplierId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageSupplierId(imageSupplierId: JsonField) = apply { - this.imageSupplierId = imageSupplierId - } - - fun imageSupplierImageId(imageSupplierImageId: String) = - imageSupplierImageId(JsonField.of(imageSupplierImageId)) - - /** - * Sets [Builder.imageSupplierImageId] to an arbitrary JSON value. - * - * You should usually call [Builder.imageSupplierImageId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun imageSupplierImageId(imageSupplierImageId: JsonField) = apply { - this.imageSupplierImageId = imageSupplierImageId - } - - fun imageSupplierName(imageSupplierName: String) = - imageSupplierName(JsonField.of(imageSupplierName)) - - /** - * Sets [Builder.imageSupplierName] to an arbitrary JSON value. - * - * You should usually call [Builder.imageSupplierName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageSupplierName(imageSupplierName: JsonField) = apply { - this.imageSupplierName = imageSupplierName - } - - fun instructions(instructions: String) = instructions(JsonField.of(instructions)) - - /** - * Sets [Builder.instructions] to an arbitrary JSON value. - * - * You should usually call [Builder.instructions] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun instructions(instructions: JsonField) = apply { - this.instructions = instructions - } - - fun intellectualGenre(intellectualGenre: String) = - intellectualGenre(JsonField.of(intellectualGenre)) - - /** - * Sets [Builder.intellectualGenre] to an arbitrary JSON value. - * - * You should usually call [Builder.intellectualGenre] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun intellectualGenre(intellectualGenre: JsonField) = apply { - this.intellectualGenre = intellectualGenre - } - - fun keywords(keywords: List) = keywords(JsonField.of(keywords)) - - /** - * Sets [Builder.keywords] to an arbitrary JSON value. - * - * You should usually call [Builder.keywords] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun keywords(keywords: JsonField>) = apply { - this.keywords = keywords.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [keywords]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addKeyword(keyword: String) = apply { - keywords = - (keywords ?: JsonField.of(mutableListOf())).also { - checkKnown("keywords", it).add(keyword) - } - } - - fun licensorCity(licensorCity: List) = licensorCity(JsonField.of(licensorCity)) - - /** - * Sets [Builder.licensorCity] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorCity] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun licensorCity(licensorCity: JsonField>) = apply { - this.licensorCity = licensorCity.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorCity]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorCity(licensorCity: String) = apply { - this.licensorCity = - (this.licensorCity ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorCity", it).add(licensorCity) - } - } - - fun licensorCountry(licensorCountry: List) = - licensorCountry(JsonField.of(licensorCountry)) - - /** - * Sets [Builder.licensorCountry] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorCountry] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorCountry(licensorCountry: JsonField>) = apply { - this.licensorCountry = licensorCountry.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorCountry]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorCountry(licensorCountry: String) = apply { - this.licensorCountry = - (this.licensorCountry ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorCountry", it).add(licensorCountry) - } - } - - fun licensorEmail(licensorEmail: List) = - licensorEmail(JsonField.of(licensorEmail)) - - /** - * Sets [Builder.licensorEmail] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorEmail] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorEmail(licensorEmail: JsonField>) = apply { - this.licensorEmail = licensorEmail.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorEmail]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorEmail(licensorEmail: String) = apply { - this.licensorEmail = - (this.licensorEmail ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorEmail", it).add(licensorEmail) - } - } - - fun licensorExtendedAddress(licensorExtendedAddress: List) = - licensorExtendedAddress(JsonField.of(licensorExtendedAddress)) - - /** - * Sets [Builder.licensorExtendedAddress] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorExtendedAddress] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun licensorExtendedAddress(licensorExtendedAddress: JsonField>) = apply { - this.licensorExtendedAddress = licensorExtendedAddress.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorExtendedAddress]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorExtendedAddress(licensorExtendedAddress: String) = apply { - this.licensorExtendedAddress = - (this.licensorExtendedAddress ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorExtendedAddress", it).add(licensorExtendedAddress) - } - } - - fun licensorId(licensorId: List) = licensorId(JsonField.of(licensorId)) - - /** - * Sets [Builder.licensorId] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorId] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun licensorId(licensorId: JsonField>) = apply { - this.licensorId = licensorId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorId(licensorId: String) = apply { - this.licensorId = - (this.licensorId ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorId", it).add(licensorId) - } - } - - fun licensorName(licensorName: List) = licensorName(JsonField.of(licensorName)) - - /** - * Sets [Builder.licensorName] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorName] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun licensorName(licensorName: JsonField>) = apply { - this.licensorName = licensorName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorName(licensorName: String) = apply { - this.licensorName = - (this.licensorName ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorName", it).add(licensorName) - } - } - - fun licensorPostalCode(licensorPostalCode: List) = - licensorPostalCode(JsonField.of(licensorPostalCode)) - - /** - * Sets [Builder.licensorPostalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorPostalCode] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorPostalCode(licensorPostalCode: JsonField>) = apply { - this.licensorPostalCode = licensorPostalCode.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorPostalCode]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorPostalCode(licensorPostalCode: String) = apply { - this.licensorPostalCode = - (this.licensorPostalCode ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorPostalCode", it).add(licensorPostalCode) - } - } - - fun licensorRegion(licensorRegion: List) = - licensorRegion(JsonField.of(licensorRegion)) - - /** - * Sets [Builder.licensorRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorRegion] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorRegion(licensorRegion: JsonField>) = apply { - this.licensorRegion = licensorRegion.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorRegion]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorRegion(licensorRegion: String) = apply { - this.licensorRegion = - (this.licensorRegion ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorRegion", it).add(licensorRegion) - } - } - - fun licensorStreetAddress(licensorStreetAddress: List) = - licensorStreetAddress(JsonField.of(licensorStreetAddress)) - - /** - * Sets [Builder.licensorStreetAddress] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorStreetAddress] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun licensorStreetAddress(licensorStreetAddress: JsonField>) = apply { - this.licensorStreetAddress = licensorStreetAddress.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorStreetAddress]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorStreetAddress(licensorStreetAddress: String) = apply { - this.licensorStreetAddress = - (this.licensorStreetAddress ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorStreetAddress", it).add(licensorStreetAddress) - } - } - - fun licensorTelephone1(licensorTelephone1: List) = - licensorTelephone1(JsonField.of(licensorTelephone1)) - - /** - * Sets [Builder.licensorTelephone1] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorTelephone1] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorTelephone1(licensorTelephone1: JsonField>) = apply { - this.licensorTelephone1 = licensorTelephone1.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorTelephone1]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorTelephone1(licensorTelephone1: String) = apply { - this.licensorTelephone1 = - (this.licensorTelephone1 ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorTelephone1", it).add(licensorTelephone1) - } - } - - fun licensorTelephone2(licensorTelephone2: List) = - licensorTelephone2(JsonField.of(licensorTelephone2)) - - /** - * Sets [Builder.licensorTelephone2] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorTelephone2] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun licensorTelephone2(licensorTelephone2: JsonField>) = apply { - this.licensorTelephone2 = licensorTelephone2.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorTelephone2]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorTelephone2(licensorTelephone2: String) = apply { - this.licensorTelephone2 = - (this.licensorTelephone2 ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorTelephone2", it).add(licensorTelephone2) - } - } - - fun licensorUrl(licensorUrl: List) = licensorUrl(JsonField.of(licensorUrl)) - - /** - * Sets [Builder.licensorUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.licensorUrl] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun licensorUrl(licensorUrl: JsonField>) = apply { - this.licensorUrl = licensorUrl.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.licensorUrl]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLicensorUrl(licensorUrl: String) = apply { - this.licensorUrl = - (this.licensorUrl ?: JsonField.of(mutableListOf())).also { - checkKnown("licensorUrl", it).add(licensorUrl) - } - } - - fun linkedEncodedRightsExpr(linkedEncodedRightsExpr: String) = - linkedEncodedRightsExpr(JsonField.of(linkedEncodedRightsExpr)) - - /** - * Sets [Builder.linkedEncodedRightsExpr] to an arbitrary JSON value. - * - * You should usually call [Builder.linkedEncodedRightsExpr] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun linkedEncodedRightsExpr(linkedEncodedRightsExpr: JsonField) = apply { - this.linkedEncodedRightsExpr = linkedEncodedRightsExpr - } - - fun linkedEncodedRightsExprLangId(linkedEncodedRightsExprLangId: String) = - linkedEncodedRightsExprLangId(JsonField.of(linkedEncodedRightsExprLangId)) - - /** - * Sets [Builder.linkedEncodedRightsExprLangId] to an arbitrary JSON value. - * - * You should usually call [Builder.linkedEncodedRightsExprLangId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun linkedEncodedRightsExprLangId(linkedEncodedRightsExprLangId: JsonField) = - apply { - this.linkedEncodedRightsExprLangId = linkedEncodedRightsExprLangId - } - - fun linkedEncodedRightsExprType(linkedEncodedRightsExprType: String) = - linkedEncodedRightsExprType(JsonField.of(linkedEncodedRightsExprType)) - - /** - * Sets [Builder.linkedEncodedRightsExprType] to an arbitrary JSON value. - * - * You should usually call [Builder.linkedEncodedRightsExprType] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun linkedEncodedRightsExprType(linkedEncodedRightsExprType: JsonField) = - apply { - this.linkedEncodedRightsExprType = linkedEncodedRightsExprType - } - - fun location(location: String) = location(JsonField.of(location)) - - /** - * Sets [Builder.location] to an arbitrary JSON value. - * - * You should usually call [Builder.location] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun location(location: JsonField) = apply { this.location = location } - - fun locationCreatedCity(locationCreatedCity: String) = - locationCreatedCity(JsonField.of(locationCreatedCity)) - - /** - * Sets [Builder.locationCreatedCity] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedCity] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun locationCreatedCity(locationCreatedCity: JsonField) = apply { - this.locationCreatedCity = locationCreatedCity - } - - fun locationCreatedCountryCode(locationCreatedCountryCode: String) = - locationCreatedCountryCode(JsonField.of(locationCreatedCountryCode)) - - /** - * Sets [Builder.locationCreatedCountryCode] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedCountryCode] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedCountryCode(locationCreatedCountryCode: JsonField) = apply { - this.locationCreatedCountryCode = locationCreatedCountryCode - } - - fun locationCreatedCountryName(locationCreatedCountryName: String) = - locationCreatedCountryName(JsonField.of(locationCreatedCountryName)) - - /** - * Sets [Builder.locationCreatedCountryName] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedCountryName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedCountryName(locationCreatedCountryName: JsonField) = apply { - this.locationCreatedCountryName = locationCreatedCountryName - } - - fun locationCreatedGpsAltitude(locationCreatedGpsAltitude: String) = - locationCreatedGpsAltitude(JsonField.of(locationCreatedGpsAltitude)) - - /** - * Sets [Builder.locationCreatedGpsAltitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedGpsAltitude] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedGpsAltitude(locationCreatedGpsAltitude: JsonField) = apply { - this.locationCreatedGpsAltitude = locationCreatedGpsAltitude - } - - fun locationCreatedGpsLatitude(locationCreatedGpsLatitude: String) = - locationCreatedGpsLatitude(JsonField.of(locationCreatedGpsLatitude)) - - /** - * Sets [Builder.locationCreatedGpsLatitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedGpsLatitude] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedGpsLatitude(locationCreatedGpsLatitude: JsonField) = apply { - this.locationCreatedGpsLatitude = locationCreatedGpsLatitude - } - - fun locationCreatedGpsLongitude(locationCreatedGpsLongitude: String) = - locationCreatedGpsLongitude(JsonField.of(locationCreatedGpsLongitude)) - - /** - * Sets [Builder.locationCreatedGpsLongitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedGpsLongitude] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedGpsLongitude(locationCreatedGpsLongitude: JsonField) = - apply { - this.locationCreatedGpsLongitude = locationCreatedGpsLongitude - } - - fun locationCreatedLocationId(locationCreatedLocationId: String) = - locationCreatedLocationId(JsonField.of(locationCreatedLocationId)) - - /** - * Sets [Builder.locationCreatedLocationId] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedLocationId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedLocationId(locationCreatedLocationId: JsonField) = apply { - this.locationCreatedLocationId = locationCreatedLocationId - } - - fun locationCreatedLocationName(locationCreatedLocationName: String) = - locationCreatedLocationName(JsonField.of(locationCreatedLocationName)) - - /** - * Sets [Builder.locationCreatedLocationName] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedLocationName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedLocationName(locationCreatedLocationName: JsonField) = - apply { - this.locationCreatedLocationName = locationCreatedLocationName - } - - fun locationCreatedProvinceState(locationCreatedProvinceState: String) = - locationCreatedProvinceState(JsonField.of(locationCreatedProvinceState)) - - /** - * Sets [Builder.locationCreatedProvinceState] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedProvinceState] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedProvinceState(locationCreatedProvinceState: JsonField) = - apply { - this.locationCreatedProvinceState = locationCreatedProvinceState - } - - fun locationCreatedSublocation(locationCreatedSublocation: String) = - locationCreatedSublocation(JsonField.of(locationCreatedSublocation)) - - /** - * Sets [Builder.locationCreatedSublocation] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedSublocation] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedSublocation(locationCreatedSublocation: JsonField) = apply { - this.locationCreatedSublocation = locationCreatedSublocation - } - - fun locationCreatedWorldRegion(locationCreatedWorldRegion: String) = - locationCreatedWorldRegion(JsonField.of(locationCreatedWorldRegion)) - - /** - * Sets [Builder.locationCreatedWorldRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.locationCreatedWorldRegion] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationCreatedWorldRegion(locationCreatedWorldRegion: JsonField) = apply { - this.locationCreatedWorldRegion = locationCreatedWorldRegion - } - - fun locationShownCity(locationShownCity: List) = - locationShownCity(JsonField.of(locationShownCity)) - - /** - * Sets [Builder.locationShownCity] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownCity] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun locationShownCity(locationShownCity: JsonField>) = apply { - this.locationShownCity = locationShownCity.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownCity]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownCity(locationShownCity: String) = apply { - this.locationShownCity = - (this.locationShownCity ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownCity", it).add(locationShownCity) - } - } - - fun locationShownCountryCode(locationShownCountryCode: List) = - locationShownCountryCode(JsonField.of(locationShownCountryCode)) - - /** - * Sets [Builder.locationShownCountryCode] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownCountryCode] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownCountryCode(locationShownCountryCode: JsonField>) = - apply { - this.locationShownCountryCode = - locationShownCountryCode.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownCountryCode]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownCountryCode(locationShownCountryCode: String) = apply { - this.locationShownCountryCode = - (this.locationShownCountryCode ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownCountryCode", it).add(locationShownCountryCode) - } - } - - fun locationShownCountryName(locationShownCountryName: List) = - locationShownCountryName(JsonField.of(locationShownCountryName)) - - /** - * Sets [Builder.locationShownCountryName] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownCountryName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownCountryName(locationShownCountryName: JsonField>) = - apply { - this.locationShownCountryName = - locationShownCountryName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownCountryName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownCountryName(locationShownCountryName: String) = apply { - this.locationShownCountryName = - (this.locationShownCountryName ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownCountryName", it).add(locationShownCountryName) - } - } - - fun locationShownGpsAltitude(locationShownGpsAltitude: List) = - locationShownGpsAltitude(JsonField.of(locationShownGpsAltitude)) - - /** - * Sets [Builder.locationShownGpsAltitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownGpsAltitude] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownGpsAltitude(locationShownGpsAltitude: JsonField>) = - apply { - this.locationShownGpsAltitude = - locationShownGpsAltitude.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownGpsAltitude]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownGpsAltitude(locationShownGpsAltitude: String) = apply { - this.locationShownGpsAltitude = - (this.locationShownGpsAltitude ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownGpsAltitude", it).add(locationShownGpsAltitude) - } - } - - fun locationShownGpsLatitude(locationShownGpsLatitude: List) = - locationShownGpsLatitude(JsonField.of(locationShownGpsLatitude)) - - /** - * Sets [Builder.locationShownGpsLatitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownGpsLatitude] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownGpsLatitude(locationShownGpsLatitude: JsonField>) = - apply { - this.locationShownGpsLatitude = - locationShownGpsLatitude.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownGpsLatitude]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownGpsLatitude(locationShownGpsLatitude: String) = apply { - this.locationShownGpsLatitude = - (this.locationShownGpsLatitude ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownGpsLatitude", it).add(locationShownGpsLatitude) - } - } - - fun locationShownGpsLongitude(locationShownGpsLongitude: List) = - locationShownGpsLongitude(JsonField.of(locationShownGpsLongitude)) - - /** - * Sets [Builder.locationShownGpsLongitude] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownGpsLongitude] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownGpsLongitude(locationShownGpsLongitude: JsonField>) = - apply { - this.locationShownGpsLongitude = - locationShownGpsLongitude.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownGpsLongitude]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownGpsLongitude(locationShownGpsLongitude: String) = apply { - this.locationShownGpsLongitude = - (this.locationShownGpsLongitude ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownGpsLongitude", it).add(locationShownGpsLongitude) - } - } - - fun locationShownLocationId(locationShownLocationId: List) = - locationShownLocationId(JsonField.of(locationShownLocationId)) - - /** - * Sets [Builder.locationShownLocationId] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownLocationId] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownLocationId(locationShownLocationId: JsonField>) = apply { - this.locationShownLocationId = locationShownLocationId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownLocationId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownLocationId(locationShownLocationId: String) = apply { - this.locationShownLocationId = - (this.locationShownLocationId ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownLocationId", it).add(locationShownLocationId) - } - } - - fun locationShownLocationName(locationShownLocationName: List) = - locationShownLocationName(JsonField.of(locationShownLocationName)) - - /** - * Sets [Builder.locationShownLocationName] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownLocationName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownLocationName(locationShownLocationName: JsonField>) = - apply { - this.locationShownLocationName = - locationShownLocationName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownLocationName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownLocationName(locationShownLocationName: String) = apply { - this.locationShownLocationName = - (this.locationShownLocationName ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownLocationName", it).add(locationShownLocationName) - } - } - - fun locationShownProvinceState(locationShownProvinceState: List) = - locationShownProvinceState(JsonField.of(locationShownProvinceState)) - - /** - * Sets [Builder.locationShownProvinceState] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownProvinceState] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownProvinceState(locationShownProvinceState: JsonField>) = - apply { - this.locationShownProvinceState = - locationShownProvinceState.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownProvinceState]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownProvinceState(locationShownProvinceState: String) = apply { - this.locationShownProvinceState = - (this.locationShownProvinceState ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownProvinceState", it).add(locationShownProvinceState) - } - } - - fun locationShownSublocation(locationShownSublocation: List) = - locationShownSublocation(JsonField.of(locationShownSublocation)) - - /** - * Sets [Builder.locationShownSublocation] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownSublocation] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownSublocation(locationShownSublocation: JsonField>) = - apply { - this.locationShownSublocation = - locationShownSublocation.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownSublocation]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownSublocation(locationShownSublocation: String) = apply { - this.locationShownSublocation = - (this.locationShownSublocation ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownSublocation", it).add(locationShownSublocation) - } - } - - fun locationShownWorldRegion(locationShownWorldRegion: List) = - locationShownWorldRegion(JsonField.of(locationShownWorldRegion)) - - /** - * Sets [Builder.locationShownWorldRegion] to an arbitrary JSON value. - * - * You should usually call [Builder.locationShownWorldRegion] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locationShownWorldRegion(locationShownWorldRegion: JsonField>) = - apply { - this.locationShownWorldRegion = - locationShownWorldRegion.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.locationShownWorldRegion]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLocationShownWorldRegion(locationShownWorldRegion: String) = apply { - this.locationShownWorldRegion = - (this.locationShownWorldRegion ?: JsonField.of(mutableListOf())).also { - checkKnown("locationShownWorldRegion", it).add(locationShownWorldRegion) - } - } - - fun maxAvailHeight(maxAvailHeight: Double) = - maxAvailHeight(JsonField.of(maxAvailHeight)) - - /** - * Sets [Builder.maxAvailHeight] to an arbitrary JSON value. - * - * You should usually call [Builder.maxAvailHeight] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxAvailHeight(maxAvailHeight: JsonField) = apply { - this.maxAvailHeight = maxAvailHeight - } - - fun maxAvailWidth(maxAvailWidth: Double) = maxAvailWidth(JsonField.of(maxAvailWidth)) - - /** - * Sets [Builder.maxAvailWidth] to an arbitrary JSON value. - * - * You should usually call [Builder.maxAvailWidth] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxAvailWidth(maxAvailWidth: JsonField) = apply { - this.maxAvailWidth = maxAvailWidth - } - - fun modelAge(modelAge: List) = modelAge(JsonField.of(modelAge)) - - /** - * Sets [Builder.modelAge] to an arbitrary JSON value. - * - * You should usually call [Builder.modelAge] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun modelAge(modelAge: JsonField>) = apply { - this.modelAge = modelAge.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.modelAge]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addModelAge(modelAge: Double) = apply { - this.modelAge = - (this.modelAge ?: JsonField.of(mutableListOf())).also { - checkKnown("modelAge", it).add(modelAge) - } - } - - fun modelReleaseId(modelReleaseId: List) = - modelReleaseId(JsonField.of(modelReleaseId)) - - /** - * Sets [Builder.modelReleaseId] to an arbitrary JSON value. - * - * You should usually call [Builder.modelReleaseId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun modelReleaseId(modelReleaseId: JsonField>) = apply { - this.modelReleaseId = modelReleaseId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.modelReleaseId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addModelReleaseId(modelReleaseId: String) = apply { - this.modelReleaseId = - (this.modelReleaseId ?: JsonField.of(mutableListOf())).also { - checkKnown("modelReleaseId", it).add(modelReleaseId) - } - } - - fun objectAttributeReference(objectAttributeReference: String) = - objectAttributeReference(JsonField.of(objectAttributeReference)) - - /** - * Sets [Builder.objectAttributeReference] to an arbitrary JSON value. - * - * You should usually call [Builder.objectAttributeReference] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun objectAttributeReference(objectAttributeReference: JsonField) = apply { - this.objectAttributeReference = objectAttributeReference - } - - fun objectName(objectName: String) = objectName(JsonField.of(objectName)) - - /** - * Sets [Builder.objectName] to an arbitrary JSON value. - * - * You should usually call [Builder.objectName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun objectName(objectName: JsonField) = apply { this.objectName = objectName } - - fun offsetTimeOriginal(offsetTimeOriginal: String) = - offsetTimeOriginal(JsonField.of(offsetTimeOriginal)) - - /** - * Sets [Builder.offsetTimeOriginal] to an arbitrary JSON value. - * - * You should usually call [Builder.offsetTimeOriginal] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun offsetTimeOriginal(offsetTimeOriginal: JsonField) = apply { - this.offsetTimeOriginal = offsetTimeOriginal - } - - fun organisationInImageCode(organisationInImageCode: List) = - organisationInImageCode(JsonField.of(organisationInImageCode)) - - /** - * Sets [Builder.organisationInImageCode] to an arbitrary JSON value. - * - * You should usually call [Builder.organisationInImageCode] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun organisationInImageCode(organisationInImageCode: JsonField>) = apply { - this.organisationInImageCode = organisationInImageCode.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.organisationInImageCode]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addOrganisationInImageCode(organisationInImageCode: String) = apply { - this.organisationInImageCode = - (this.organisationInImageCode ?: JsonField.of(mutableListOf())).also { - checkKnown("organisationInImageCode", it).add(organisationInImageCode) - } - } - - fun organisationInImageName(organisationInImageName: List) = - organisationInImageName(JsonField.of(organisationInImageName)) - - /** - * Sets [Builder.organisationInImageName] to an arbitrary JSON value. - * - * You should usually call [Builder.organisationInImageName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun organisationInImageName(organisationInImageName: JsonField>) = apply { - this.organisationInImageName = organisationInImageName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.organisationInImageName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addOrganisationInImageName(organisationInImageName: String) = apply { - this.organisationInImageName = - (this.organisationInImageName ?: JsonField.of(mutableListOf())).also { - checkKnown("organisationInImageName", it).add(organisationInImageName) - } - } - - fun orientation(orientation: String) = orientation(JsonField.of(orientation)) - - /** - * Sets [Builder.orientation] to an arbitrary JSON value. - * - * You should usually call [Builder.orientation] with a well-typed [String] 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 originalTransmissionReference(originalTransmissionReference: String) = - originalTransmissionReference(JsonField.of(originalTransmissionReference)) - - /** - * Sets [Builder.originalTransmissionReference] to an arbitrary JSON value. - * - * You should usually call [Builder.originalTransmissionReference] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun originalTransmissionReference(originalTransmissionReference: JsonField) = - apply { - this.originalTransmissionReference = originalTransmissionReference - } - - fun personInImage(personInImage: List) = - personInImage(JsonField.of(personInImage)) - - /** - * Sets [Builder.personInImage] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImage] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun personInImage(personInImage: JsonField>) = apply { - this.personInImage = personInImage.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImage]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImage(personInImage: String) = apply { - this.personInImage = - (this.personInImage ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImage", it).add(personInImage) - } - } - - fun personInImageCvTermCvId(personInImageCvTermCvId: List) = - personInImageCvTermCvId(JsonField.of(personInImageCvTermCvId)) - - /** - * Sets [Builder.personInImageCvTermCvId] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageCvTermCvId] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageCvTermCvId(personInImageCvTermCvId: JsonField>) = apply { - this.personInImageCvTermCvId = personInImageCvTermCvId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageCvTermCvId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageCvTermCvId(personInImageCvTermCvId: String) = apply { - this.personInImageCvTermCvId = - (this.personInImageCvTermCvId ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageCvTermCvId", it).add(personInImageCvTermCvId) - } - } - - fun personInImageCvTermId(personInImageCvTermId: List) = - personInImageCvTermId(JsonField.of(personInImageCvTermId)) - - /** - * Sets [Builder.personInImageCvTermId] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageCvTermId] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageCvTermId(personInImageCvTermId: JsonField>) = apply { - this.personInImageCvTermId = personInImageCvTermId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageCvTermId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageCvTermId(personInImageCvTermId: String) = apply { - this.personInImageCvTermId = - (this.personInImageCvTermId ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageCvTermId", it).add(personInImageCvTermId) - } - } - - fun personInImageCvTermName(personInImageCvTermName: List) = - personInImageCvTermName(JsonField.of(personInImageCvTermName)) - - /** - * Sets [Builder.personInImageCvTermName] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageCvTermName] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageCvTermName(personInImageCvTermName: JsonField>) = apply { - this.personInImageCvTermName = personInImageCvTermName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageCvTermName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageCvTermName(personInImageCvTermName: String) = apply { - this.personInImageCvTermName = - (this.personInImageCvTermName ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageCvTermName", it).add(personInImageCvTermName) - } - } - - fun personInImageCvTermRefinedAbout(personInImageCvTermRefinedAbout: List) = - personInImageCvTermRefinedAbout(JsonField.of(personInImageCvTermRefinedAbout)) - - /** - * Sets [Builder.personInImageCvTermRefinedAbout] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageCvTermRefinedAbout] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageCvTermRefinedAbout( - personInImageCvTermRefinedAbout: JsonField> - ) = apply { - this.personInImageCvTermRefinedAbout = - personInImageCvTermRefinedAbout.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageCvTermRefinedAbout]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageCvTermRefinedAbout(personInImageCvTermRefinedAbout: String) = - apply { - this.personInImageCvTermRefinedAbout = - (this.personInImageCvTermRefinedAbout ?: JsonField.of(mutableListOf())) - .also { - checkKnown("personInImageCvTermRefinedAbout", it) - .add(personInImageCvTermRefinedAbout) - } - } - - fun personInImageDescription(personInImageDescription: List) = - personInImageDescription(JsonField.of(personInImageDescription)) - - /** - * Sets [Builder.personInImageDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageDescription] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun personInImageDescription(personInImageDescription: JsonField>) = - apply { - this.personInImageDescription = - personInImageDescription.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageDescription]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageDescription(personInImageDescription: String) = apply { - this.personInImageDescription = - (this.personInImageDescription ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageDescription", it).add(personInImageDescription) - } - } - - fun personInImageId(personInImageId: List) = - personInImageId(JsonField.of(personInImageId)) - - /** - * Sets [Builder.personInImageId] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun personInImageId(personInImageId: JsonField>) = apply { - this.personInImageId = personInImageId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageId(personInImageId: String) = apply { - this.personInImageId = - (this.personInImageId ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageId", it).add(personInImageId) - } - } - - fun personInImageName(personInImageName: List) = - personInImageName(JsonField.of(personInImageName)) - - /** - * Sets [Builder.personInImageName] to an arbitrary JSON value. - * - * You should usually call [Builder.personInImageName] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun personInImageName(personInImageName: JsonField>) = apply { - this.personInImageName = personInImageName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.personInImageName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPersonInImageName(personInImageName: String) = apply { - this.personInImageName = - (this.personInImageName ?: JsonField.of(mutableListOf())).also { - checkKnown("personInImageName", it).add(personInImageName) - } - } - - fun productInImageDescription(productInImageDescription: List) = - productInImageDescription(JsonField.of(productInImageDescription)) - - /** - * Sets [Builder.productInImageDescription] to an arbitrary JSON value. - * - * You should usually call [Builder.productInImageDescription] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun productInImageDescription(productInImageDescription: JsonField>) = - apply { - this.productInImageDescription = - productInImageDescription.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.productInImageDescription]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProductInImageDescription(productInImageDescription: String) = apply { - this.productInImageDescription = - (this.productInImageDescription ?: JsonField.of(mutableListOf())).also { - checkKnown("productInImageDescription", it).add(productInImageDescription) - } - } - - fun productInImageGtin(productInImageGtin: List) = - productInImageGtin(JsonField.of(productInImageGtin)) - - /** - * Sets [Builder.productInImageGtin] to an arbitrary JSON value. - * - * You should usually call [Builder.productInImageGtin] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun productInImageGtin(productInImageGtin: JsonField>) = apply { - this.productInImageGtin = productInImageGtin.map { it.toMutableList() } - } - - /** - * Adds a single [Double] to [Builder.productInImageGtin]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProductInImageGtin(productInImageGtin: Double) = apply { - this.productInImageGtin = - (this.productInImageGtin ?: JsonField.of(mutableListOf())).also { - checkKnown("productInImageGtin", it).add(productInImageGtin) - } - } - - fun productInImageName(productInImageName: List) = - productInImageName(JsonField.of(productInImageName)) - - /** - * Sets [Builder.productInImageName] to an arbitrary JSON value. - * - * You should usually call [Builder.productInImageName] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun productInImageName(productInImageName: JsonField>) = apply { - this.productInImageName = productInImageName.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.productInImageName]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProductInImageName(productInImageName: String) = apply { - this.productInImageName = - (this.productInImageName ?: JsonField.of(mutableListOf())).also { - checkKnown("productInImageName", it).add(productInImageName) - } - } - - fun propertyReleaseId(propertyReleaseId: List) = - propertyReleaseId(JsonField.of(propertyReleaseId)) - - /** - * Sets [Builder.propertyReleaseId] to an arbitrary JSON value. - * - * You should usually call [Builder.propertyReleaseId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun propertyReleaseId(propertyReleaseId: JsonField>) = apply { - this.propertyReleaseId = propertyReleaseId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.propertyReleaseId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPropertyReleaseId(propertyReleaseId: String) = apply { - this.propertyReleaseId = - (this.propertyReleaseId ?: JsonField.of(mutableListOf())).also { - checkKnown("propertyReleaseId", it).add(propertyReleaseId) - } - } - - fun provinceState(provinceState: String) = provinceState(JsonField.of(provinceState)) - - /** - * Sets [Builder.provinceState] to an arbitrary JSON value. - * - * You should usually call [Builder.provinceState] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun provinceState(provinceState: JsonField) = apply { - this.provinceState = provinceState - } - - fun rating(rating: Long) = rating(JsonField.of(rating)) - - /** - * Sets [Builder.rating] to an arbitrary JSON value. - * - * You should usually call [Builder.rating] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun rating(rating: JsonField) = apply { this.rating = rating } - - fun registryEntryRole(registryEntryRole: List) = - registryEntryRole(JsonField.of(registryEntryRole)) - - /** - * Sets [Builder.registryEntryRole] to an arbitrary JSON value. - * - * You should usually call [Builder.registryEntryRole] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun registryEntryRole(registryEntryRole: JsonField>) = apply { - this.registryEntryRole = registryEntryRole.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.registryEntryRole]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRegistryEntryRole(registryEntryRole: String) = apply { - this.registryEntryRole = - (this.registryEntryRole ?: JsonField.of(mutableListOf())).also { - checkKnown("registryEntryRole", it).add(registryEntryRole) - } - } - - fun registryItemId(registryItemId: List) = - registryItemId(JsonField.of(registryItemId)) - - /** - * Sets [Builder.registryItemId] to an arbitrary JSON value. - * - * You should usually call [Builder.registryItemId] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun registryItemId(registryItemId: JsonField>) = apply { - this.registryItemId = registryItemId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.registryItemId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRegistryItemId(registryItemId: String) = apply { - this.registryItemId = - (this.registryItemId ?: JsonField.of(mutableListOf())).also { - checkKnown("registryItemId", it).add(registryItemId) - } - } - - fun registryOrganisationId(registryOrganisationId: List) = - registryOrganisationId(JsonField.of(registryOrganisationId)) - - /** - * Sets [Builder.registryOrganisationId] to an arbitrary JSON value. - * - * You should usually call [Builder.registryOrganisationId] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun registryOrganisationId(registryOrganisationId: JsonField>) = apply { - this.registryOrganisationId = registryOrganisationId.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.registryOrganisationId]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRegistryOrganisationId(registryOrganisationId: String) = apply { - this.registryOrganisationId = - (this.registryOrganisationId ?: JsonField.of(mutableListOf())).also { - checkKnown("registryOrganisationId", it).add(registryOrganisationId) - } - } - - fun resolutionUnit(resolutionUnit: String) = - resolutionUnit(JsonField.of(resolutionUnit)) - - /** - * Sets [Builder.resolutionUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.resolutionUnit] with a well-typed [String] 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 rights(rights: String) = rights(JsonField.of(rights)) - - /** - * Sets [Builder.rights] to an arbitrary JSON value. - * - * You should usually call [Builder.rights] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rights(rights: JsonField) = apply { this.rights = rights } - - fun scene(scene: List) = scene(JsonField.of(scene)) - - /** - * Sets [Builder.scene] to an arbitrary JSON value. - * - * You should usually call [Builder.scene] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun scene(scene: JsonField>) = apply { - this.scene = scene.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.scene]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addScene(scene: String) = apply { - this.scene = - (this.scene ?: JsonField.of(mutableListOf())).also { - checkKnown("scene", it).add(scene) - } - } - - 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 specialInstructions(specialInstructions: String) = - specialInstructions(JsonField.of(specialInstructions)) - - /** - * Sets [Builder.specialInstructions] to an arbitrary JSON value. - * - * You should usually call [Builder.specialInstructions] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun specialInstructions(specialInstructions: JsonField) = apply { - this.specialInstructions = specialInstructions - } - - fun state(state: String) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun state(state: JsonField) = apply { this.state = state } - - fun subject(subject: List) = subject(JsonField.of(subject)) - - /** - * Sets [Builder.subject] to an arbitrary JSON value. - * - * You should usually call [Builder.subject] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun subject(subject: JsonField>) = apply { - this.subject = subject.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.subject]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSubject(subject: String) = apply { - this.subject = - (this.subject ?: JsonField.of(mutableListOf())).also { - checkKnown("subject", it).add(subject) - } - } - - fun subjectCode(subjectCode: List) = subjectCode(JsonField.of(subjectCode)) - - /** - * Sets [Builder.subjectCode] to an arbitrary JSON value. - * - * You should usually call [Builder.subjectCode] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun subjectCode(subjectCode: JsonField>) = apply { - this.subjectCode = subjectCode.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.subjectCode]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSubjectCode(subjectCode: String) = apply { - this.subjectCode = - (this.subjectCode ?: JsonField.of(mutableListOf())).also { - checkKnown("subjectCode", it).add(subjectCode) - } - } - - fun subjectReference(subjectReference: List) = - subjectReference(JsonField.of(subjectReference)) - - /** - * Sets [Builder.subjectReference] to an arbitrary JSON value. - * - * You should usually call [Builder.subjectReference] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun subjectReference(subjectReference: JsonField>) = apply { - this.subjectReference = subjectReference.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.subjectReference]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addSubjectReference(subjectReference: String) = apply { - this.subjectReference = - (this.subjectReference ?: JsonField.of(mutableListOf())).also { - checkKnown("subjectReference", it).add(subjectReference) - } - } - - fun sublocation(sublocation: String) = sublocation(JsonField.of(sublocation)) - - /** - * Sets [Builder.sublocation] to an arbitrary JSON value. - * - * You should usually call [Builder.sublocation] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sublocation(sublocation: JsonField) = apply { - this.sublocation = sublocation - } - - fun timeCreated(timeCreated: String) = timeCreated(JsonField.of(timeCreated)) - - /** - * Sets [Builder.timeCreated] to an arbitrary JSON value. - * - * You should usually call [Builder.timeCreated] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun timeCreated(timeCreated: JsonField) = apply { - this.timeCreated = timeCreated - } - - fun title(title: String) = title(JsonField.of(title)) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun title(title: JsonField) = apply { this.title = title } - - fun transmissionReference(transmissionReference: String) = - transmissionReference(JsonField.of(transmissionReference)) - - /** - * Sets [Builder.transmissionReference] to an arbitrary JSON value. - * - * You should usually call [Builder.transmissionReference] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun transmissionReference(transmissionReference: JsonField) = apply { - this.transmissionReference = transmissionReference - } - - fun usageTerms(usageTerms: String) = usageTerms(JsonField.of(usageTerms)) - - /** - * Sets [Builder.usageTerms] to an arbitrary JSON value. - * - * You should usually call [Builder.usageTerms] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun usageTerms(usageTerms: JsonField) = apply { this.usageTerms = usageTerms } - - fun webStatement(webStatement: String) = webStatement(JsonField.of(webStatement)) - - /** - * Sets [Builder.webStatement] to an arbitrary JSON value. - * - * You should usually call [Builder.webStatement] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun webStatement(webStatement: JsonField) = apply { - this.webStatement = webStatement - } - - fun writer(writer: String) = writer(JsonField.of(writer)) - - /** - * Sets [Builder.writer] to an arbitrary JSON value. - * - * You should usually call [Builder.writer] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun writer(writer: JsonField) = apply { this.writer = writer } - - fun writerEditor(writerEditor: String) = writerEditor(JsonField.of(writerEditor)) - - /** - * Sets [Builder.writerEditor] to an arbitrary JSON value. - * - * You should usually call [Builder.writerEditor] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun writerEditor(writerEditor: JsonField) = apply { - this.writerEditor = writerEditor - } - - fun xResolution(xResolution: Double) = xResolution(JsonField.of(xResolution)) - - /** - * Sets [Builder.xResolution] to an arbitrary JSON value. - * - * You should usually call [Builder.xResolution] with a well-typed [Double] 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: Double) = yResolution(JsonField.of(yResolution)) - - /** - * Sets [Builder.yResolution] to an arbitrary JSON value. - * - * You should usually call [Builder.yResolution] with a well-typed [Double] 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 [EmbeddedMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EmbeddedMetadata = - EmbeddedMetadata( - aboutCvTermCvId, - aboutCvTermId, - aboutCvTermName, - aboutCvTermRefinedAbout, - additionalModelInformation, - applicationRecordVersion, - artist, - artworkCircaDateCreated, - artworkContentDescription, - artworkContributionDescription, - artworkCopyrightNotice, - artworkCopyrightOwnerId, - artworkCopyrightOwnerName, - (artworkCreator ?: JsonMissing.of()).map { it.toImmutable() }, - (artworkCreatorId ?: JsonMissing.of()).map { it.toImmutable() }, - artworkDateCreated, - artworkLicensorId, - artworkLicensorName, - artworkPhysicalDescription, - artworkSource, - artworkSourceInventoryNo, - artworkSourceInvUrl, - (artworkStylePeriod ?: JsonMissing.of()).map { it.toImmutable() }, - artworkTitle, - authorsPosition, - byline, - bylineTitle, - caption, - captionAbstract, - captionWriter, - city, - colorSpace, - componentsConfiguration, - copyright, - copyrightNotice, - (copyrightOwnerId ?: JsonMissing.of()).map { it.toImmutable() }, - (copyrightOwnerName ?: JsonMissing.of()).map { it.toImmutable() }, - country, - countryCode, - countryPrimaryLocationCode, - countryPrimaryLocationName, - creator, - creatorAddress, - creatorCity, - creatorCountry, - creatorPostalCode, - creatorRegion, - creatorWorkEmail, - creatorWorkTelephone, - creatorWorkUrl, - credit, - dateCreated, - dateTimeCreated, - dateTimeOriginal, - description, - digitalImageGuid, - digitalSourceType, - embeddedEncodedRightsExpr, - embeddedEncodedRightsExprLangId, - embeddedEncodedRightsExprType, - event, - exifVersion, - flashpixVersion, - genreCvId, - genreCvTermId, - genreCvTermName, - genreCvTermRefinedAbout, - headline, - imageCreatorId, - imageCreatorImageId, - imageCreatorName, - imageDescription, - (imageRegionBoundaryH ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryRx ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryShape ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryUnit ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryVerticesX ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryVerticesY ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryW ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryX ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionBoundaryY ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionCtypeIdentifier ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionCtypeName ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionId ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionName ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionOrganisationInImageName ?: JsonMissing.of()).map { - it.toImmutable() - }, - (imageRegionPersonInImage ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionRoleIdentifier ?: JsonMissing.of()).map { it.toImmutable() }, - (imageRegionRoleName ?: JsonMissing.of()).map { it.toImmutable() }, - imageSupplierId, - imageSupplierImageId, - imageSupplierName, - instructions, - intellectualGenre, - (keywords ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorCity ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorCountry ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorEmail ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorExtendedAddress ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorId ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorName ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorPostalCode ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorRegion ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorStreetAddress ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorTelephone1 ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorTelephone2 ?: JsonMissing.of()).map { it.toImmutable() }, - (licensorUrl ?: JsonMissing.of()).map { it.toImmutable() }, - linkedEncodedRightsExpr, - linkedEncodedRightsExprLangId, - linkedEncodedRightsExprType, - location, - locationCreatedCity, - locationCreatedCountryCode, - locationCreatedCountryName, - locationCreatedGpsAltitude, - locationCreatedGpsLatitude, - locationCreatedGpsLongitude, - locationCreatedLocationId, - locationCreatedLocationName, - locationCreatedProvinceState, - locationCreatedSublocation, - locationCreatedWorldRegion, - (locationShownCity ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownCountryCode ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownCountryName ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownGpsAltitude ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownGpsLatitude ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownGpsLongitude ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownLocationId ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownLocationName ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownProvinceState ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownSublocation ?: JsonMissing.of()).map { it.toImmutable() }, - (locationShownWorldRegion ?: JsonMissing.of()).map { it.toImmutable() }, - maxAvailHeight, - maxAvailWidth, - (modelAge ?: JsonMissing.of()).map { it.toImmutable() }, - (modelReleaseId ?: JsonMissing.of()).map { it.toImmutable() }, - objectAttributeReference, - objectName, - offsetTimeOriginal, - (organisationInImageCode ?: JsonMissing.of()).map { it.toImmutable() }, - (organisationInImageName ?: JsonMissing.of()).map { it.toImmutable() }, - orientation, - originalTransmissionReference, - (personInImage ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageCvTermCvId ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageCvTermId ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageCvTermName ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageCvTermRefinedAbout ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageDescription ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageId ?: JsonMissing.of()).map { it.toImmutable() }, - (personInImageName ?: JsonMissing.of()).map { it.toImmutable() }, - (productInImageDescription ?: JsonMissing.of()).map { it.toImmutable() }, - (productInImageGtin ?: JsonMissing.of()).map { it.toImmutable() }, - (productInImageName ?: JsonMissing.of()).map { it.toImmutable() }, - (propertyReleaseId ?: JsonMissing.of()).map { it.toImmutable() }, - provinceState, - rating, - (registryEntryRole ?: JsonMissing.of()).map { it.toImmutable() }, - (registryItemId ?: JsonMissing.of()).map { it.toImmutable() }, - (registryOrganisationId ?: JsonMissing.of()).map { it.toImmutable() }, - resolutionUnit, - rights, - (scene ?: JsonMissing.of()).map { it.toImmutable() }, - source, - specialInstructions, - state, - (subject ?: JsonMissing.of()).map { it.toImmutable() }, - (subjectCode ?: JsonMissing.of()).map { it.toImmutable() }, - (subjectReference ?: JsonMissing.of()).map { it.toImmutable() }, - sublocation, - timeCreated, - title, - transmissionReference, - usageTerms, - webStatement, - writer, - writerEditor, - xResolution, - yResolution, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmbeddedMetadata = apply { - if (validated) { - return@apply - } - - aboutCvTermCvId() - aboutCvTermId() - aboutCvTermName() - aboutCvTermRefinedAbout() - additionalModelInformation() - applicationRecordVersion() - artist() - artworkCircaDateCreated() - artworkContentDescription() - artworkContributionDescription() - artworkCopyrightNotice() - artworkCopyrightOwnerId() - artworkCopyrightOwnerName() - artworkCreator() - artworkCreatorId() - artworkDateCreated() - artworkLicensorId() - artworkLicensorName() - artworkPhysicalDescription() - artworkSource() - artworkSourceInventoryNo() - artworkSourceInvUrl() - artworkStylePeriod() - artworkTitle() - authorsPosition() - byline() - bylineTitle() - caption() - captionAbstract() - captionWriter() - city() - colorSpace() - componentsConfiguration() - copyright() - copyrightNotice() - copyrightOwnerId() - copyrightOwnerName() - country() - countryCode() - countryPrimaryLocationCode() - countryPrimaryLocationName() - creator() - creatorAddress() - creatorCity() - creatorCountry() - creatorPostalCode() - creatorRegion() - creatorWorkEmail() - creatorWorkTelephone() - creatorWorkUrl() - credit() - dateCreated() - dateTimeCreated() - dateTimeOriginal() - description() - digitalImageGuid() - digitalSourceType() - embeddedEncodedRightsExpr() - embeddedEncodedRightsExprLangId() - embeddedEncodedRightsExprType() - event() - exifVersion() - flashpixVersion() - genreCvId() - genreCvTermId() - genreCvTermName() - genreCvTermRefinedAbout() - headline() - imageCreatorId() - imageCreatorImageId() - imageCreatorName() - imageDescription() - imageRegionBoundaryH() - imageRegionBoundaryRx() - imageRegionBoundaryShape() - imageRegionBoundaryUnit() - imageRegionBoundaryVerticesX() - imageRegionBoundaryVerticesY() - imageRegionBoundaryW() - imageRegionBoundaryX() - imageRegionBoundaryY() - imageRegionCtypeIdentifier() - imageRegionCtypeName() - imageRegionId() - imageRegionName() - imageRegionOrganisationInImageName() - imageRegionPersonInImage() - imageRegionRoleIdentifier() - imageRegionRoleName() - imageSupplierId() - imageSupplierImageId() - imageSupplierName() - instructions() - intellectualGenre() - keywords() - licensorCity() - licensorCountry() - licensorEmail() - licensorExtendedAddress() - licensorId() - licensorName() - licensorPostalCode() - licensorRegion() - licensorStreetAddress() - licensorTelephone1() - licensorTelephone2() - licensorUrl() - linkedEncodedRightsExpr() - linkedEncodedRightsExprLangId() - linkedEncodedRightsExprType() - location() - locationCreatedCity() - locationCreatedCountryCode() - locationCreatedCountryName() - locationCreatedGpsAltitude() - locationCreatedGpsLatitude() - locationCreatedGpsLongitude() - locationCreatedLocationId() - locationCreatedLocationName() - locationCreatedProvinceState() - locationCreatedSublocation() - locationCreatedWorldRegion() - locationShownCity() - locationShownCountryCode() - locationShownCountryName() - locationShownGpsAltitude() - locationShownGpsLatitude() - locationShownGpsLongitude() - locationShownLocationId() - locationShownLocationName() - locationShownProvinceState() - locationShownSublocation() - locationShownWorldRegion() - maxAvailHeight() - maxAvailWidth() - modelAge() - modelReleaseId() - objectAttributeReference() - objectName() - offsetTimeOriginal() - organisationInImageCode() - organisationInImageName() - orientation() - originalTransmissionReference() - personInImage() - personInImageCvTermCvId() - personInImageCvTermId() - personInImageCvTermName() - personInImageCvTermRefinedAbout() - personInImageDescription() - personInImageId() - personInImageName() - productInImageDescription() - productInImageGtin() - productInImageName() - propertyReleaseId() - provinceState() - rating() - registryEntryRole() - registryItemId() - registryOrganisationId() - resolutionUnit() - rights() - scene() - source() - specialInstructions() - state() - subject() - subjectCode() - subjectReference() - sublocation() - timeCreated() - title() - transmissionReference() - usageTerms() - webStatement() - writer() - writerEditor() - 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 (aboutCvTermCvId.asKnown().isPresent) 1 else 0) + - (if (aboutCvTermId.asKnown().isPresent) 1 else 0) + - (if (aboutCvTermName.asKnown().isPresent) 1 else 0) + - (if (aboutCvTermRefinedAbout.asKnown().isPresent) 1 else 0) + - (if (additionalModelInformation.asKnown().isPresent) 1 else 0) + - (if (applicationRecordVersion.asKnown().isPresent) 1 else 0) + - (if (artist.asKnown().isPresent) 1 else 0) + - (if (artworkCircaDateCreated.asKnown().isPresent) 1 else 0) + - (if (artworkContentDescription.asKnown().isPresent) 1 else 0) + - (if (artworkContributionDescription.asKnown().isPresent) 1 else 0) + - (if (artworkCopyrightNotice.asKnown().isPresent) 1 else 0) + - (if (artworkCopyrightOwnerId.asKnown().isPresent) 1 else 0) + - (if (artworkCopyrightOwnerName.asKnown().isPresent) 1 else 0) + - (artworkCreator.asKnown().getOrNull()?.size ?: 0) + - (artworkCreatorId.asKnown().getOrNull()?.size ?: 0) + - (if (artworkDateCreated.asKnown().isPresent) 1 else 0) + - (if (artworkLicensorId.asKnown().isPresent) 1 else 0) + - (if (artworkLicensorName.asKnown().isPresent) 1 else 0) + - (if (artworkPhysicalDescription.asKnown().isPresent) 1 else 0) + - (if (artworkSource.asKnown().isPresent) 1 else 0) + - (if (artworkSourceInventoryNo.asKnown().isPresent) 1 else 0) + - (if (artworkSourceInvUrl.asKnown().isPresent) 1 else 0) + - (artworkStylePeriod.asKnown().getOrNull()?.size ?: 0) + - (if (artworkTitle.asKnown().isPresent) 1 else 0) + - (if (authorsPosition.asKnown().isPresent) 1 else 0) + - (if (byline.asKnown().isPresent) 1 else 0) + - (if (bylineTitle.asKnown().isPresent) 1 else 0) + - (if (caption.asKnown().isPresent) 1 else 0) + - (if (captionAbstract.asKnown().isPresent) 1 else 0) + - (if (captionWriter.asKnown().isPresent) 1 else 0) + - (if (city.asKnown().isPresent) 1 else 0) + - (if (colorSpace.asKnown().isPresent) 1 else 0) + - (if (componentsConfiguration.asKnown().isPresent) 1 else 0) + - (if (copyright.asKnown().isPresent) 1 else 0) + - (if (copyrightNotice.asKnown().isPresent) 1 else 0) + - (copyrightOwnerId.asKnown().getOrNull()?.size ?: 0) + - (copyrightOwnerName.asKnown().getOrNull()?.size ?: 0) + - (if (country.asKnown().isPresent) 1 else 0) + - (if (countryCode.asKnown().isPresent) 1 else 0) + - (if (countryPrimaryLocationCode.asKnown().isPresent) 1 else 0) + - (if (countryPrimaryLocationName.asKnown().isPresent) 1 else 0) + - (if (creator.asKnown().isPresent) 1 else 0) + - (if (creatorAddress.asKnown().isPresent) 1 else 0) + - (if (creatorCity.asKnown().isPresent) 1 else 0) + - (if (creatorCountry.asKnown().isPresent) 1 else 0) + - (if (creatorPostalCode.asKnown().isPresent) 1 else 0) + - (if (creatorRegion.asKnown().isPresent) 1 else 0) + - (if (creatorWorkEmail.asKnown().isPresent) 1 else 0) + - (if (creatorWorkTelephone.asKnown().isPresent) 1 else 0) + - (if (creatorWorkUrl.asKnown().isPresent) 1 else 0) + - (if (credit.asKnown().isPresent) 1 else 0) + - (if (dateCreated.asKnown().isPresent) 1 else 0) + - (if (dateTimeCreated.asKnown().isPresent) 1 else 0) + - (if (dateTimeOriginal.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (digitalImageGuid.asKnown().isPresent) 1 else 0) + - (if (digitalSourceType.asKnown().isPresent) 1 else 0) + - (if (embeddedEncodedRightsExpr.asKnown().isPresent) 1 else 0) + - (if (embeddedEncodedRightsExprLangId.asKnown().isPresent) 1 else 0) + - (if (embeddedEncodedRightsExprType.asKnown().isPresent) 1 else 0) + - (if (event.asKnown().isPresent) 1 else 0) + - (if (exifVersion.asKnown().isPresent) 1 else 0) + - (if (flashpixVersion.asKnown().isPresent) 1 else 0) + - (if (genreCvId.asKnown().isPresent) 1 else 0) + - (if (genreCvTermId.asKnown().isPresent) 1 else 0) + - (if (genreCvTermName.asKnown().isPresent) 1 else 0) + - (if (genreCvTermRefinedAbout.asKnown().isPresent) 1 else 0) + - (if (headline.asKnown().isPresent) 1 else 0) + - (if (imageCreatorId.asKnown().isPresent) 1 else 0) + - (if (imageCreatorImageId.asKnown().isPresent) 1 else 0) + - (if (imageCreatorName.asKnown().isPresent) 1 else 0) + - (if (imageDescription.asKnown().isPresent) 1 else 0) + - (imageRegionBoundaryH.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryRx.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryShape.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryUnit.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryVerticesX.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryVerticesY.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryW.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryX.asKnown().getOrNull()?.size ?: 0) + - (imageRegionBoundaryY.asKnown().getOrNull()?.size ?: 0) + - (imageRegionCtypeIdentifier.asKnown().getOrNull()?.size ?: 0) + - (imageRegionCtypeName.asKnown().getOrNull()?.size ?: 0) + - (imageRegionId.asKnown().getOrNull()?.size ?: 0) + - (imageRegionName.asKnown().getOrNull()?.size ?: 0) + - (imageRegionOrganisationInImageName.asKnown().getOrNull()?.size ?: 0) + - (imageRegionPersonInImage.asKnown().getOrNull()?.size ?: 0) + - (imageRegionRoleIdentifier.asKnown().getOrNull()?.size ?: 0) + - (imageRegionRoleName.asKnown().getOrNull()?.size ?: 0) + - (if (imageSupplierId.asKnown().isPresent) 1 else 0) + - (if (imageSupplierImageId.asKnown().isPresent) 1 else 0) + - (if (imageSupplierName.asKnown().isPresent) 1 else 0) + - (if (instructions.asKnown().isPresent) 1 else 0) + - (if (intellectualGenre.asKnown().isPresent) 1 else 0) + - (keywords.asKnown().getOrNull()?.size ?: 0) + - (licensorCity.asKnown().getOrNull()?.size ?: 0) + - (licensorCountry.asKnown().getOrNull()?.size ?: 0) + - (licensorEmail.asKnown().getOrNull()?.size ?: 0) + - (licensorExtendedAddress.asKnown().getOrNull()?.size ?: 0) + - (licensorId.asKnown().getOrNull()?.size ?: 0) + - (licensorName.asKnown().getOrNull()?.size ?: 0) + - (licensorPostalCode.asKnown().getOrNull()?.size ?: 0) + - (licensorRegion.asKnown().getOrNull()?.size ?: 0) + - (licensorStreetAddress.asKnown().getOrNull()?.size ?: 0) + - (licensorTelephone1.asKnown().getOrNull()?.size ?: 0) + - (licensorTelephone2.asKnown().getOrNull()?.size ?: 0) + - (licensorUrl.asKnown().getOrNull()?.size ?: 0) + - (if (linkedEncodedRightsExpr.asKnown().isPresent) 1 else 0) + - (if (linkedEncodedRightsExprLangId.asKnown().isPresent) 1 else 0) + - (if (linkedEncodedRightsExprType.asKnown().isPresent) 1 else 0) + - (if (location.asKnown().isPresent) 1 else 0) + - (if (locationCreatedCity.asKnown().isPresent) 1 else 0) + - (if (locationCreatedCountryCode.asKnown().isPresent) 1 else 0) + - (if (locationCreatedCountryName.asKnown().isPresent) 1 else 0) + - (if (locationCreatedGpsAltitude.asKnown().isPresent) 1 else 0) + - (if (locationCreatedGpsLatitude.asKnown().isPresent) 1 else 0) + - (if (locationCreatedGpsLongitude.asKnown().isPresent) 1 else 0) + - (if (locationCreatedLocationId.asKnown().isPresent) 1 else 0) + - (if (locationCreatedLocationName.asKnown().isPresent) 1 else 0) + - (if (locationCreatedProvinceState.asKnown().isPresent) 1 else 0) + - (if (locationCreatedSublocation.asKnown().isPresent) 1 else 0) + - (if (locationCreatedWorldRegion.asKnown().isPresent) 1 else 0) + - (locationShownCity.asKnown().getOrNull()?.size ?: 0) + - (locationShownCountryCode.asKnown().getOrNull()?.size ?: 0) + - (locationShownCountryName.asKnown().getOrNull()?.size ?: 0) + - (locationShownGpsAltitude.asKnown().getOrNull()?.size ?: 0) + - (locationShownGpsLatitude.asKnown().getOrNull()?.size ?: 0) + - (locationShownGpsLongitude.asKnown().getOrNull()?.size ?: 0) + - (locationShownLocationId.asKnown().getOrNull()?.size ?: 0) + - (locationShownLocationName.asKnown().getOrNull()?.size ?: 0) + - (locationShownProvinceState.asKnown().getOrNull()?.size ?: 0) + - (locationShownSublocation.asKnown().getOrNull()?.size ?: 0) + - (locationShownWorldRegion.asKnown().getOrNull()?.size ?: 0) + - (if (maxAvailHeight.asKnown().isPresent) 1 else 0) + - (if (maxAvailWidth.asKnown().isPresent) 1 else 0) + - (modelAge.asKnown().getOrNull()?.size ?: 0) + - (modelReleaseId.asKnown().getOrNull()?.size ?: 0) + - (if (objectAttributeReference.asKnown().isPresent) 1 else 0) + - (if (objectName.asKnown().isPresent) 1 else 0) + - (if (offsetTimeOriginal.asKnown().isPresent) 1 else 0) + - (organisationInImageCode.asKnown().getOrNull()?.size ?: 0) + - (organisationInImageName.asKnown().getOrNull()?.size ?: 0) + - (if (orientation.asKnown().isPresent) 1 else 0) + - (if (originalTransmissionReference.asKnown().isPresent) 1 else 0) + - (personInImage.asKnown().getOrNull()?.size ?: 0) + - (personInImageCvTermCvId.asKnown().getOrNull()?.size ?: 0) + - (personInImageCvTermId.asKnown().getOrNull()?.size ?: 0) + - (personInImageCvTermName.asKnown().getOrNull()?.size ?: 0) + - (personInImageCvTermRefinedAbout.asKnown().getOrNull()?.size ?: 0) + - (personInImageDescription.asKnown().getOrNull()?.size ?: 0) + - (personInImageId.asKnown().getOrNull()?.size ?: 0) + - (personInImageName.asKnown().getOrNull()?.size ?: 0) + - (productInImageDescription.asKnown().getOrNull()?.size ?: 0) + - (productInImageGtin.asKnown().getOrNull()?.size ?: 0) + - (productInImageName.asKnown().getOrNull()?.size ?: 0) + - (propertyReleaseId.asKnown().getOrNull()?.size ?: 0) + - (if (provinceState.asKnown().isPresent) 1 else 0) + - (if (rating.asKnown().isPresent) 1 else 0) + - (registryEntryRole.asKnown().getOrNull()?.size ?: 0) + - (registryItemId.asKnown().getOrNull()?.size ?: 0) + - (registryOrganisationId.asKnown().getOrNull()?.size ?: 0) + - (if (resolutionUnit.asKnown().isPresent) 1 else 0) + - (if (rights.asKnown().isPresent) 1 else 0) + - (scene.asKnown().getOrNull()?.size ?: 0) + - (if (source.asKnown().isPresent) 1 else 0) + - (if (specialInstructions.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) + - (subject.asKnown().getOrNull()?.size ?: 0) + - (subjectCode.asKnown().getOrNull()?.size ?: 0) + - (subjectReference.asKnown().getOrNull()?.size ?: 0) + - (if (sublocation.asKnown().isPresent) 1 else 0) + - (if (timeCreated.asKnown().isPresent) 1 else 0) + - (if (title.asKnown().isPresent) 1 else 0) + - (if (transmissionReference.asKnown().isPresent) 1 else 0) + - (if (usageTerms.asKnown().isPresent) 1 else 0) + - (if (webStatement.asKnown().isPresent) 1 else 0) + - (if (writer.asKnown().isPresent) 1 else 0) + - (if (writerEditor.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 EmbeddedMetadata && - aboutCvTermCvId == other.aboutCvTermCvId && - aboutCvTermId == other.aboutCvTermId && - aboutCvTermName == other.aboutCvTermName && - aboutCvTermRefinedAbout == other.aboutCvTermRefinedAbout && - additionalModelInformation == other.additionalModelInformation && - applicationRecordVersion == other.applicationRecordVersion && - artist == other.artist && - artworkCircaDateCreated == other.artworkCircaDateCreated && - artworkContentDescription == other.artworkContentDescription && - artworkContributionDescription == other.artworkContributionDescription && - artworkCopyrightNotice == other.artworkCopyrightNotice && - artworkCopyrightOwnerId == other.artworkCopyrightOwnerId && - artworkCopyrightOwnerName == other.artworkCopyrightOwnerName && - artworkCreator == other.artworkCreator && - artworkCreatorId == other.artworkCreatorId && - artworkDateCreated == other.artworkDateCreated && - artworkLicensorId == other.artworkLicensorId && - artworkLicensorName == other.artworkLicensorName && - artworkPhysicalDescription == other.artworkPhysicalDescription && - artworkSource == other.artworkSource && - artworkSourceInventoryNo == other.artworkSourceInventoryNo && - artworkSourceInvUrl == other.artworkSourceInvUrl && - artworkStylePeriod == other.artworkStylePeriod && - artworkTitle == other.artworkTitle && - authorsPosition == other.authorsPosition && - byline == other.byline && - bylineTitle == other.bylineTitle && - caption == other.caption && - captionAbstract == other.captionAbstract && - captionWriter == other.captionWriter && - city == other.city && - colorSpace == other.colorSpace && - componentsConfiguration == other.componentsConfiguration && - copyright == other.copyright && - copyrightNotice == other.copyrightNotice && - copyrightOwnerId == other.copyrightOwnerId && - copyrightOwnerName == other.copyrightOwnerName && - country == other.country && - countryCode == other.countryCode && - countryPrimaryLocationCode == other.countryPrimaryLocationCode && - countryPrimaryLocationName == other.countryPrimaryLocationName && - creator == other.creator && - creatorAddress == other.creatorAddress && - creatorCity == other.creatorCity && - creatorCountry == other.creatorCountry && - creatorPostalCode == other.creatorPostalCode && - creatorRegion == other.creatorRegion && - creatorWorkEmail == other.creatorWorkEmail && - creatorWorkTelephone == other.creatorWorkTelephone && - creatorWorkUrl == other.creatorWorkUrl && - credit == other.credit && - dateCreated == other.dateCreated && - dateTimeCreated == other.dateTimeCreated && - dateTimeOriginal == other.dateTimeOriginal && - description == other.description && - digitalImageGuid == other.digitalImageGuid && - digitalSourceType == other.digitalSourceType && - embeddedEncodedRightsExpr == other.embeddedEncodedRightsExpr && - embeddedEncodedRightsExprLangId == other.embeddedEncodedRightsExprLangId && - embeddedEncodedRightsExprType == other.embeddedEncodedRightsExprType && - event == other.event && - exifVersion == other.exifVersion && - flashpixVersion == other.flashpixVersion && - genreCvId == other.genreCvId && - genreCvTermId == other.genreCvTermId && - genreCvTermName == other.genreCvTermName && - genreCvTermRefinedAbout == other.genreCvTermRefinedAbout && - headline == other.headline && - imageCreatorId == other.imageCreatorId && - imageCreatorImageId == other.imageCreatorImageId && - imageCreatorName == other.imageCreatorName && - imageDescription == other.imageDescription && - imageRegionBoundaryH == other.imageRegionBoundaryH && - imageRegionBoundaryRx == other.imageRegionBoundaryRx && - imageRegionBoundaryShape == other.imageRegionBoundaryShape && - imageRegionBoundaryUnit == other.imageRegionBoundaryUnit && - imageRegionBoundaryVerticesX == other.imageRegionBoundaryVerticesX && - imageRegionBoundaryVerticesY == other.imageRegionBoundaryVerticesY && - imageRegionBoundaryW == other.imageRegionBoundaryW && - imageRegionBoundaryX == other.imageRegionBoundaryX && - imageRegionBoundaryY == other.imageRegionBoundaryY && - imageRegionCtypeIdentifier == other.imageRegionCtypeIdentifier && - imageRegionCtypeName == other.imageRegionCtypeName && - imageRegionId == other.imageRegionId && - imageRegionName == other.imageRegionName && - imageRegionOrganisationInImageName == other.imageRegionOrganisationInImageName && - imageRegionPersonInImage == other.imageRegionPersonInImage && - imageRegionRoleIdentifier == other.imageRegionRoleIdentifier && - imageRegionRoleName == other.imageRegionRoleName && - imageSupplierId == other.imageSupplierId && - imageSupplierImageId == other.imageSupplierImageId && - imageSupplierName == other.imageSupplierName && - instructions == other.instructions && - intellectualGenre == other.intellectualGenre && - keywords == other.keywords && - licensorCity == other.licensorCity && - licensorCountry == other.licensorCountry && - licensorEmail == other.licensorEmail && - licensorExtendedAddress == other.licensorExtendedAddress && - licensorId == other.licensorId && - licensorName == other.licensorName && - licensorPostalCode == other.licensorPostalCode && - licensorRegion == other.licensorRegion && - licensorStreetAddress == other.licensorStreetAddress && - licensorTelephone1 == other.licensorTelephone1 && - licensorTelephone2 == other.licensorTelephone2 && - licensorUrl == other.licensorUrl && - linkedEncodedRightsExpr == other.linkedEncodedRightsExpr && - linkedEncodedRightsExprLangId == other.linkedEncodedRightsExprLangId && - linkedEncodedRightsExprType == other.linkedEncodedRightsExprType && - location == other.location && - locationCreatedCity == other.locationCreatedCity && - locationCreatedCountryCode == other.locationCreatedCountryCode && - locationCreatedCountryName == other.locationCreatedCountryName && - locationCreatedGpsAltitude == other.locationCreatedGpsAltitude && - locationCreatedGpsLatitude == other.locationCreatedGpsLatitude && - locationCreatedGpsLongitude == other.locationCreatedGpsLongitude && - locationCreatedLocationId == other.locationCreatedLocationId && - locationCreatedLocationName == other.locationCreatedLocationName && - locationCreatedProvinceState == other.locationCreatedProvinceState && - locationCreatedSublocation == other.locationCreatedSublocation && - locationCreatedWorldRegion == other.locationCreatedWorldRegion && - locationShownCity == other.locationShownCity && - locationShownCountryCode == other.locationShownCountryCode && - locationShownCountryName == other.locationShownCountryName && - locationShownGpsAltitude == other.locationShownGpsAltitude && - locationShownGpsLatitude == other.locationShownGpsLatitude && - locationShownGpsLongitude == other.locationShownGpsLongitude && - locationShownLocationId == other.locationShownLocationId && - locationShownLocationName == other.locationShownLocationName && - locationShownProvinceState == other.locationShownProvinceState && - locationShownSublocation == other.locationShownSublocation && - locationShownWorldRegion == other.locationShownWorldRegion && - maxAvailHeight == other.maxAvailHeight && - maxAvailWidth == other.maxAvailWidth && - modelAge == other.modelAge && - modelReleaseId == other.modelReleaseId && - objectAttributeReference == other.objectAttributeReference && - objectName == other.objectName && - offsetTimeOriginal == other.offsetTimeOriginal && - organisationInImageCode == other.organisationInImageCode && - organisationInImageName == other.organisationInImageName && - orientation == other.orientation && - originalTransmissionReference == other.originalTransmissionReference && - personInImage == other.personInImage && - personInImageCvTermCvId == other.personInImageCvTermCvId && - personInImageCvTermId == other.personInImageCvTermId && - personInImageCvTermName == other.personInImageCvTermName && - personInImageCvTermRefinedAbout == other.personInImageCvTermRefinedAbout && - personInImageDescription == other.personInImageDescription && - personInImageId == other.personInImageId && - personInImageName == other.personInImageName && - productInImageDescription == other.productInImageDescription && - productInImageGtin == other.productInImageGtin && - productInImageName == other.productInImageName && - propertyReleaseId == other.propertyReleaseId && - provinceState == other.provinceState && - rating == other.rating && - registryEntryRole == other.registryEntryRole && - registryItemId == other.registryItemId && - registryOrganisationId == other.registryOrganisationId && - resolutionUnit == other.resolutionUnit && - rights == other.rights && - scene == other.scene && - source == other.source && - specialInstructions == other.specialInstructions && - state == other.state && - subject == other.subject && - subjectCode == other.subjectCode && - subjectReference == other.subjectReference && - sublocation == other.sublocation && - timeCreated == other.timeCreated && - title == other.title && - transmissionReference == other.transmissionReference && - usageTerms == other.usageTerms && - webStatement == other.webStatement && - writer == other.writer && - writerEditor == other.writerEditor && - xResolution == other.xResolution && - yResolution == other.yResolution && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - aboutCvTermCvId, - aboutCvTermId, - aboutCvTermName, - aboutCvTermRefinedAbout, - additionalModelInformation, - applicationRecordVersion, - artist, - artworkCircaDateCreated, - artworkContentDescription, - artworkContributionDescription, - artworkCopyrightNotice, - artworkCopyrightOwnerId, - artworkCopyrightOwnerName, - artworkCreator, - artworkCreatorId, - artworkDateCreated, - artworkLicensorId, - artworkLicensorName, - artworkPhysicalDescription, - artworkSource, - artworkSourceInventoryNo, - artworkSourceInvUrl, - artworkStylePeriod, - artworkTitle, - authorsPosition, - byline, - bylineTitle, - caption, - captionAbstract, - captionWriter, - city, - colorSpace, - componentsConfiguration, - copyright, - copyrightNotice, - copyrightOwnerId, - copyrightOwnerName, - country, - countryCode, - countryPrimaryLocationCode, - countryPrimaryLocationName, - creator, - creatorAddress, - creatorCity, - creatorCountry, - creatorPostalCode, - creatorRegion, - creatorWorkEmail, - creatorWorkTelephone, - creatorWorkUrl, - credit, - dateCreated, - dateTimeCreated, - dateTimeOriginal, - description, - digitalImageGuid, - digitalSourceType, - embeddedEncodedRightsExpr, - embeddedEncodedRightsExprLangId, - embeddedEncodedRightsExprType, - event, - exifVersion, - flashpixVersion, - genreCvId, - genreCvTermId, - genreCvTermName, - genreCvTermRefinedAbout, - headline, - imageCreatorId, - imageCreatorImageId, - imageCreatorName, - imageDescription, - imageRegionBoundaryH, - imageRegionBoundaryRx, - imageRegionBoundaryShape, - imageRegionBoundaryUnit, - imageRegionBoundaryVerticesX, - imageRegionBoundaryVerticesY, - imageRegionBoundaryW, - imageRegionBoundaryX, - imageRegionBoundaryY, - imageRegionCtypeIdentifier, - imageRegionCtypeName, - imageRegionId, - imageRegionName, - imageRegionOrganisationInImageName, - imageRegionPersonInImage, - imageRegionRoleIdentifier, - imageRegionRoleName, - imageSupplierId, - imageSupplierImageId, - imageSupplierName, - instructions, - intellectualGenre, - keywords, - licensorCity, - licensorCountry, - licensorEmail, - licensorExtendedAddress, - licensorId, - licensorName, - licensorPostalCode, - licensorRegion, - licensorStreetAddress, - licensorTelephone1, - licensorTelephone2, - licensorUrl, - linkedEncodedRightsExpr, - linkedEncodedRightsExprLangId, - linkedEncodedRightsExprType, - location, - locationCreatedCity, - locationCreatedCountryCode, - locationCreatedCountryName, - locationCreatedGpsAltitude, - locationCreatedGpsLatitude, - locationCreatedGpsLongitude, - locationCreatedLocationId, - locationCreatedLocationName, - locationCreatedProvinceState, - locationCreatedSublocation, - locationCreatedWorldRegion, - locationShownCity, - locationShownCountryCode, - locationShownCountryName, - locationShownGpsAltitude, - locationShownGpsLatitude, - locationShownGpsLongitude, - locationShownLocationId, - locationShownLocationName, - locationShownProvinceState, - locationShownSublocation, - locationShownWorldRegion, - maxAvailHeight, - maxAvailWidth, - modelAge, - modelReleaseId, - objectAttributeReference, - objectName, - offsetTimeOriginal, - organisationInImageCode, - organisationInImageName, - orientation, - originalTransmissionReference, - personInImage, - personInImageCvTermCvId, - personInImageCvTermId, - personInImageCvTermName, - personInImageCvTermRefinedAbout, - personInImageDescription, - personInImageId, - personInImageName, - productInImageDescription, - productInImageGtin, - productInImageName, - propertyReleaseId, - provinceState, - rating, - registryEntryRole, - registryItemId, - registryOrganisationId, - resolutionUnit, - rights, - scene, - source, - specialInstructions, - state, - subject, - subjectCode, - subjectReference, - sublocation, - timeCreated, - title, - transmissionReference, - usageTerms, - webStatement, - writer, - writerEditor, - xResolution, - yResolution, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmbeddedMetadata{aboutCvTermCvId=$aboutCvTermCvId, aboutCvTermId=$aboutCvTermId, aboutCvTermName=$aboutCvTermName, aboutCvTermRefinedAbout=$aboutCvTermRefinedAbout, additionalModelInformation=$additionalModelInformation, applicationRecordVersion=$applicationRecordVersion, artist=$artist, artworkCircaDateCreated=$artworkCircaDateCreated, artworkContentDescription=$artworkContentDescription, artworkContributionDescription=$artworkContributionDescription, artworkCopyrightNotice=$artworkCopyrightNotice, artworkCopyrightOwnerId=$artworkCopyrightOwnerId, artworkCopyrightOwnerName=$artworkCopyrightOwnerName, artworkCreator=$artworkCreator, artworkCreatorId=$artworkCreatorId, artworkDateCreated=$artworkDateCreated, artworkLicensorId=$artworkLicensorId, artworkLicensorName=$artworkLicensorName, artworkPhysicalDescription=$artworkPhysicalDescription, artworkSource=$artworkSource, artworkSourceInventoryNo=$artworkSourceInventoryNo, artworkSourceInvUrl=$artworkSourceInvUrl, artworkStylePeriod=$artworkStylePeriod, artworkTitle=$artworkTitle, authorsPosition=$authorsPosition, byline=$byline, bylineTitle=$bylineTitle, caption=$caption, captionAbstract=$captionAbstract, captionWriter=$captionWriter, city=$city, colorSpace=$colorSpace, componentsConfiguration=$componentsConfiguration, copyright=$copyright, copyrightNotice=$copyrightNotice, copyrightOwnerId=$copyrightOwnerId, copyrightOwnerName=$copyrightOwnerName, country=$country, countryCode=$countryCode, countryPrimaryLocationCode=$countryPrimaryLocationCode, countryPrimaryLocationName=$countryPrimaryLocationName, creator=$creator, creatorAddress=$creatorAddress, creatorCity=$creatorCity, creatorCountry=$creatorCountry, creatorPostalCode=$creatorPostalCode, creatorRegion=$creatorRegion, creatorWorkEmail=$creatorWorkEmail, creatorWorkTelephone=$creatorWorkTelephone, creatorWorkUrl=$creatorWorkUrl, credit=$credit, dateCreated=$dateCreated, dateTimeCreated=$dateTimeCreated, dateTimeOriginal=$dateTimeOriginal, description=$description, digitalImageGuid=$digitalImageGuid, digitalSourceType=$digitalSourceType, embeddedEncodedRightsExpr=$embeddedEncodedRightsExpr, embeddedEncodedRightsExprLangId=$embeddedEncodedRightsExprLangId, embeddedEncodedRightsExprType=$embeddedEncodedRightsExprType, event=$event, exifVersion=$exifVersion, flashpixVersion=$flashpixVersion, genreCvId=$genreCvId, genreCvTermId=$genreCvTermId, genreCvTermName=$genreCvTermName, genreCvTermRefinedAbout=$genreCvTermRefinedAbout, headline=$headline, imageCreatorId=$imageCreatorId, imageCreatorImageId=$imageCreatorImageId, imageCreatorName=$imageCreatorName, imageDescription=$imageDescription, imageRegionBoundaryH=$imageRegionBoundaryH, imageRegionBoundaryRx=$imageRegionBoundaryRx, imageRegionBoundaryShape=$imageRegionBoundaryShape, imageRegionBoundaryUnit=$imageRegionBoundaryUnit, imageRegionBoundaryVerticesX=$imageRegionBoundaryVerticesX, imageRegionBoundaryVerticesY=$imageRegionBoundaryVerticesY, imageRegionBoundaryW=$imageRegionBoundaryW, imageRegionBoundaryX=$imageRegionBoundaryX, imageRegionBoundaryY=$imageRegionBoundaryY, imageRegionCtypeIdentifier=$imageRegionCtypeIdentifier, imageRegionCtypeName=$imageRegionCtypeName, imageRegionId=$imageRegionId, imageRegionName=$imageRegionName, imageRegionOrganisationInImageName=$imageRegionOrganisationInImageName, imageRegionPersonInImage=$imageRegionPersonInImage, imageRegionRoleIdentifier=$imageRegionRoleIdentifier, imageRegionRoleName=$imageRegionRoleName, imageSupplierId=$imageSupplierId, imageSupplierImageId=$imageSupplierImageId, imageSupplierName=$imageSupplierName, instructions=$instructions, intellectualGenre=$intellectualGenre, keywords=$keywords, licensorCity=$licensorCity, licensorCountry=$licensorCountry, licensorEmail=$licensorEmail, licensorExtendedAddress=$licensorExtendedAddress, licensorId=$licensorId, licensorName=$licensorName, licensorPostalCode=$licensorPostalCode, licensorRegion=$licensorRegion, licensorStreetAddress=$licensorStreetAddress, licensorTelephone1=$licensorTelephone1, licensorTelephone2=$licensorTelephone2, licensorUrl=$licensorUrl, linkedEncodedRightsExpr=$linkedEncodedRightsExpr, linkedEncodedRightsExprLangId=$linkedEncodedRightsExprLangId, linkedEncodedRightsExprType=$linkedEncodedRightsExprType, location=$location, locationCreatedCity=$locationCreatedCity, locationCreatedCountryCode=$locationCreatedCountryCode, locationCreatedCountryName=$locationCreatedCountryName, locationCreatedGpsAltitude=$locationCreatedGpsAltitude, locationCreatedGpsLatitude=$locationCreatedGpsLatitude, locationCreatedGpsLongitude=$locationCreatedGpsLongitude, locationCreatedLocationId=$locationCreatedLocationId, locationCreatedLocationName=$locationCreatedLocationName, locationCreatedProvinceState=$locationCreatedProvinceState, locationCreatedSublocation=$locationCreatedSublocation, locationCreatedWorldRegion=$locationCreatedWorldRegion, locationShownCity=$locationShownCity, locationShownCountryCode=$locationShownCountryCode, locationShownCountryName=$locationShownCountryName, locationShownGpsAltitude=$locationShownGpsAltitude, locationShownGpsLatitude=$locationShownGpsLatitude, locationShownGpsLongitude=$locationShownGpsLongitude, locationShownLocationId=$locationShownLocationId, locationShownLocationName=$locationShownLocationName, locationShownProvinceState=$locationShownProvinceState, locationShownSublocation=$locationShownSublocation, locationShownWorldRegion=$locationShownWorldRegion, maxAvailHeight=$maxAvailHeight, maxAvailWidth=$maxAvailWidth, modelAge=$modelAge, modelReleaseId=$modelReleaseId, objectAttributeReference=$objectAttributeReference, objectName=$objectName, offsetTimeOriginal=$offsetTimeOriginal, organisationInImageCode=$organisationInImageCode, organisationInImageName=$organisationInImageName, orientation=$orientation, originalTransmissionReference=$originalTransmissionReference, personInImage=$personInImage, personInImageCvTermCvId=$personInImageCvTermCvId, personInImageCvTermId=$personInImageCvTermId, personInImageCvTermName=$personInImageCvTermName, personInImageCvTermRefinedAbout=$personInImageCvTermRefinedAbout, personInImageDescription=$personInImageDescription, personInImageId=$personInImageId, personInImageName=$personInImageName, productInImageDescription=$productInImageDescription, productInImageGtin=$productInImageGtin, productInImageName=$productInImageName, propertyReleaseId=$propertyReleaseId, provinceState=$provinceState, rating=$rating, registryEntryRole=$registryEntryRole, registryItemId=$registryItemId, registryOrganisationId=$registryOrganisationId, resolutionUnit=$resolutionUnit, rights=$rights, scene=$scene, source=$source, specialInstructions=$specialInstructions, state=$state, subject=$subject, subjectCode=$subjectCode, subjectReference=$subjectReference, sublocation=$sublocation, timeCreated=$timeCreated, title=$title, transmissionReference=$transmissionReference, usageTerms=$usageTerms, webStatement=$webStatement, writer=$writer, writerEditor=$writerEditor, xResolution=$xResolution, yResolution=$yResolution, 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 awsAutoTagging: JsonField, - private val googleAutoTagging: JsonField, - private val removeBg: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @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(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 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 [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 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 { - awsAutoTagging = extensionStatus.awsAutoTagging - googleAutoTagging = extensionStatus.googleAutoTagging - removeBg = extensionStatus.removeBg - additionalProperties = extensionStatus.additionalProperties.toMutableMap() - } - - 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( - awsAutoTagging, - googleAutoTagging, - removeBg, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ExtensionStatus = apply { - if (validated) { - return@apply - } - - 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 = - (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + - (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + - (removeBg.asKnown().getOrNull()?.validity() ?: 0) - - 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 && - awsAutoTagging == other.awsAutoTagging && - googleAutoTagging == other.googleAutoTagging && - removeBg == other.removeBg && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" - } - - /** - * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the - * upload API response. - */ - 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: ExifDetails) = exif(JsonField.of(exif)) - - /** - * Sets [Builder.exif] to an arbitrary JSON value. - * - * 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 } - - /** 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: ExifImage) = image(JsonField.of(image)) - - /** - * Sets [Builder.image] to an arbitrary JSON value. - * - * You should usually call [Builder.image] with a well-typed [ExifImage] 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) - - 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}" - } - - 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}" - } - - /** 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 FileUploadV2Response && - aiTags == other.aiTags && - audioCodec == other.audioCodec && - bitRate == other.bitRate && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - 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, - 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() = - "FileUploadV2Response{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/Interoperability.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Interoperability.kt deleted file mode 100644 index 8f0420c5..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Interoperability.kt +++ /dev/null @@ -1,201 +0,0 @@ -// 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 - -/** 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}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Thumbnail.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Thumbnail.kt deleted file mode 100644 index cd375b63..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Thumbnail.kt +++ /dev/null @@ -1,359 +0,0 @@ -// 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 - -/** 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}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt index ce23d3e6..c59c5207 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -24,7 +24,7 @@ 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 FileAddTagsParams +class BulkAddTagsParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -74,7 +74,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FileAddTagsParams]. + * Returns a mutable builder for constructing an instance of [BulkAddTagsParams]. * * The following fields are required: * ```java @@ -85,7 +85,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FileAddTagsParams]. */ + /** A builder for [BulkAddTagsParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -93,10 +93,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(fileAddTagsParams: FileAddTagsParams) = apply { - body = fileAddTagsParams.body.toBuilder() - additionalHeaders = fileAddTagsParams.additionalHeaders.toBuilder() - additionalQueryParams = fileAddTagsParams.additionalQueryParams.toBuilder() + internal fun from(bulkAddTagsParams: BulkAddTagsParams) = apply { + body = bulkAddTagsParams.body.toBuilder() + additionalHeaders = bulkAddTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkAddTagsParams.additionalQueryParams.toBuilder() } /** @@ -265,7 +265,7 @@ private constructor( } /** - * Returns an immutable instance of [FileAddTagsParams]. + * Returns an immutable instance of [BulkAddTagsParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -277,8 +277,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileAddTagsParams = - FileAddTagsParams( + fun build(): BulkAddTagsParams = + BulkAddTagsParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -520,7 +520,7 @@ private constructor( return true } - return other is FileAddTagsParams && + return other is BulkAddTagsParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -529,5 +529,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "FileAddTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BulkAddTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt index 14a1888e..2cfbf744 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileAddTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -18,7 +18,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class FileAddTagsResponse +class BulkAddTagsResponse private constructor( private val successfullyUpdatedFileIds: JsonField>, private val additionalProperties: MutableMap, @@ -64,21 +64,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [FileAddTagsResponse]. */ + /** Returns a mutable builder for constructing an instance of [BulkAddTagsResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [FileAddTagsResponse]. */ + /** A builder for [BulkAddTagsResponse]. */ class Builder internal constructor() { private var successfullyUpdatedFileIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileAddTagsResponse: FileAddTagsResponse) = apply { + internal fun from(bulkAddTagsResponse: BulkAddTagsResponse) = apply { successfullyUpdatedFileIds = - fileAddTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } - additionalProperties = fileAddTagsResponse.additionalProperties.toMutableMap() + bulkAddTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = bulkAddTagsResponse.additionalProperties.toMutableMap() } /** An array of fileIds that in which tags were successfully added. */ @@ -130,12 +130,12 @@ private constructor( } /** - * Returns an immutable instance of [FileAddTagsResponse]. + * Returns an immutable instance of [BulkAddTagsResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): FileAddTagsResponse = - FileAddTagsResponse( + fun build(): BulkAddTagsResponse = + BulkAddTagsResponse( (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -143,7 +143,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileAddTagsResponse = apply { + fun validate(): BulkAddTagsResponse = apply { if (validated) { return@apply } @@ -173,7 +173,7 @@ private constructor( return true } - return other is FileAddTagsResponse && + return other is BulkAddTagsResponse && successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && additionalProperties == other.additionalProperties } @@ -185,5 +185,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileAddTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" + "BulkAddTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt index 0c89f9e1..e27e8f49 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.batch +package com.imagekit.api.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -29,7 +29,7 @@ import kotlin.jvm.optionals.getOrNull * * A maximum of 100 files can be deleted at a time. */ -class BatchDeleteParams +class BulkDeleteParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -64,7 +64,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BatchDeleteParams]. + * Returns a mutable builder for constructing an instance of [BulkDeleteParams]. * * The following fields are required: * ```java @@ -74,7 +74,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BatchDeleteParams]. */ + /** A builder for [BulkDeleteParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -82,10 +82,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(batchDeleteParams: BatchDeleteParams) = apply { - body = batchDeleteParams.body.toBuilder() - additionalHeaders = batchDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = batchDeleteParams.additionalQueryParams.toBuilder() + internal fun from(bulkDeleteParams: BulkDeleteParams) = apply { + body = bulkDeleteParams.body.toBuilder() + additionalHeaders = bulkDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkDeleteParams.additionalQueryParams.toBuilder() } /** @@ -234,7 +234,7 @@ private constructor( } /** - * Returns an immutable instance of [BatchDeleteParams]. + * Returns an immutable instance of [BulkDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -245,12 +245,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BatchDeleteParams = - BatchDeleteParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + fun build(): BulkDeleteParams = + BulkDeleteParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } fun _body(): Body = body @@ -438,7 +434,7 @@ private constructor( return true } - return other is BatchDeleteParams && + return other is BulkDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -447,5 +443,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "BatchDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BulkDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt index 6cf1084c..10b9af28 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.batch +package com.imagekit.api.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -18,7 +18,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class BatchDeleteResponse +class BulkDeleteResponse private constructor( private val successfullyDeletedFileIds: JsonField>, private val additionalProperties: MutableMap, @@ -64,21 +64,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [BatchDeleteResponse]. */ + /** Returns a mutable builder for constructing an instance of [BulkDeleteResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BatchDeleteResponse]. */ + /** A builder for [BulkDeleteResponse]. */ class Builder internal constructor() { private var successfullyDeletedFileIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(batchDeleteResponse: BatchDeleteResponse) = apply { + internal fun from(bulkDeleteResponse: BulkDeleteResponse) = apply { successfullyDeletedFileIds = - batchDeleteResponse.successfullyDeletedFileIds.map { it.toMutableList() } - additionalProperties = batchDeleteResponse.additionalProperties.toMutableMap() + bulkDeleteResponse.successfullyDeletedFileIds.map { it.toMutableList() } + additionalProperties = bulkDeleteResponse.additionalProperties.toMutableMap() } /** An array of fileIds that were successfully deleted. */ @@ -130,12 +130,12 @@ private constructor( } /** - * Returns an immutable instance of [BatchDeleteResponse]. + * Returns an immutable instance of [BulkDeleteResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): BatchDeleteResponse = - BatchDeleteResponse( + fun build(): BulkDeleteResponse = + BulkDeleteResponse( (successfullyDeletedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -143,7 +143,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BatchDeleteResponse = apply { + fun validate(): BulkDeleteResponse = apply { if (validated) { return@apply } @@ -173,7 +173,7 @@ private constructor( return true } - return other is BatchDeleteResponse && + return other is BulkDeleteResponse && successfullyDeletedFileIds == other.successfullyDeletedFileIds && additionalProperties == other.additionalProperties } @@ -185,5 +185,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BatchDeleteResponse{successfullyDeletedFileIds=$successfullyDeletedFileIds, additionalProperties=$additionalProperties}" + "BulkDeleteResponse{successfullyDeletedFileIds=$successfullyDeletedFileIds, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt index 2ac2780f..f22a019e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -25,7 +25,7 @@ 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 FileRemoveAiTagsParams +class BulkRemoveAiTagsParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -75,7 +75,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FileRemoveAiTagsParams]. + * Returns a mutable builder for constructing an instance of [BulkRemoveAiTagsParams]. * * The following fields are required: * ```java @@ -86,7 +86,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FileRemoveAiTagsParams]. */ + /** A builder for [BulkRemoveAiTagsParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -94,10 +94,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(fileRemoveAiTagsParams: FileRemoveAiTagsParams) = apply { - body = fileRemoveAiTagsParams.body.toBuilder() - additionalHeaders = fileRemoveAiTagsParams.additionalHeaders.toBuilder() - additionalQueryParams = fileRemoveAiTagsParams.additionalQueryParams.toBuilder() + internal fun from(bulkRemoveAiTagsParams: BulkRemoveAiTagsParams) = apply { + body = bulkRemoveAiTagsParams.body.toBuilder() + additionalHeaders = bulkRemoveAiTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkRemoveAiTagsParams.additionalQueryParams.toBuilder() } /** @@ -266,7 +266,7 @@ private constructor( } /** - * Returns an immutable instance of [FileRemoveAiTagsParams]. + * Returns an immutable instance of [BulkRemoveAiTagsParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -278,8 +278,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileRemoveAiTagsParams = - FileRemoveAiTagsParams( + fun build(): BulkRemoveAiTagsParams = + BulkRemoveAiTagsParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -525,7 +525,7 @@ private constructor( return true } - return other is FileRemoveAiTagsParams && + return other is BulkRemoveAiTagsParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -534,5 +534,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "FileRemoveAiTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BulkRemoveAiTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt index ed7ef4da..9d467351 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -18,7 +18,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class FileRemoveAiTagsResponse +class BulkRemoveAiTagsResponse private constructor( private val successfullyUpdatedFileIds: JsonField>, private val additionalProperties: MutableMap, @@ -64,21 +64,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [FileRemoveAiTagsResponse]. */ + /** Returns a mutable builder for constructing an instance of [BulkRemoveAiTagsResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [FileRemoveAiTagsResponse]. */ + /** A builder for [BulkRemoveAiTagsResponse]. */ class Builder internal constructor() { private var successfullyUpdatedFileIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileRemoveAiTagsResponse: FileRemoveAiTagsResponse) = apply { + internal fun from(bulkRemoveAiTagsResponse: BulkRemoveAiTagsResponse) = apply { successfullyUpdatedFileIds = - fileRemoveAiTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } - additionalProperties = fileRemoveAiTagsResponse.additionalProperties.toMutableMap() + bulkRemoveAiTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = bulkRemoveAiTagsResponse.additionalProperties.toMutableMap() } /** An array of fileIds that in which AITags were successfully removed. */ @@ -130,12 +130,12 @@ private constructor( } /** - * Returns an immutable instance of [FileRemoveAiTagsResponse]. + * Returns an immutable instance of [BulkRemoveAiTagsResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): FileRemoveAiTagsResponse = - FileRemoveAiTagsResponse( + fun build(): BulkRemoveAiTagsResponse = + BulkRemoveAiTagsResponse( (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -143,7 +143,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileRemoveAiTagsResponse = apply { + fun validate(): BulkRemoveAiTagsResponse = apply { if (validated) { return@apply } @@ -173,7 +173,7 @@ private constructor( return true } - return other is FileRemoveAiTagsResponse && + return other is BulkRemoveAiTagsResponse && successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && additionalProperties == other.additionalProperties } @@ -185,5 +185,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileRemoveAiTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" + "BulkRemoveAiTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt index c3b029c8..f72a4520 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -25,7 +25,7 @@ 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 FileRemoveTagsParams +class BulkRemoveTagsParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -75,7 +75,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FileRemoveTagsParams]. + * Returns a mutable builder for constructing an instance of [BulkRemoveTagsParams]. * * The following fields are required: * ```java @@ -86,7 +86,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FileRemoveTagsParams]. */ + /** A builder for [BulkRemoveTagsParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -94,10 +94,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(fileRemoveTagsParams: FileRemoveTagsParams) = apply { - body = fileRemoveTagsParams.body.toBuilder() - additionalHeaders = fileRemoveTagsParams.additionalHeaders.toBuilder() - additionalQueryParams = fileRemoveTagsParams.additionalQueryParams.toBuilder() + internal fun from(bulkRemoveTagsParams: BulkRemoveTagsParams) = apply { + body = bulkRemoveTagsParams.body.toBuilder() + additionalHeaders = bulkRemoveTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkRemoveTagsParams.additionalQueryParams.toBuilder() } /** @@ -266,7 +266,7 @@ private constructor( } /** - * Returns an immutable instance of [FileRemoveTagsParams]. + * Returns an immutable instance of [BulkRemoveTagsParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -278,8 +278,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileRemoveTagsParams = - FileRemoveTagsParams( + fun build(): BulkRemoveTagsParams = + BulkRemoveTagsParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -521,7 +521,7 @@ private constructor( return true } - return other is FileRemoveTagsParams && + return other is BulkRemoveTagsParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -530,5 +530,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "FileRemoveTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "BulkRemoveTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt index 351e603c..0a23ecda 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -18,7 +18,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class FileRemoveTagsResponse +class BulkRemoveTagsResponse private constructor( private val successfullyUpdatedFileIds: JsonField>, private val additionalProperties: MutableMap, @@ -64,21 +64,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [FileRemoveTagsResponse]. */ + /** Returns a mutable builder for constructing an instance of [BulkRemoveTagsResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [FileRemoveTagsResponse]. */ + /** A builder for [BulkRemoveTagsResponse]. */ class Builder internal constructor() { private var successfullyUpdatedFileIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileRemoveTagsResponse: FileRemoveTagsResponse) = apply { + internal fun from(bulkRemoveTagsResponse: BulkRemoveTagsResponse) = apply { successfullyUpdatedFileIds = - fileRemoveTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } - additionalProperties = fileRemoveTagsResponse.additionalProperties.toMutableMap() + bulkRemoveTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = bulkRemoveTagsResponse.additionalProperties.toMutableMap() } /** An array of fileIds that in which tags were successfully removed. */ @@ -130,12 +130,12 @@ private constructor( } /** - * Returns an immutable instance of [FileRemoveTagsResponse]. + * Returns an immutable instance of [BulkRemoveTagsResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): FileRemoveTagsResponse = - FileRemoveTagsResponse( + fun build(): BulkRemoveTagsResponse = + BulkRemoveTagsResponse( (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -143,7 +143,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileRemoveTagsResponse = apply { + fun validate(): BulkRemoveTagsResponse = apply { if (validated) { return@apply } @@ -173,7 +173,7 @@ private constructor( return true } - return other is FileRemoveTagsResponse && + return other is BulkRemoveTagsResponse && successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && additionalProperties == other.additionalProperties } @@ -185,5 +185,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileRemoveTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" + "BulkRemoveTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponse.kt deleted file mode 100644 index 78ed3f2e..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponse.kt +++ /dev/null @@ -1,1353 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.details - -import 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 - -/** Object containing details of a file or file version. */ -class DetailRetrieveResponse -private constructor( - private val aiTags: JsonField>, - private val createdAt: JsonField, - private val customCoordinates: JsonField, - private val customMetadata: JsonValue, - 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: JsonValue = 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, - 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. */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata - - /** - * 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 [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 [DetailRetrieveResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DetailRetrieveResponse]. */ - class Builder internal constructor() { - - private var aiTags: JsonField>? = null - private var createdAt: JsonField = JsonMissing.of() - private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = 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(detailRetrieveResponse: DetailRetrieveResponse) = apply { - aiTags = detailRetrieveResponse.aiTags.map { it.toMutableList() } - createdAt = detailRetrieveResponse.createdAt - customCoordinates = detailRetrieveResponse.customCoordinates - customMetadata = detailRetrieveResponse.customMetadata - fileId = detailRetrieveResponse.fileId - filePath = detailRetrieveResponse.filePath - fileType = detailRetrieveResponse.fileType - hasAlpha = detailRetrieveResponse.hasAlpha - height = detailRetrieveResponse.height - isPrivateFile = detailRetrieveResponse.isPrivateFile - isPublished = detailRetrieveResponse.isPublished - mime = detailRetrieveResponse.mime - name = detailRetrieveResponse.name - size = detailRetrieveResponse.size - tags = detailRetrieveResponse.tags.map { it.toMutableList() } - thumbnail = detailRetrieveResponse.thumbnail - type = detailRetrieveResponse.type - updatedAt = detailRetrieveResponse.updatedAt - url = detailRetrieveResponse.url - versionInfo = detailRetrieveResponse.versionInfo - width = detailRetrieveResponse.width - additionalProperties = detailRetrieveResponse.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: String) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [String] 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: JsonValue) = apply { - this.customMetadata = customMetadata - } - - /** 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: 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 } - - /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ - fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) - - /** - * Sets [Builder.updatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.updatedAt] with a well-typed [String] 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 [DetailRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): DetailRetrieveResponse = - DetailRetrieveResponse( - (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, - createdAt, - customCoordinates, - customMetadata, - 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(): DetailRetrieveResponse = apply { - if (validated) { - return@apply - } - - aiTags().ifPresent { it.forEach { it.validate() } } - createdAt() - customCoordinates() - fileId() - filePath() - fileType() - hasAlpha() - height() - isPrivateFile() - isPublished() - mime() - name() - size() - tags() - thumbnail() - type() - 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) + - (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) + - (if (type.asKnown().isPresent) 1 else 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 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 DetailRetrieveResponse && - aiTags == other.aiTags && - createdAt == other.createdAt && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - 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, - 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() = - "DetailRetrieveResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/metadata/MetadataFromUrlResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponse.kt deleted file mode 100644 index e6b758de..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponse.kt +++ /dev/null @@ -1,1110 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.metadata - -import 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.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.files.ExifDetails -import com.imagekit.api.models.files.ExifImage -import com.imagekit.api.models.files.Gps -import com.imagekit.api.models.files.Interoperability -import com.imagekit.api.models.files.Thumbnail -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** JSON object containing metadata. */ -class MetadataFromUrlResponse -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 [MetadataFromUrlResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MetadataFromUrlResponse]. */ - 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(metadataFromUrlResponse: MetadataFromUrlResponse) = apply { - audioCodec = metadataFromUrlResponse.audioCodec - bitRate = metadataFromUrlResponse.bitRate - density = metadataFromUrlResponse.density - duration = metadataFromUrlResponse.duration - exif = metadataFromUrlResponse.exif - format = metadataFromUrlResponse.format - hasColorProfile = metadataFromUrlResponse.hasColorProfile - hasTransparency = metadataFromUrlResponse.hasTransparency - height = metadataFromUrlResponse.height - pHash = metadataFromUrlResponse.pHash - quality = metadataFromUrlResponse.quality - size = metadataFromUrlResponse.size - videoCodec = metadataFromUrlResponse.videoCodec - width = metadataFromUrlResponse.width - additionalProperties = metadataFromUrlResponse.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 [MetadataFromUrlResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MetadataFromUrlResponse = - MetadataFromUrlResponse( - audioCodec, - bitRate, - density, - duration, - exif, - format, - hasColorProfile, - hasTransparency, - height, - pHash, - quality, - size, - videoCodec, - width, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MetadataFromUrlResponse = 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: ExifDetails) = exif(JsonField.of(exif)) - - /** - * Sets [Builder.exif] to an arbitrary JSON value. - * - * 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 } - - /** 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: ExifImage) = image(JsonField.of(image)) - - /** - * Sets [Builder.image] to an arbitrary JSON value. - * - * You should usually call [Builder.image] with a well-typed [ExifImage] 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) - - 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}" - } - - 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 MetadataFromUrlResponse && - 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() = - "MetadataFromUrlResponse{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/metadata/MetadataFromUrlParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt index 64019c0f..a5131a3d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt @@ -9,7 +9,7 @@ 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 MetadataFromUrlParams +class MetadataGetFromUrlParams private constructor( private val url: String, private val additionalHeaders: Headers, @@ -30,7 +30,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MetadataFromUrlParams]. + * Returns a mutable builder for constructing an instance of [MetadataGetFromUrlParams]. * * The following fields are required: * ```java @@ -40,7 +40,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MetadataFromUrlParams]. */ + /** A builder for [MetadataGetFromUrlParams]. */ class Builder internal constructor() { private var url: String? = null @@ -48,10 +48,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(metadataFromUrlParams: MetadataFromUrlParams) = apply { - url = metadataFromUrlParams.url - additionalHeaders = metadataFromUrlParams.additionalHeaders.toBuilder() - additionalQueryParams = metadataFromUrlParams.additionalQueryParams.toBuilder() + 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. */ @@ -156,7 +156,7 @@ private constructor( } /** - * Returns an immutable instance of [MetadataFromUrlParams]. + * Returns an immutable instance of [MetadataGetFromUrlParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -167,8 +167,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MetadataFromUrlParams = - MetadataFromUrlParams( + fun build(): MetadataGetFromUrlParams = + MetadataGetFromUrlParams( checkRequired("url", url), additionalHeaders.build(), additionalQueryParams.build(), @@ -190,7 +190,7 @@ private constructor( return true } - return other is MetadataFromUrlParams && + return other is MetadataGetFromUrlParams && url == other.url && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -199,5 +199,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(url, additionalHeaders, additionalQueryParams) override fun toString() = - "MetadataFromUrlParams{url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "MetadataGetFromUrlParams{url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt new file mode 100644 index 00000000..c88f4cbd --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt @@ -0,0 +1,3576 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +import 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 MetadataGetFromUrlResponse +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 [MetadataGetFromUrlResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetadataGetFromUrlResponse]. */ + 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(metadataGetFromUrlResponse: MetadataGetFromUrlResponse) = apply { + audioCodec = metadataGetFromUrlResponse.audioCodec + bitRate = metadataGetFromUrlResponse.bitRate + density = metadataGetFromUrlResponse.density + duration = metadataGetFromUrlResponse.duration + exif = metadataGetFromUrlResponse.exif + format = metadataGetFromUrlResponse.format + hasColorProfile = metadataGetFromUrlResponse.hasColorProfile + hasTransparency = metadataGetFromUrlResponse.hasTransparency + height = metadataGetFromUrlResponse.height + pHash = metadataGetFromUrlResponse.pHash + quality = metadataGetFromUrlResponse.quality + size = metadataGetFromUrlResponse.size + videoCodec = metadataGetFromUrlResponse.videoCodec + width = metadataGetFromUrlResponse.width + additionalProperties = metadataGetFromUrlResponse.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 [MetadataGetFromUrlResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetadataGetFromUrlResponse = + MetadataGetFromUrlResponse( + audioCodec, + bitRate, + density, + duration, + exif, + format, + hasColorProfile, + hasTransparency, + height, + pHash, + quality, + size, + videoCodec, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MetadataGetFromUrlResponse = 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 MetadataGetFromUrlResponse && + 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() = + "MetadataGetFromUrlResponse{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/metadata/MetadataRetrieveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt index 1fa9cdcc..cab27ba0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt @@ -16,7 +16,7 @@ import kotlin.jvm.optionals.getOrNull * You can also get the metadata in upload API response by passing `metadata` in `responseFields` * parameter. */ -class MetadataRetrieveParams +class MetadataGetParams private constructor( private val fileId: String?, private val additionalHeaders: Headers, @@ -35,13 +35,13 @@ private constructor( companion object { - @JvmStatic fun none(): MetadataRetrieveParams = builder().build() + @JvmStatic fun none(): MetadataGetParams = builder().build() - /** Returns a mutable builder for constructing an instance of [MetadataRetrieveParams]. */ + /** Returns a mutable builder for constructing an instance of [MetadataGetParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [MetadataRetrieveParams]. */ + /** A builder for [MetadataGetParams]. */ class Builder internal constructor() { private var fileId: String? = null @@ -49,10 +49,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(metadataRetrieveParams: MetadataRetrieveParams) = apply { - fileId = metadataRetrieveParams.fileId - additionalHeaders = metadataRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = metadataRetrieveParams.additionalQueryParams.toBuilder() + 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 } @@ -159,12 +159,12 @@ private constructor( } /** - * Returns an immutable instance of [MetadataRetrieveParams]. + * Returns an immutable instance of [MetadataGetParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): MetadataRetrieveParams = - MetadataRetrieveParams(fileId, additionalHeaders.build(), additionalQueryParams.build()) + fun build(): MetadataGetParams = + MetadataGetParams(fileId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = @@ -182,7 +182,7 @@ private constructor( return true } - return other is MetadataRetrieveParams && + return other is MetadataGetParams && fileId == other.fileId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -191,5 +191,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(fileId, additionalHeaders, additionalQueryParams) override fun toString() = - "MetadataRetrieveParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "MetadataGetParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt new file mode 100644 index 00000000..cca25a2a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt @@ -0,0 +1,3574 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +import 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 MetadataGetResponse +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 [MetadataGetResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetadataGetResponse]. */ + 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(metadataGetResponse: MetadataGetResponse) = apply { + audioCodec = metadataGetResponse.audioCodec + bitRate = metadataGetResponse.bitRate + density = metadataGetResponse.density + duration = metadataGetResponse.duration + exif = metadataGetResponse.exif + format = metadataGetResponse.format + hasColorProfile = metadataGetResponse.hasColorProfile + hasTransparency = metadataGetResponse.hasTransparency + height = metadataGetResponse.height + pHash = metadataGetResponse.pHash + quality = metadataGetResponse.quality + size = metadataGetResponse.size + videoCodec = metadataGetResponse.videoCodec + width = metadataGetResponse.width + additionalProperties = metadataGetResponse.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 [MetadataGetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetadataGetResponse = + MetadataGetResponse( + audioCodec, + bitRate, + density, + duration, + exif, + format, + hasColorProfile, + hasTransparency, + height, + pHash, + quality, + size, + videoCodec, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MetadataGetResponse = 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 MetadataGetResponse && + 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() = + "MetadataGetResponse{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/metadata/MetadataRetrieveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponse.kt deleted file mode 100644 index 9f565b16..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponse.kt +++ /dev/null @@ -1,1110 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.metadata - -import 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.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.files.ExifDetails -import com.imagekit.api.models.files.ExifImage -import com.imagekit.api.models.files.Gps -import com.imagekit.api.models.files.Interoperability -import com.imagekit.api.models.files.Thumbnail -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** JSON object containing metadata. */ -class MetadataRetrieveResponse -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 [MetadataRetrieveResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MetadataRetrieveResponse]. */ - 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(metadataRetrieveResponse: MetadataRetrieveResponse) = apply { - audioCodec = metadataRetrieveResponse.audioCodec - bitRate = metadataRetrieveResponse.bitRate - density = metadataRetrieveResponse.density - duration = metadataRetrieveResponse.duration - exif = metadataRetrieveResponse.exif - format = metadataRetrieveResponse.format - hasColorProfile = metadataRetrieveResponse.hasColorProfile - hasTransparency = metadataRetrieveResponse.hasTransparency - height = metadataRetrieveResponse.height - pHash = metadataRetrieveResponse.pHash - quality = metadataRetrieveResponse.quality - size = metadataRetrieveResponse.size - videoCodec = metadataRetrieveResponse.videoCodec - width = metadataRetrieveResponse.width - additionalProperties = metadataRetrieveResponse.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 [MetadataRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MetadataRetrieveResponse = - MetadataRetrieveResponse( - audioCodec, - bitRate, - density, - duration, - exif, - format, - hasColorProfile, - hasTransparency, - height, - pHash, - quality, - size, - videoCodec, - width, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MetadataRetrieveResponse = 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: ExifDetails) = exif(JsonField.of(exif)) - - /** - * Sets [Builder.exif] to an arbitrary JSON value. - * - * 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 } - - /** 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: ExifImage) = image(JsonField.of(image)) - - /** - * Sets [Builder.image] to an arbitrary JSON value. - * - * You should usually call [Builder.image] with a well-typed [ExifImage] 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) - - 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}" - } - - 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 MetadataRetrieveResponse && - 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() = - "MetadataRetrieveResponse{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/versions/VersionRetrieveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt index 15c717fe..fd71f44e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt @@ -11,7 +11,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** This API returns an object with details or attributes of a file version. */ -class VersionRetrieveParams +class VersionGetParams private constructor( private val fileId: String, private val versionId: String?, @@ -34,7 +34,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VersionRetrieveParams]. + * Returns a mutable builder for constructing an instance of [VersionGetParams]. * * The following fields are required: * ```java @@ -44,7 +44,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VersionRetrieveParams]. */ + /** A builder for [VersionGetParams]. */ class Builder internal constructor() { private var fileId: String? = null @@ -53,11 +53,11 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(versionRetrieveParams: VersionRetrieveParams) = apply { - fileId = versionRetrieveParams.fileId - versionId = versionRetrieveParams.versionId - additionalHeaders = versionRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = versionRetrieveParams.additionalQueryParams.toBuilder() + 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 } @@ -166,7 +166,7 @@ private constructor( } /** - * Returns an immutable instance of [VersionRetrieveParams]. + * Returns an immutable instance of [VersionGetParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -177,8 +177,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VersionRetrieveParams = - VersionRetrieveParams( + fun build(): VersionGetParams = + VersionGetParams( checkRequired("fileId", fileId), versionId, additionalHeaders.build(), @@ -202,7 +202,7 @@ private constructor( return true } - return other is VersionRetrieveParams && + return other is VersionGetParams && fileId == other.fileId && versionId == other.versionId && additionalHeaders == other.additionalHeaders && @@ -213,5 +213,5 @@ private constructor( Objects.hash(fileId, versionId, additionalHeaders, additionalQueryParams) override fun toString() = - "VersionRetrieveParams{fileId=$fileId, versionId=$versionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "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/VersionRetrieveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt index 2335105b..83ea86e0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt @@ -19,7 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Object containing details of a file or file version. */ -class VersionRetrieveResponse +class VersionGetResponse private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, @@ -434,11 +434,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [VersionRetrieveResponse]. */ + /** Returns a mutable builder for constructing an instance of [VersionGetResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [VersionRetrieveResponse]. */ + /** A builder for [VersionGetResponse]. */ class Builder internal constructor() { private var aiTags: JsonField>? = null @@ -465,29 +465,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(versionRetrieveResponse: VersionRetrieveResponse) = apply { - aiTags = versionRetrieveResponse.aiTags.map { it.toMutableList() } - createdAt = versionRetrieveResponse.createdAt - customCoordinates = versionRetrieveResponse.customCoordinates - customMetadata = versionRetrieveResponse.customMetadata - fileId = versionRetrieveResponse.fileId - filePath = versionRetrieveResponse.filePath - fileType = versionRetrieveResponse.fileType - hasAlpha = versionRetrieveResponse.hasAlpha - height = versionRetrieveResponse.height - isPrivateFile = versionRetrieveResponse.isPrivateFile - isPublished = versionRetrieveResponse.isPublished - mime = versionRetrieveResponse.mime - name = versionRetrieveResponse.name - size = versionRetrieveResponse.size - tags = versionRetrieveResponse.tags.map { it.toMutableList() } - thumbnail = versionRetrieveResponse.thumbnail - type = versionRetrieveResponse.type - updatedAt = versionRetrieveResponse.updatedAt - url = versionRetrieveResponse.url - versionInfo = versionRetrieveResponse.versionInfo - width = versionRetrieveResponse.width - additionalProperties = versionRetrieveResponse.additionalProperties.toMutableMap() + internal fun from(versionGetResponse: VersionGetResponse) = apply { + aiTags = versionGetResponse.aiTags.map { it.toMutableList() } + createdAt = versionGetResponse.createdAt + customCoordinates = versionGetResponse.customCoordinates + customMetadata = versionGetResponse.customMetadata + fileId = versionGetResponse.fileId + filePath = versionGetResponse.filePath + fileType = versionGetResponse.fileType + hasAlpha = versionGetResponse.hasAlpha + height = versionGetResponse.height + isPrivateFile = versionGetResponse.isPrivateFile + isPublished = versionGetResponse.isPublished + mime = versionGetResponse.mime + name = versionGetResponse.name + size = versionGetResponse.size + tags = versionGetResponse.tags.map { it.toMutableList() } + thumbnail = versionGetResponse.thumbnail + type = versionGetResponse.type + updatedAt = versionGetResponse.updatedAt + url = versionGetResponse.url + versionInfo = versionGetResponse.versionInfo + width = versionGetResponse.width + additionalProperties = versionGetResponse.additionalProperties.toMutableMap() } /** An array of tags assigned to the file by auto tagging. */ @@ -797,12 +797,12 @@ private constructor( } /** - * Returns an immutable instance of [VersionRetrieveResponse]. + * Returns an immutable instance of [VersionGetResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): VersionRetrieveResponse = - VersionRetrieveResponse( + fun build(): VersionGetResponse = + VersionGetResponse( (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, createdAt, customCoordinates, @@ -830,7 +830,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VersionRetrieveResponse = apply { + fun validate(): VersionGetResponse = apply { if (validated) { return@apply } @@ -1294,7 +1294,7 @@ private constructor( return true } - return other is VersionRetrieveResponse && + return other is VersionGetResponse && aiTags == other.aiTags && createdAt == other.createdAt && customCoordinates == other.customCoordinates && @@ -1349,5 +1349,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VersionRetrieveResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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}" + "VersionGetResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/bulkjobs/BulkJobCopyFolderParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt index 33271fd7..92cb7933 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -25,7 +25,7 @@ import java.util.Optional * 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 BulkJobCopyFolderParams +class FolderCopyParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -93,7 +93,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkJobCopyFolderParams]. + * Returns a mutable builder for constructing an instance of [FolderCopyParams]. * * The following fields are required: * ```java @@ -104,7 +104,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BulkJobCopyFolderParams]. */ + /** A builder for [FolderCopyParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -112,10 +112,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(bulkJobCopyFolderParams: BulkJobCopyFolderParams) = apply { - body = bulkJobCopyFolderParams.body.toBuilder() - additionalHeaders = bulkJobCopyFolderParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkJobCopyFolderParams.additionalQueryParams.toBuilder() + internal fun from(folderCopyParams: FolderCopyParams) = apply { + body = folderCopyParams.body.toBuilder() + additionalHeaders = folderCopyParams.additionalHeaders.toBuilder() + additionalQueryParams = folderCopyParams.additionalQueryParams.toBuilder() } /** @@ -299,7 +299,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkJobCopyFolderParams]. + * Returns an immutable instance of [FolderCopyParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -311,12 +311,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkJobCopyFolderParams = - BulkJobCopyFolderParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + fun build(): FolderCopyParams = + FolderCopyParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } fun _body(): Body = body @@ -596,7 +592,7 @@ private constructor( return true } - return other is BulkJobCopyFolderParams && + return other is FolderCopyParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -605,5 +601,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "BulkJobCopyFolderParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FolderCopyParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt index cc966b42..a6e7fc5f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -15,7 +15,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional -class BulkJobMoveFolderResponse +class FolderCopyResponse private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, @@ -55,22 +55,20 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [BulkJobMoveFolderResponse]. - */ + /** Returns a mutable builder for constructing an instance of [FolderCopyResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkJobMoveFolderResponse]. */ + /** A builder for [FolderCopyResponse]. */ class Builder internal constructor() { private var jobId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkJobMoveFolderResponse: BulkJobMoveFolderResponse) = apply { - jobId = bulkJobMoveFolderResponse.jobId - additionalProperties = bulkJobMoveFolderResponse.additionalProperties.toMutableMap() + internal fun from(folderCopyResponse: FolderCopyResponse) = apply { + jobId = folderCopyResponse.jobId + additionalProperties = folderCopyResponse.additionalProperties.toMutableMap() } /** @@ -106,17 +104,17 @@ private constructor( } /** - * Returns an immutable instance of [BulkJobMoveFolderResponse]. + * Returns an immutable instance of [FolderCopyResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): BulkJobMoveFolderResponse = - BulkJobMoveFolderResponse(jobId, additionalProperties.toMutableMap()) + fun build(): FolderCopyResponse = + FolderCopyResponse(jobId, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): BulkJobMoveFolderResponse = apply { + fun validate(): FolderCopyResponse = apply { if (validated) { return@apply } @@ -145,7 +143,7 @@ private constructor( return true } - return other is BulkJobMoveFolderResponse && + return other is FolderCopyResponse && jobId == other.jobId && additionalProperties == other.additionalProperties } @@ -155,5 +153,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkJobMoveFolderResponse{jobId=$jobId, additionalProperties=$additionalProperties}" + "FolderCopyResponse{jobId=$jobId, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt index 50a36457..3976d1ed 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folder +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt index 7d95b6de..ca1aebd1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folder +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt index fbfff16b..0cdc8516 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folder +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt index 77fe1825..b9d17cd6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folder/FolderDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folder +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt index 6d36fb85..26539737 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -24,7 +24,7 @@ import java.util.Objects * the source file, then the source file and its versions will be appended to the destination file * version history. */ -class BulkJobMoveFolderParams +class FolderMoveParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -75,7 +75,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkJobMoveFolderParams]. + * Returns a mutable builder for constructing an instance of [FolderMoveParams]. * * The following fields are required: * ```java @@ -86,7 +86,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BulkJobMoveFolderParams]. */ + /** A builder for [FolderMoveParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -94,10 +94,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(bulkJobMoveFolderParams: BulkJobMoveFolderParams) = apply { - body = bulkJobMoveFolderParams.body.toBuilder() - additionalHeaders = bulkJobMoveFolderParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkJobMoveFolderParams.additionalQueryParams.toBuilder() + internal fun from(folderMoveParams: FolderMoveParams) = apply { + body = folderMoveParams.body.toBuilder() + additionalHeaders = folderMoveParams.additionalHeaders.toBuilder() + additionalQueryParams = folderMoveParams.additionalQueryParams.toBuilder() } /** @@ -260,7 +260,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkJobMoveFolderParams]. + * Returns an immutable instance of [FolderMoveParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -272,12 +272,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkJobMoveFolderParams = - BulkJobMoveFolderParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + fun build(): FolderMoveParams = + FolderMoveParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } fun _body(): Body = body @@ -508,7 +504,7 @@ private constructor( return true } - return other is BulkJobMoveFolderParams && + return other is FolderMoveParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -517,5 +513,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "BulkJobMoveFolderParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FolderMoveParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt index 177f822d..5a91000a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -15,7 +15,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional -class BulkJobCopyFolderResponse +class FolderMoveResponse private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, @@ -55,22 +55,20 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [BulkJobCopyFolderResponse]. - */ + /** Returns a mutable builder for constructing an instance of [FolderMoveResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkJobCopyFolderResponse]. */ + /** A builder for [FolderMoveResponse]. */ class Builder internal constructor() { private var jobId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkJobCopyFolderResponse: BulkJobCopyFolderResponse) = apply { - jobId = bulkJobCopyFolderResponse.jobId - additionalProperties = bulkJobCopyFolderResponse.additionalProperties.toMutableMap() + internal fun from(folderMoveResponse: FolderMoveResponse) = apply { + jobId = folderMoveResponse.jobId + additionalProperties = folderMoveResponse.additionalProperties.toMutableMap() } /** @@ -106,17 +104,17 @@ private constructor( } /** - * Returns an immutable instance of [BulkJobCopyFolderResponse]. + * Returns an immutable instance of [FolderMoveResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): BulkJobCopyFolderResponse = - BulkJobCopyFolderResponse(jobId, additionalProperties.toMutableMap()) + fun build(): FolderMoveResponse = + FolderMoveResponse(jobId, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): BulkJobCopyFolderResponse = apply { + fun validate(): FolderMoveResponse = apply { if (validated) { return@apply } @@ -145,7 +143,7 @@ private constructor( return true } - return other is BulkJobCopyFolderResponse && + return other is FolderMoveResponse && jobId == other.jobId && additionalProperties == other.additionalProperties } @@ -155,5 +153,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkJobCopyFolderResponse{jobId=$jobId, additionalProperties=$additionalProperties}" + "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/files/Gps.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt similarity index 54% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Gps.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt index 462174ea..8cd255ca 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Gps.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -10,42 +10,36 @@ 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 GPS information. */ -class Gps +class FolderRenameResponse private constructor( - private val gpsVersionId: JsonField>, + private val jobId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("GPSVersionID") - @ExcludeMissing - gpsVersionId: JsonField> = JsonMissing.of() - ) : this(gpsVersionId, mutableMapOf()) + @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 (e.g. if the * server responded with an unexpected value). */ - fun gpsVersionId(): Optional> = gpsVersionId.getOptional("GPSVersionID") + fun jobId(): Optional = jobId.getOptional("jobId") /** - * Returns the raw JSON value of [gpsVersionId]. + * Returns the raw JSON value of [jobId]. * - * Unlike [gpsVersionId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("GPSVersionID") - @ExcludeMissing - fun _gpsVersionId(): JsonField> = gpsVersionId + @JsonProperty("jobId") @ExcludeMissing fun _jobId(): JsonField = jobId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -61,46 +55,34 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Gps]. */ + /** Returns a mutable builder for constructing an instance of [FolderRenameResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Gps]. */ + /** A builder for [FolderRenameResponse]. */ class Builder internal constructor() { - private var gpsVersionId: JsonField>? = null + private var jobId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(gps: Gps) = apply { - gpsVersionId = gps.gpsVersionId.map { it.toMutableList() } - additionalProperties = gps.additionalProperties.toMutableMap() + internal fun from(folderRenameResponse: FolderRenameResponse) = apply { + jobId = folderRenameResponse.jobId + additionalProperties = folderRenameResponse.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. + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. */ - fun gpsVersionId(gpsVersionId: JsonField>) = apply { - this.gpsVersionId = gpsVersionId.map { it.toMutableList() } - } + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) /** - * Adds a single [Long] to [Builder.gpsVersionId]. + * Sets [Builder.jobId] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * 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 addGpsVersionId(gpsVersionId: Long) = apply { - this.gpsVersionId = - (this.gpsVersionId ?: JsonField.of(mutableListOf())).also { - checkKnown("gpsVersionId", it).add(gpsVersionId) - } - } + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -122,25 +104,22 @@ private constructor( } /** - * Returns an immutable instance of [Gps]. + * Returns an immutable instance of [FolderRenameResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Gps = - Gps( - (gpsVersionId ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): FolderRenameResponse = + FolderRenameResponse(jobId, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): Gps = apply { + fun validate(): FolderRenameResponse = apply { if (validated) { return@apply } - gpsVersionId() + jobId() validated = true } @@ -157,22 +136,22 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (gpsVersionId.asKnown().getOrNull()?.size ?: 0) + @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 Gps && - gpsVersionId == other.gpsVersionId && + return other is FolderRenameResponse && + jobId == other.jobId && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(gpsVersionId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Gps{gpsVersionId=$gpsVersionId, additionalProperties=$additionalProperties}" + "FolderRenameResponse{jobId=$jobId, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParams.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt index da3b93de..6e87f9b0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders.job import com.imagekit.api.core.Params import com.imagekit.api.core.http.Headers @@ -10,7 +10,7 @@ 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 BulkJobRetrieveStatusParams +class JobGetParams private constructor( private val jobId: String?, private val additionalHeaders: Headers, @@ -29,15 +29,13 @@ private constructor( companion object { - @JvmStatic fun none(): BulkJobRetrieveStatusParams = builder().build() + @JvmStatic fun none(): JobGetParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of [BulkJobRetrieveStatusParams]. - */ + /** Returns a mutable builder for constructing an instance of [JobGetParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkJobRetrieveStatusParams]. */ + /** A builder for [JobGetParams]. */ class Builder internal constructor() { private var jobId: String? = null @@ -45,10 +43,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(bulkJobRetrieveStatusParams: BulkJobRetrieveStatusParams) = apply { - jobId = bulkJobRetrieveStatusParams.jobId - additionalHeaders = bulkJobRetrieveStatusParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkJobRetrieveStatusParams.additionalQueryParams.toBuilder() + 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 } @@ -155,16 +153,12 @@ private constructor( } /** - * Returns an immutable instance of [BulkJobRetrieveStatusParams]. + * Returns an immutable instance of [JobGetParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): BulkJobRetrieveStatusParams = - BulkJobRetrieveStatusParams( - jobId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) + fun build(): JobGetParams = + JobGetParams(jobId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = @@ -182,7 +176,7 @@ private constructor( return true } - return other is BulkJobRetrieveStatusParams && + return other is JobGetParams && jobId == other.jobId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -191,5 +185,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(jobId, additionalHeaders, additionalQueryParams) override fun toString() = - "BulkJobRetrieveStatusParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "JobGetParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt similarity index 68% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt index 3b098f35..c63515ca 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders.job import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -15,9 +15,10 @@ import java.util.Collections import java.util.Objects import java.util.Optional -class BulkJobRetrieveStatusResponse +class JobGetResponse private constructor( private val jobId: JsonField, + private val purgeRequestId: JsonField, private val status: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, @@ -26,9 +27,12 @@ private constructor( @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, status, type, mutableMapOf()) + ) : this(jobId, purgeRequestId, status, type, mutableMapOf()) /** * Unique identifier of the bulk job. @@ -38,6 +42,15 @@ private constructor( */ 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. Possible values - `Pending`, `Completed`. * @@ -47,7 +60,7 @@ private constructor( fun status(): Optional = status.getOptional("status") /** - * Type of the bulk job. Possible values - `COPY_FOLDER`, `MOVE_FOLDER`. + * Type of the bulk job. Possible values - `COPY_FOLDER`, `MOVE_FOLDER`, `RENAME_FOLDER`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -61,6 +74,15 @@ private constructor( */ @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]. * @@ -89,27 +111,26 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [BulkJobRetrieveStatusResponse]. - */ + /** Returns a mutable builder for constructing an instance of [JobGetResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkJobRetrieveStatusResponse]. */ + /** 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(bulkJobRetrieveStatusResponse: BulkJobRetrieveStatusResponse) = apply { - jobId = bulkJobRetrieveStatusResponse.jobId - status = bulkJobRetrieveStatusResponse.status - type = bulkJobRetrieveStatusResponse.type - additionalProperties = bulkJobRetrieveStatusResponse.additionalProperties.toMutableMap() + 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. */ @@ -123,6 +144,23 @@ private constructor( */ 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. Possible values - `Pending`, `Completed`. */ fun status(status: String) = status(JsonField.of(status)) @@ -134,7 +172,9 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } - /** Type of the bulk job. Possible values - `COPY_FOLDER`, `MOVE_FOLDER`. */ + /** + * Type of the bulk job. Possible values - `COPY_FOLDER`, `MOVE_FOLDER`, `RENAME_FOLDER`. + */ fun type(type: String) = type(JsonField.of(type)) /** @@ -165,22 +205,23 @@ private constructor( } /** - * Returns an immutable instance of [BulkJobRetrieveStatusResponse]. + * Returns an immutable instance of [JobGetResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): BulkJobRetrieveStatusResponse = - BulkJobRetrieveStatusResponse(jobId, status, type, additionalProperties.toMutableMap()) + fun build(): JobGetResponse = + JobGetResponse(jobId, purgeRequestId, status, type, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): BulkJobRetrieveStatusResponse = apply { + fun validate(): JobGetResponse = apply { if (validated) { return@apply } jobId() + purgeRequestId() status() type() validated = true @@ -202,6 +243,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (jobId.asKnown().isPresent) 1 else 0) + + (if (purgeRequestId.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + (if (type.asKnown().isPresent) 1 else 0) @@ -210,17 +252,20 @@ private constructor( return true } - return other is BulkJobRetrieveStatusResponse && + 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, status, type, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(jobId, purgeRequestId, status, type, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "BulkJobRetrieveStatusResponse{jobId=$jobId, status=$status, type=$type, additionalProperties=$additionalProperties}" + "JobGetResponse{jobId=$jobId, purgeRequestId=$purgeRequestId, status=$status, type=$type, 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 index 3bc65d76..b8387b91 100644 --- 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 @@ -3,11 +3,9 @@ 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.accounts.AccountGetUsageParams -import com.imagekit.api.models.accounts.AccountGetUsageResponse -import java.util.concurrent.CompletableFuture +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 { @@ -24,19 +22,11 @@ interface AccountServiceAsync { */ fun withOptions(modifier: Consumer): AccountServiceAsync - /** - * 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 getUsage(params: AccountGetUsageParams): CompletableFuture = - getUsage(params, RequestOptions.none()) + fun usage(): UsageServiceAsync + + fun origins(): OriginServiceAsync - /** @see getUsage */ - fun getUsage( - params: AccountGetUsageParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun urlEndpoints(): UrlEndpointServiceAsync /** * A view of [AccountServiceAsync] that provides access to raw HTTP responses for each method. @@ -52,19 +42,10 @@ interface AccountServiceAsync { modifier: Consumer ): AccountServiceAsync.WithRawResponse - /** - * Returns a raw HTTP response for `get /v1/accounts/usage`, but is otherwise the same as - * [AccountServiceAsync.getUsage]. - */ - fun getUsage( - params: AccountGetUsageParams - ): CompletableFuture> = - getUsage(params, RequestOptions.none()) + fun usage(): UsageServiceAsync.WithRawResponse + + fun origins(): OriginServiceAsync.WithRawResponse - /** @see getUsage */ - fun getUsage( - params: AccountGetUsageParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + 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 index f6234c97..a6322df0 100644 --- 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 @@ -3,20 +3,12 @@ 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.accounts.AccountGetUsageParams -import com.imagekit.api.models.accounts.AccountGetUsageResponse -import java.util.concurrent.CompletableFuture +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) : @@ -26,23 +18,39 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl 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 getUsage( - params: AccountGetUsageParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /v1/accounts/usage - withRawResponse().getUsage(params, requestOptions).thenApply { it.parse() } + 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 errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + 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 @@ -51,34 +59,10 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl clientOptions.toBuilder().apply(modifier::accept).build() ) - private val getUsageHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getUsage( - params: AccountGetUsageParams, - 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 { getUsageHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } + 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/BulkJobServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsync.kt deleted file mode 100644 index 17061158..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsync.kt +++ /dev/null @@ -1,186 +0,0 @@ -// 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.bulkjobs.BulkJobCopyFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobCopyFolderResponse -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderResponse -import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusParams -import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface BulkJobServiceAsync { - - /** - * 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): BulkJobServiceAsync - - /** - * 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 copyFolder(params: BulkJobCopyFolderParams): CompletableFuture = - copyFolder(params, RequestOptions.none()) - - /** @see copyFolder */ - fun copyFolder( - params: BulkJobCopyFolderParams, - 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 moveFolder(params: BulkJobMoveFolderParams): CompletableFuture = - moveFolder(params, RequestOptions.none()) - - /** @see moveFolder */ - fun moveFolder( - params: BulkJobMoveFolderParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** This API returns the status of a bulk job like copy and move folder operations. */ - fun retrieveStatus(jobId: String): CompletableFuture = - retrieveStatus(jobId, BulkJobRetrieveStatusParams.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieveStatus(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), - ): CompletableFuture = - retrieveStatus(jobId, params, RequestOptions.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - params: BulkJobRetrieveStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieveStatus */ - fun retrieveStatus( - params: BulkJobRetrieveStatusParams - ): CompletableFuture = - retrieveStatus(params, RequestOptions.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieveStatus(jobId, BulkJobRetrieveStatusParams.none(), requestOptions) - - /** - * A view of [BulkJobServiceAsync] 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 - ): BulkJobServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same - * as [BulkJobServiceAsync.copyFolder]. - */ - fun copyFolder( - params: BulkJobCopyFolderParams - ): CompletableFuture> = - copyFolder(params, RequestOptions.none()) - - /** @see copyFolder */ - fun copyFolder( - params: BulkJobCopyFolderParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same - * as [BulkJobServiceAsync.moveFolder]. - */ - fun moveFolder( - params: BulkJobMoveFolderParams - ): CompletableFuture> = - moveFolder(params, RequestOptions.none()) - - /** @see moveFolder */ - fun moveFolder( - params: BulkJobMoveFolderParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /v1/bulkJobs/{jobId}`, but is otherwise the same as - * [BulkJobServiceAsync.retrieveStatus]. - */ - fun retrieveStatus( - jobId: String - ): CompletableFuture> = - retrieveStatus(jobId, BulkJobRetrieveStatusParams.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieveStatus(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), - ): CompletableFuture> = - retrieveStatus(jobId, params, RequestOptions.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - params: BulkJobRetrieveStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieveStatus */ - fun retrieveStatus( - params: BulkJobRetrieveStatusParams - ): CompletableFuture> = - retrieveStatus(params, RequestOptions.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieveStatus(jobId, BulkJobRetrieveStatusParams.none(), requestOptions) - } -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncImpl.kt deleted file mode 100644 index dd5389cb..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncImpl.kt +++ /dev/null @@ -1,170 +0,0 @@ -// 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.bulkjobs.BulkJobCopyFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobCopyFolderResponse -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderResponse -import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusParams -import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BulkJobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - BulkJobServiceAsync { - - private val withRawResponse: BulkJobServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BulkJobServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BulkJobServiceAsync = - BulkJobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun copyFolder( - params: BulkJobCopyFolderParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/bulkJobs/copyFolder - withRawResponse().copyFolder(params, requestOptions).thenApply { it.parse() } - - override fun moveFolder( - params: BulkJobMoveFolderParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/bulkJobs/moveFolder - withRawResponse().moveFolder(params, requestOptions).thenApply { it.parse() } - - override fun retrieveStatus( - params: BulkJobRetrieveStatusParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /v1/bulkJobs/{jobId} - withRawResponse().retrieveStatus(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BulkJobServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BulkJobServiceAsync.WithRawResponse = - BulkJobServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val copyFolderHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun copyFolder( - params: BulkJobCopyFolderParams, - 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 { copyFolderHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val moveFolderHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun moveFolder( - params: BulkJobMoveFolderParams, - 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 { moveFolderHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val retrieveStatusHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveStatus( - params: BulkJobRetrieveStatusParams, - 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 { retrieveStatusHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} 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/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index 3a5df469..c0bc8bf4 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 @@ -6,29 +6,21 @@ 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.FileAddTagsParams -import com.imagekit.api.models.files.FileAddTagsResponse 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.FileListParams -import com.imagekit.api.models.files.FileListResponse +import com.imagekit.api.models.files.FileGetParams +import com.imagekit.api.models.files.FileGetResponse import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileMoveResponse -import com.imagekit.api.models.files.FileRemoveAiTagsParams -import com.imagekit.api.models.files.FileRemoveAiTagsResponse -import com.imagekit.api.models.files.FileRemoveTagsParams -import com.imagekit.api.models.files.FileRemoveTagsResponse import com.imagekit.api.models.files.FileRenameParams import com.imagekit.api.models.files.FileRenameResponse -import com.imagekit.api.models.files.FileUploadV1Params -import com.imagekit.api.models.files.FileUploadV1Response -import com.imagekit.api.models.files.FileUploadV2Params -import com.imagekit.api.models.files.FileUploadV2Response -import com.imagekit.api.services.async.files.BatchServiceAsync -import com.imagekit.api.services.async.files.DetailServiceAsync +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.PurgeServiceAsync import com.imagekit.api.services.async.files.VersionServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -47,38 +39,50 @@ interface FileServiceAsync { */ fun withOptions(modifier: Consumer): FileServiceAsync - fun details(): DetailServiceAsync - - fun batch(): BatchServiceAsync + fun bulk(): BulkServiceAsync fun versions(): VersionServiceAsync - fun purge(): PurgeServiceAsync - fun metadata(): MetadataServiceAsync /** - * 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`. + * 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 list(): CompletableFuture> = list(FileListParams.none()) + 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 list */ - fun list( - params: FileListParams = FileListParams.none(), + /** @see update */ + fun update( + params: FileUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture - /** @see list */ - fun list( - params: FileListParams = FileListParams.none() - ): CompletableFuture> = list(params, RequestOptions.none()) + /** @see update */ + fun update(params: FileUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture> = - list(FileListParams.none(), requestOptions) + /** @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. @@ -116,19 +120,6 @@ interface FileServiceAsync { fun delete(fileId: String, requestOptions: RequestOptions): CompletableFuture = delete(fileId, FileDeleteParams.none(), requestOptions) - /** - * This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a - * time. - */ - fun addTags(params: FileAddTagsParams): CompletableFuture = - addTags(params, RequestOptions.none()) - - /** @see addTags */ - fun addTags( - params: FileAddTagsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** * This will copy a file from one folder to another. * @@ -145,6 +136,39 @@ interface FileServiceAsync { 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. * @@ -160,32 +184,6 @@ interface FileServiceAsync { 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: FileRemoveAiTagsParams): CompletableFuture = - removeAiTags(params, RequestOptions.none()) - - /** @see removeAiTags */ - fun removeAiTags( - params: FileRemoveAiTagsParams, - 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: FileRemoveTagsParams): CompletableFuture = - removeTags(params, RequestOptions.none()) - - /** @see removeTags */ - fun removeTags( - params: FileRemoveTagsParams, - 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. @@ -226,45 +224,14 @@ 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 uploadV1(params: FileUploadV1Params): CompletableFuture = - uploadV1(params, RequestOptions.none()) + fun upload(params: FileUploadParams): CompletableFuture = + upload(params, RequestOptions.none()) - /** @see uploadV1 */ - fun uploadV1( - params: FileUploadV1Params, + /** @see upload */ + fun upload( + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * 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 uploadV2(params: FileUploadV2Params): CompletableFuture = - uploadV2(params, RequestOptions.none()) - - /** @see uploadV2 */ - fun uploadV2( - params: FileUploadV2Params, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -276,40 +243,52 @@ interface FileServiceAsync { */ fun withOptions(modifier: Consumer): FileServiceAsync.WithRawResponse - fun details(): DetailServiceAsync.WithRawResponse - - fun batch(): BatchServiceAsync.WithRawResponse + fun bulk(): BulkServiceAsync.WithRawResponse fun versions(): VersionServiceAsync.WithRawResponse - fun purge(): PurgeServiceAsync.WithRawResponse - fun metadata(): MetadataServiceAsync.WithRawResponse /** - * Returns a raw HTTP response for `get /v1/files`, but is otherwise the same as - * [FileServiceAsync.list]. + * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the + * same as [FileServiceAsync.update]. */ - fun list(): CompletableFuture>> = - list(FileListParams.none()) + fun update(fileId: String): CompletableFuture> = + update(fileId, FileUpdateParams.none()) - /** @see list */ - fun list( - params: FileListParams = FileListParams.none(), + /** @see update */ + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + ): CompletableFuture> = + update(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see list */ - fun list( - params: FileListParams = FileListParams.none() - ): CompletableFuture>> = - list(params, RequestOptions.none()) + /** @see update */ + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + ): CompletableFuture> = + update(fileId, params, RequestOptions.none()) - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture>> = - list(FileListParams.none(), requestOptions) + /** @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 @@ -348,21 +327,6 @@ interface FileServiceAsync { requestOptions: RequestOptions, ): CompletableFuture = delete(fileId, FileDeleteParams.none(), requestOptions) - /** - * Returns a raw HTTP response for `post /v1/files/addTags`, but is otherwise the same as - * [FileServiceAsync.addTags]. - */ - fun addTags( - params: FileAddTagsParams - ): CompletableFuture> = - addTags(params, RequestOptions.none()) - - /** @see addTags */ - fun addTags( - params: FileAddTagsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - /** * Returns a raw HTTP response for `post /v1/files/copy`, but is otherwise the same as * [FileServiceAsync.copy]. @@ -376,6 +340,45 @@ interface FileServiceAsync { 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]. @@ -389,36 +392,6 @@ interface FileServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `post /v1/files/removeAITags`, but is otherwise the same - * as [FileServiceAsync.removeAiTags]. - */ - fun removeAiTags( - params: FileRemoveAiTagsParams - ): CompletableFuture> = - removeAiTags(params, RequestOptions.none()) - - /** @see removeAiTags */ - fun removeAiTags( - params: FileRemoveAiTagsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `post /v1/files/removeTags`, but is otherwise the same as - * [FileServiceAsync.removeTags]. - */ - fun removeTags( - params: FileRemoveTagsParams - ): CompletableFuture> = - removeTags(params, RequestOptions.none()) - - /** @see removeTags */ - fun removeTags( - params: FileRemoveTagsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - /** * Returns a raw HTTP response for `put /v1/files/rename`, but is otherwise the same as * [FileServiceAsync.rename]. @@ -436,32 +409,17 @@ interface FileServiceAsync { /** * Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the same as - * [FileServiceAsync.uploadV1]. - */ - fun uploadV1( - params: FileUploadV1Params - ): CompletableFuture> = - uploadV1(params, RequestOptions.none()) - - /** @see uploadV1 */ - fun uploadV1( - params: FileUploadV1Params, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `post /api/v2/files/upload`, but is otherwise the same as - * [FileServiceAsync.uploadV2]. + * [FileServiceAsync.upload]. */ - fun uploadV2( - params: FileUploadV2Params - ): CompletableFuture> = - uploadV2(params, RequestOptions.none()) - - /** @see uploadV2 */ - fun uploadV2( - params: FileUploadV2Params, + fun upload( + params: FileUploadParams + ): CompletableFuture> = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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 a800c132..31626710 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 @@ -18,33 +18,23 @@ 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.FileAddTagsParams -import com.imagekit.api.models.files.FileAddTagsResponse 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.FileListParams -import com.imagekit.api.models.files.FileListResponse +import com.imagekit.api.models.files.FileGetParams +import com.imagekit.api.models.files.FileGetResponse import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileMoveResponse -import com.imagekit.api.models.files.FileRemoveAiTagsParams -import com.imagekit.api.models.files.FileRemoveAiTagsResponse -import com.imagekit.api.models.files.FileRemoveTagsParams -import com.imagekit.api.models.files.FileRemoveTagsResponse import com.imagekit.api.models.files.FileRenameParams import com.imagekit.api.models.files.FileRenameResponse -import com.imagekit.api.models.files.FileUploadV1Params -import com.imagekit.api.models.files.FileUploadV1Response -import com.imagekit.api.models.files.FileUploadV2Params -import com.imagekit.api.models.files.FileUploadV2Response -import com.imagekit.api.services.async.files.BatchServiceAsync -import com.imagekit.api.services.async.files.BatchServiceAsyncImpl -import com.imagekit.api.services.async.files.DetailServiceAsync -import com.imagekit.api.services.async.files.DetailServiceAsyncImpl +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.PurgeServiceAsync -import com.imagekit.api.services.async.files.PurgeServiceAsyncImpl import com.imagekit.api.services.async.files.VersionServiceAsync import com.imagekit.api.services.async.files.VersionServiceAsyncImpl import java.util.concurrent.CompletableFuture @@ -58,14 +48,10 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien WithRawResponseImpl(clientOptions) } - private val details: DetailServiceAsync by lazy { DetailServiceAsyncImpl(clientOptions) } - - private val batch: BatchServiceAsync by lazy { BatchServiceAsyncImpl(clientOptions) } + private val bulk: BulkServiceAsync by lazy { BulkServiceAsyncImpl(clientOptions) } private val versions: VersionServiceAsync by lazy { VersionServiceAsyncImpl(clientOptions) } - private val purge: PurgeServiceAsync by lazy { PurgeServiceAsyncImpl(clientOptions) } - private val metadata: MetadataServiceAsync by lazy { MetadataServiceAsyncImpl(clientOptions) } override fun withRawResponse(): FileServiceAsync.WithRawResponse = withRawResponse @@ -73,22 +59,18 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): FileServiceAsync = FileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun details(): DetailServiceAsync = details - - override fun batch(): BatchServiceAsync = batch + override fun bulk(): BulkServiceAsync = bulk override fun versions(): VersionServiceAsync = versions - override fun purge(): PurgeServiceAsync = purge - override fun metadata(): MetadataServiceAsync = metadata - override fun list( - params: FileListParams, + override fun update( + params: FileUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture> = - // get /v1/files - withRawResponse().list(params, requestOptions).thenApply { it.parse() } + ): CompletableFuture = + // patch /v1/files/{fileId}/details + withRawResponse().update(params, requestOptions).thenApply { it.parse() } override fun delete( params: FileDeleteParams, @@ -97,13 +79,6 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien // delete /v1/files/{fileId} withRawResponse().delete(params, requestOptions).thenAccept {} - override fun addTags( - params: FileAddTagsParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/files/addTags - withRawResponse().addTags(params, requestOptions).thenApply { it.parse() } - override fun copy( params: FileCopyParams, requestOptions: RequestOptions, @@ -111,6 +86,13 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien // 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, @@ -118,20 +100,6 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien // post /v1/files/move withRawResponse().move(params, requestOptions).thenApply { it.parse() } - override fun removeAiTags( - params: FileRemoveAiTagsParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/files/removeAITags - withRawResponse().removeAiTags(params, requestOptions).thenApply { it.parse() } - - override fun removeTags( - params: FileRemoveTagsParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/files/removeTags - withRawResponse().removeTags(params, requestOptions).thenApply { it.parse() } - override fun rename( params: FileRenameParams, requestOptions: RequestOptions, @@ -139,19 +107,12 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien // put /v1/files/rename withRawResponse().rename(params, requestOptions).thenApply { it.parse() } - override fun uploadV1( - params: FileUploadV1Params, + override fun upload( + params: FileUploadParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /api/v1/files/upload - withRawResponse().uploadV1(params, requestOptions).thenApply { it.parse() } - - override fun uploadV2( - params: FileUploadV2Params, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /api/v2/files/upload - withRawResponse().uploadV2(params, requestOptions).thenApply { it.parse() } + withRawResponse().upload(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FileServiceAsync.WithRawResponse { @@ -159,22 +120,14 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - private val details: DetailServiceAsync.WithRawResponse by lazy { - DetailServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val batch: BatchServiceAsync.WithRawResponse by lazy { - BatchServiceAsyncImpl.WithRawResponseImpl(clientOptions) + private val bulk: BulkServiceAsync.WithRawResponse by lazy { + BulkServiceAsyncImpl.WithRawResponseImpl(clientOptions) } private val versions: VersionServiceAsync.WithRawResponse by lazy { VersionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val purge: PurgeServiceAsync.WithRawResponse by lazy { - PurgeServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - private val metadata: MetadataServiceAsync.WithRawResponse by lazy { MetadataServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -186,28 +139,28 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) - override fun details(): DetailServiceAsync.WithRawResponse = details - - override fun batch(): BatchServiceAsync.WithRawResponse = batch + override fun bulk(): BulkServiceAsync.WithRawResponse = bulk override fun versions(): VersionServiceAsync.WithRawResponse = versions - override fun purge(): PurgeServiceAsync.WithRawResponse = purge - override fun metadata(): MetadataServiceAsync.WithRawResponse = metadata - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun list( - params: FileListParams, + override fun update( + params: FileUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.GET) + .method(HttpMethod.PATCH) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files") + .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)) @@ -216,10 +169,10 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { listHandler.handle(it) } + .use { updateHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } + it.validate() } } } @@ -253,37 +206,6 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val addTagsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun addTags( - params: FileAddTagsParams, - 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 copyHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -315,50 +237,21 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val moveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun move( - params: FileMoveParams, + override fun get( + params: FileGetParams, 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 removeAiTagsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun removeAiTags( - params: FileRemoveAiTagsParams, - requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.POST) + .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", "removeAITags") - .body(json(clientOptions.jsonMapper, params._body())) + .addPathSegments("v1", "files", params._pathParam(0), "details") .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -367,7 +260,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { removeAiTagsHandler.handle(it) } + .use { getHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -377,18 +270,18 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val removeTagsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun removeTags( - params: FileRemoveTagsParams, + override fun move( + params: FileMoveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", "removeTags") + .addPathSegments("v1", "files", "move") .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) @@ -398,7 +291,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { removeTagsHandler.handle(it) } + .use { moveHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -439,13 +332,13 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val uploadV1Handler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val uploadHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun uploadV1( - params: FileUploadV1Params, + override fun upload( + params: FileUploadParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -463,41 +356,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { uploadV1Handler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val uploadV2Handler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun uploadV2( - params: FileUploadV2Params, - 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 { uploadV2Handler.handle(it) } + .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 index dadf76b9..aaa08ff2 100644 --- 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 @@ -5,10 +5,17 @@ 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.folder.FolderCreateParams -import com.imagekit.api.models.folder.FolderCreateResponse -import com.imagekit.api.models.folder.FolderDeleteParams -import com.imagekit.api.models.folder.FolderDeleteResponse +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 @@ -26,6 +33,8 @@ interface FolderServiceAsync { */ 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. @@ -52,6 +61,50 @@ interface FolderServiceAsync { 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. */ @@ -66,6 +119,8 @@ interface FolderServiceAsync { 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]. @@ -95,5 +150,46 @@ interface FolderServiceAsync { 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 index db754058..426fe095 100644 --- 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 @@ -15,10 +15,18 @@ 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.folder.FolderCreateParams -import com.imagekit.api.models.folder.FolderCreateResponse -import com.imagekit.api.models.folder.FolderDeleteParams -import com.imagekit.api.models.folder.FolderDeleteResponse +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 @@ -29,11 +37,15 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli 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, @@ -48,12 +60,37 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli // 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 = @@ -61,6 +98,8 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) + override fun job(): JobServiceAsync.WithRawResponse = job + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -122,5 +161,98 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } } + + 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/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..ae63f6e9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt @@ -0,0 +1,314 @@ +// 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.OriginCreateResponse +import com.imagekit.api.models.accounts.origins.OriginDeleteParams +import com.imagekit.api.models.accounts.origins.OriginGetParams +import com.imagekit.api.models.accounts.origins.OriginGetResponse +import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginListResponse +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import com.imagekit.api.models.accounts.origins.OriginUpdateResponse +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..7805e11a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt @@ -0,0 +1,248 @@ +// 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.OriginCreateResponse +import com.imagekit.api.models.accounts.origins.OriginDeleteParams +import com.imagekit.api.models.accounts.origins.OriginGetParams +import com.imagekit.api.models.accounts.origins.OriginGetResponse +import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginListResponse +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import com.imagekit.api.models.accounts.origins.OriginUpdateResponse +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..884b8832 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt @@ -0,0 +1,323 @@ +// 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.UrlEndpointCreateResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateResponse +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..45bf38ac --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt @@ -0,0 +1,248 @@ +// 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.UrlEndpointCreateResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateResponse +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/files/BatchServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt similarity index 61% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt index 617ae04b..60ebeddd 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files +package com.imagekit.api.services.async.accounts import com.imagekit.api.core.ClientOptions import com.imagekit.api.core.RequestOptions @@ -12,59 +12,57 @@ 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.batch.BatchDeleteParams -import com.imagekit.api.models.files.batch.BatchDeleteResponse +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 BatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - BatchServiceAsync { +class UsageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync { - private val withRawResponse: BatchServiceAsync.WithRawResponse by lazy { + private val withRawResponse: UsageServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - override fun withRawResponse(): BatchServiceAsync.WithRawResponse = withRawResponse + override fun withRawResponse(): UsageServiceAsync.WithRawResponse = withRawResponse - override fun withOptions(modifier: Consumer): BatchServiceAsync = - BatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun withOptions(modifier: Consumer): UsageServiceAsync = + UsageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun delete( - params: BatchDeleteParams, + override fun get( + params: UsageGetParams, requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/files/batch/deleteByFileIds - withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + ): CompletableFuture = + // get /v1/accounts/usage + withRawResponse().get(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BatchServiceAsync.WithRawResponse { + UsageServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer - ): BatchServiceAsync.WithRawResponse = - BatchServiceAsyncImpl.WithRawResponseImpl( + ): UsageServiceAsync.WithRawResponse = + UsageServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun delete( - params: BatchDeleteParams, + override fun get( + params: UsageGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() - .method(HttpMethod.POST) + .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", "batch", "deleteByFileIds") - .body(json(clientOptions.jsonMapper, params._body())) + .addPathSegments("v1", "accounts", "usage") .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -73,7 +71,7 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie .thenApply { response -> errorHandler.handle(response).parseable { response - .use { deleteHandler.handle(it) } + .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/files/PurgeServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt similarity index 65% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt index 6f66dba8..d7e41771 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files +package com.imagekit.api.services.async.cache import com.imagekit.api.core.ClientOptions import com.imagekit.api.core.RequestOptions @@ -16,60 +16,60 @@ 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.purge.PurgeExecuteParams -import com.imagekit.api.models.files.purge.PurgeExecuteResponse -import com.imagekit.api.models.files.purge.PurgeStatusParams -import com.imagekit.api.models.files.purge.PurgeStatusResponse +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 PurgeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - PurgeServiceAsync { +class InvalidationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InvalidationServiceAsync { - private val withRawResponse: PurgeServiceAsync.WithRawResponse by lazy { + private val withRawResponse: InvalidationServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - override fun withRawResponse(): PurgeServiceAsync.WithRawResponse = withRawResponse + override fun withRawResponse(): InvalidationServiceAsync.WithRawResponse = withRawResponse - override fun withOptions(modifier: Consumer): PurgeServiceAsync = - PurgeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun withOptions(modifier: Consumer): InvalidationServiceAsync = + InvalidationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun execute( - params: PurgeExecuteParams, + override fun create( + params: InvalidationCreateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/files/purge - withRawResponse().execute(params, requestOptions).thenApply { it.parse() } + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun status( - params: PurgeStatusParams, + override fun get( + params: InvalidationGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/files/purge/{requestId} - withRawResponse().status(params, requestOptions).thenApply { it.parse() } + withRawResponse().get(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - PurgeServiceAsync.WithRawResponse { + InvalidationServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer - ): PurgeServiceAsync.WithRawResponse = - PurgeServiceAsyncImpl.WithRawResponseImpl( + ): InvalidationServiceAsync.WithRawResponse = + InvalidationServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - private val executeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun execute( - params: PurgeExecuteParams, + override fun create( + params: InvalidationCreateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -84,7 +84,7 @@ class PurgeServiceAsyncImpl internal constructor(private val clientOptions: Clie .thenApply { response -> errorHandler.handle(response).parseable { response - .use { executeHandler.handle(it) } + .use { createHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -94,13 +94,13 @@ class PurgeServiceAsyncImpl internal constructor(private val clientOptions: Clie } } - private val statusHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun status( - params: PurgeStatusParams, + override fun get( + params: InvalidationGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("requestId", params.requestId().getOrNull()) @@ -117,7 +117,7 @@ class PurgeServiceAsyncImpl internal constructor(private val clientOptions: Clie .thenApply { response -> errorHandler.handle(response).parseable { response - .use { statusHandler.handle(it) } + .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/BatchServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsync.kt deleted file mode 100644 index 50308eae..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BatchServiceAsync.kt +++ /dev/null @@ -1,72 +0,0 @@ -// 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.batch.BatchDeleteParams -import com.imagekit.api.models.files.batch.BatchDeleteResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface BatchServiceAsync { - - /** - * 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): BatchServiceAsync - - /** - * 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: BatchDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: BatchDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** A view of [BatchServiceAsync] 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 - ): BatchServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/files/batch/deleteByFileIds`, but is otherwise - * the same as [BatchServiceAsync.delete]. - */ - fun delete( - params: BatchDeleteParams - ): CompletableFuture> = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: BatchDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - } -} 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/DetailServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsync.kt deleted file mode 100644 index a1be570f..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsync.kt +++ /dev/null @@ -1,201 +0,0 @@ -// 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.details.DetailRetrieveParams -import com.imagekit.api.models.files.details.DetailRetrieveResponse -import com.imagekit.api.models.files.details.DetailUpdateParams -import com.imagekit.api.models.files.details.DetailUpdateResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface DetailServiceAsync { - - /** - * 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): DetailServiceAsync - - /** - * This API returns an object with details or attributes about the current version of the file. - */ - fun retrieve(fileId: String): CompletableFuture = - retrieve(fileId, DetailRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - fileId: String, - params: DetailRetrieveParams = DetailRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - fileId: String, - params: DetailRetrieveParams = DetailRetrieveParams.none(), - ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: DetailRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: DetailRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - fileId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(fileId, DetailRetrieveParams.none(), requestOptions) - - /** - * 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, DetailUpdateParams.none()) - - /** @see update */ - fun update( - fileId: String, - params: DetailUpdateParams = DetailUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see update */ - fun update( - fileId: String, - params: DetailUpdateParams = DetailUpdateParams.none(), - ): CompletableFuture = update(fileId, params, RequestOptions.none()) - - /** @see update */ - fun update( - params: DetailUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see update */ - fun update(params: DetailUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - fileId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - update(fileId, DetailUpdateParams.none(), requestOptions) - - /** - * A view of [DetailServiceAsync] 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 - ): DetailServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the - * same as [DetailServiceAsync.retrieve]. - */ - fun retrieve(fileId: String): CompletableFuture> = - retrieve(fileId, DetailRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - fileId: String, - params: DetailRetrieveParams = DetailRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - fileId: String, - params: DetailRetrieveParams = DetailRetrieveParams.none(), - ): CompletableFuture> = - retrieve(fileId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: DetailRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: DetailRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - fileId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(fileId, DetailRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the - * same as [DetailServiceAsync.update]. - */ - fun update(fileId: String): CompletableFuture> = - update(fileId, DetailUpdateParams.none()) - - /** @see update */ - fun update( - fileId: String, - params: DetailUpdateParams = DetailUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - update(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see update */ - fun update( - fileId: String, - params: DetailUpdateParams = DetailUpdateParams.none(), - ): CompletableFuture> = - update(fileId, params, RequestOptions.none()) - - /** @see update */ - fun update( - params: DetailUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see update */ - fun update( - params: DetailUpdateParams - ): CompletableFuture> = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - fileId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - update(fileId, DetailUpdateParams.none(), requestOptions) - } -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncImpl.kt deleted file mode 100644 index 26de7ad0..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncImpl.kt +++ /dev/null @@ -1,133 +0,0 @@ -// 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.details.DetailRetrieveParams -import com.imagekit.api.models.files.details.DetailRetrieveResponse -import com.imagekit.api.models.files.details.DetailUpdateParams -import com.imagekit.api.models.files.details.DetailUpdateResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class DetailServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - DetailServiceAsync { - - private val withRawResponse: DetailServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): DetailServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): DetailServiceAsync = - DetailServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: DetailRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /v1/files/{fileId}/details - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: DetailUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // patch /v1/files/{fileId}/details - withRawResponse().update(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DetailServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): DetailServiceAsync.WithRawResponse = - DetailServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: DetailRetrieveParams, - 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 { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: DetailUpdateParams, - 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() - } - } - } - } - } - } -} 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 112ab2d5..4520527f 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 @@ -5,10 +5,10 @@ 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.MetadataFromUrlParams -import com.imagekit.api.models.files.metadata.MetadataFromUrlResponse -import com.imagekit.api.models.files.metadata.MetadataRetrieveParams -import com.imagekit.api.models.files.metadata.MetadataRetrieveResponse +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlResponse +import com.imagekit.api.models.files.metadata.MetadataGetParams +import com.imagekit.api.models.files.metadata.MetadataGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -33,51 +33,52 @@ interface MetadataServiceAsync { * You can also get the metadata in upload API response by passing `metadata` in * `responseFields` parameter. */ - fun retrieve(fileId: String): CompletableFuture = - retrieve(fileId, MetadataRetrieveParams.none()) + fun get(fileId: String): CompletableFuture = + get(fileId, MetadataGetParams.none()) - /** @see retrieve */ - fun retrieve( + /** @see get */ + fun get( fileId: String, - params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + params: MetadataGetParams = MetadataGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + ): CompletableFuture = + get(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see retrieve */ - fun retrieve( + /** @see get */ + fun get( fileId: String, - params: MetadataRetrieveParams = MetadataRetrieveParams.none(), - ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) + params: MetadataGetParams = MetadataGetParams.none(), + ): CompletableFuture = get(fileId, params, RequestOptions.none()) - /** @see retrieve */ - fun retrieve( - params: MetadataRetrieveParams, + /** @see get */ + fun get( + params: MetadataGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture - /** @see retrieve */ - fun retrieve(params: MetadataRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + /** @see get */ + fun get(params: MetadataGetParams): CompletableFuture = + get(params, RequestOptions.none()) - /** @see retrieve */ - fun retrieve( + /** @see get */ + fun get( fileId: String, requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(fileId, MetadataRetrieveParams.none(), requestOptions) + ): CompletableFuture = + get(fileId, MetadataGetParams.none(), requestOptions) /** * Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. */ - fun fromUrl(params: MetadataFromUrlParams): CompletableFuture = - fromUrl(params, RequestOptions.none()) + fun getFromUrl( + params: MetadataGetFromUrlParams + ): CompletableFuture = getFromUrl(params, RequestOptions.none()) - /** @see fromUrl */ - fun fromUrl( - params: MetadataFromUrlParams, + /** @see getFromUrl */ + fun getFromUrl( + params: MetadataGetFromUrlParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [MetadataServiceAsync] that provides access to raw HTTP responses for each method. @@ -95,58 +96,58 @@ interface MetadataServiceAsync { /** * Returns a raw HTTP response for `get /v1/files/{fileId}/metadata`, but is otherwise the - * same as [MetadataServiceAsync.retrieve]. + * same as [MetadataServiceAsync.get]. */ - fun retrieve(fileId: String): CompletableFuture> = - retrieve(fileId, MetadataRetrieveParams.none()) + fun get(fileId: String): CompletableFuture> = + get(fileId, MetadataGetParams.none()) - /** @see retrieve */ - fun retrieve( + /** @see get */ + fun get( fileId: String, - params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + params: MetadataGetParams = MetadataGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + ): CompletableFuture> = + get(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see retrieve */ - fun retrieve( + /** @see get */ + fun get( fileId: String, - params: MetadataRetrieveParams = MetadataRetrieveParams.none(), - ): CompletableFuture> = - retrieve(fileId, params, RequestOptions.none()) + params: MetadataGetParams = MetadataGetParams.none(), + ): CompletableFuture> = + get(fileId, params, RequestOptions.none()) - /** @see retrieve */ - fun retrieve( - params: MetadataRetrieveParams, + /** @see get */ + fun get( + params: MetadataGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> - /** @see retrieve */ - fun retrieve( - params: MetadataRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + /** @see get */ + fun get( + params: MetadataGetParams + ): CompletableFuture> = + get(params, RequestOptions.none()) - /** @see retrieve */ - fun retrieve( + /** @see get */ + fun get( fileId: String, requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(fileId, MetadataRetrieveParams.none(), requestOptions) + ): CompletableFuture> = + get(fileId, MetadataGetParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /v1/files/metadata`, but is otherwise the same as - * [MetadataServiceAsync.fromUrl]. + * [MetadataServiceAsync.getFromUrl]. */ - fun fromUrl( - params: MetadataFromUrlParams - ): CompletableFuture> = - fromUrl(params, RequestOptions.none()) - - /** @see fromUrl */ - fun fromUrl( - params: MetadataFromUrlParams, + fun getFromUrl( + params: MetadataGetFromUrlParams + ): CompletableFuture> = + getFromUrl(params, RequestOptions.none()) + + /** @see getFromUrl */ + fun getFromUrl( + params: MetadataGetFromUrlParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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 index df8ec9d0..5b78f236 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 @@ -15,10 +15,10 @@ 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.MetadataFromUrlParams -import com.imagekit.api.models.files.metadata.MetadataFromUrlResponse -import com.imagekit.api.models.files.metadata.MetadataRetrieveParams -import com.imagekit.api.models.files.metadata.MetadataRetrieveResponse +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlResponse +import com.imagekit.api.models.files.metadata.MetadataGetParams +import com.imagekit.api.models.files.metadata.MetadataGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -35,19 +35,19 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C override fun withOptions(modifier: Consumer): MetadataServiceAsync = MetadataServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun retrieve( - params: MetadataRetrieveParams, + override fun get( + params: MetadataGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/files/{fileId}/metadata - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + withRawResponse().get(params, requestOptions).thenApply { it.parse() } - override fun fromUrl( - params: MetadataFromUrlParams, + override fun getFromUrl( + params: MetadataGetFromUrlParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/files/metadata - withRawResponse().fromUrl(params, requestOptions).thenApply { it.parse() } + withRawResponse().getFromUrl(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : MetadataServiceAsync.WithRawResponse { @@ -62,13 +62,13 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun retrieve( - params: MetadataRetrieveParams, + override fun get( + params: MetadataGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fileId", params.fileId().getOrNull()) @@ -85,7 +85,7 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C .thenApply { response -> errorHandler.handle(response).parseable { response - .use { retrieveHandler.handle(it) } + .use { getHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -95,13 +95,13 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C } } - private val fromUrlHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getFromUrlHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun fromUrl( - params: MetadataFromUrlParams, + override fun getFromUrl( + params: MetadataGetFromUrlParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -115,7 +115,7 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C .thenApply { response -> errorHandler.handle(response).parseable { response - .use { fromUrlHandler.handle(it) } + .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/PurgeServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsync.kt deleted file mode 100644 index 15657738..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsync.kt +++ /dev/null @@ -1,145 +0,0 @@ -// 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.purge.PurgeExecuteParams -import com.imagekit.api.models.files.purge.PurgeExecuteResponse -import com.imagekit.api.models.files.purge.PurgeStatusParams -import com.imagekit.api.models.files.purge.PurgeStatusResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface PurgeServiceAsync { - - /** - * 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): PurgeServiceAsync - - /** - * 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 execute(params: PurgeExecuteParams): CompletableFuture = - execute(params, RequestOptions.none()) - - /** @see execute */ - fun execute( - params: PurgeExecuteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** This API returns the status of a purge cache request. */ - fun status(requestId: String): CompletableFuture = - status(requestId, PurgeStatusParams.none()) - - /** @see status */ - fun status( - requestId: String, - params: PurgeStatusParams = PurgeStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - status(params.toBuilder().requestId(requestId).build(), requestOptions) - - /** @see status */ - fun status( - requestId: String, - params: PurgeStatusParams = PurgeStatusParams.none(), - ): CompletableFuture = status(requestId, params, RequestOptions.none()) - - /** @see status */ - fun status( - params: PurgeStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see status */ - fun status(params: PurgeStatusParams): CompletableFuture = - status(params, RequestOptions.none()) - - /** @see status */ - fun status( - requestId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - status(requestId, PurgeStatusParams.none(), requestOptions) - - /** A view of [PurgeServiceAsync] 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 - ): PurgeServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/files/purge`, but is otherwise the same as - * [PurgeServiceAsync.execute]. - */ - fun execute( - params: PurgeExecuteParams - ): CompletableFuture> = - execute(params, RequestOptions.none()) - - /** @see execute */ - fun execute( - params: PurgeExecuteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /v1/files/purge/{requestId}`, but is otherwise the - * same as [PurgeServiceAsync.status]. - */ - fun status(requestId: String): CompletableFuture> = - status(requestId, PurgeStatusParams.none()) - - /** @see status */ - fun status( - requestId: String, - params: PurgeStatusParams = PurgeStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - status(params.toBuilder().requestId(requestId).build(), requestOptions) - - /** @see status */ - fun status( - requestId: String, - params: PurgeStatusParams = PurgeStatusParams.none(), - ): CompletableFuture> = - status(requestId, params, RequestOptions.none()) - - /** @see status */ - fun status( - params: PurgeStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see status */ - fun status( - params: PurgeStatusParams - ): CompletableFuture> = - status(params, RequestOptions.none()) - - /** @see status */ - fun status( - requestId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - status(requestId, PurgeStatusParams.none(), requestOptions) - } -} 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 index 00c43988..a758ec66 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/com/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -7,12 +7,12 @@ import com.imagekit.api.core.RequestOptions import com.imagekit.api.core.http.HttpResponseFor 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.VersionGetResponse import com.imagekit.api.models.files.versions.VersionListParams import com.imagekit.api.models.files.versions.VersionListResponse import com.imagekit.api.models.files.versions.VersionRestoreParams import com.imagekit.api.models.files.versions.VersionRestoreResponse -import com.imagekit.api.models.files.versions.VersionRetrieveParams -import com.imagekit.api.models.files.versions.VersionRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -30,31 +30,6 @@ interface VersionServiceAsync { */ fun withOptions(modifier: Consumer): VersionServiceAsync - /** This API returns an object with details or attributes of a file version. */ - fun retrieve( - versionId: String, - params: VersionRetrieveParams, - ): CompletableFuture = - retrieve(versionId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - versionId: String, - params: VersionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().versionId(versionId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(params: VersionRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: VersionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** This API returns details of all versions of a file. */ fun list(fileId: String): CompletableFuture> = list(fileId, VersionListParams.none()) @@ -118,6 +93,28 @@ interface VersionServiceAsync { 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, @@ -156,36 +153,6 @@ interface VersionServiceAsync { modifier: Consumer ): VersionServiceAsync.WithRawResponse - /** - * Returns a raw HTTP response for `get /v1/files/{fileId}/versions/{versionId}`, but is - * otherwise the same as [VersionServiceAsync.retrieve]. - */ - fun retrieve( - versionId: String, - params: VersionRetrieveParams, - ): CompletableFuture> = - retrieve(versionId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - versionId: String, - params: VersionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().versionId(versionId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - params: VersionRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: VersionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - /** * Returns a raw HTTP response for `get /v1/files/{fileId}/versions`, but is otherwise the * same as [VersionServiceAsync.list]. @@ -257,6 +224,34 @@ interface VersionServiceAsync { 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]. 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 index 228092a7..31a75208 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/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -18,12 +18,12 @@ import com.imagekit.api.core.http.parseable import com.imagekit.api.core.prepareAsync 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.VersionGetResponse import com.imagekit.api.models.files.versions.VersionListParams import com.imagekit.api.models.files.versions.VersionListResponse import com.imagekit.api.models.files.versions.VersionRestoreParams import com.imagekit.api.models.files.versions.VersionRestoreResponse -import com.imagekit.api.models.files.versions.VersionRetrieveParams -import com.imagekit.api.models.files.versions.VersionRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -40,13 +40,6 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withOptions(modifier: Consumer): VersionServiceAsync = VersionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun retrieve( - params: VersionRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /v1/files/{fileId}/versions/{versionId} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list( params: VersionListParams, requestOptions: RequestOptions, @@ -61,6 +54,13 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl // 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, @@ -81,27 +81,21 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) - override fun retrieve( - params: VersionRetrieveParams, + override fun list( + params: VersionListParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture>> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. - checkRequired("versionId", params.versionId().getOrNull()) + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "v1", - "files", - params._pathParam(0), - "versions", - params._pathParam(1), - ) + .addPathSegments("v1", "files", params._pathParam(0), "versions") .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -110,31 +104,38 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl .thenApply { response -> errorHandler.handle(response).parseable { response - .use { retrieveHandler.handle(it) } + .use { listHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.validate() + it.forEach { it.validate() } } } } } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun list( - params: VersionListParams, + override fun delete( + params: VersionDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. - checkRequired("fileId", params.fileId().getOrNull()) + checkRequired("versionId", params.versionId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.GET) + .method(HttpMethod.DELETE) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", params._pathParam(0), "versions") + .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)) @@ -143,29 +144,29 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl .thenApply { response -> errorHandler.handle(response).parseable { response - .use { listHandler.handle(it) } + .use { deleteHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } + it.validate() } } } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun delete( - params: VersionDeleteParams, + override fun get( + params: VersionGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("versionId", params.versionId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.DELETE) + .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) .addPathSegments( "v1", @@ -174,7 +175,6 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl "versions", params._pathParam(1), ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -183,7 +183,7 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl .thenApply { response -> errorHandler.handle(response).parseable { response - .use { deleteHandler.handle(it) } + .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/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 index 31727751..40a68ccd 100644 --- 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 @@ -2,12 +2,10 @@ 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.accounts.AccountGetUsageParams -import com.imagekit.api.models.accounts.AccountGetUsageResponse +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 { @@ -24,19 +22,11 @@ interface AccountService { */ fun withOptions(modifier: Consumer): AccountService - /** - * 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 getUsage(params: AccountGetUsageParams): AccountGetUsageResponse = - getUsage(params, RequestOptions.none()) + fun usage(): UsageService + + fun origins(): OriginService - /** @see getUsage */ - fun getUsage( - params: AccountGetUsageParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AccountGetUsageResponse + fun urlEndpoints(): UrlEndpointService /** A view of [AccountService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -48,19 +38,10 @@ interface AccountService { */ fun withOptions(modifier: Consumer): AccountService.WithRawResponse - /** - * Returns a raw HTTP response for `get /v1/accounts/usage`, but is otherwise the same as - * [AccountService.getUsage]. - */ - @MustBeClosed - fun getUsage(params: AccountGetUsageParams): HttpResponseFor = - getUsage(params, RequestOptions.none()) + fun usage(): UsageService.WithRawResponse + + fun origins(): OriginService.WithRawResponse - /** @see getUsage */ - @MustBeClosed - fun getUsage( - params: AccountGetUsageParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + 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 index b2130ffd..3f7a4a19 100644 --- 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 @@ -3,19 +3,12 @@ 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.accounts.AccountGetUsageParams -import com.imagekit.api.models.accounts.AccountGetUsageResponse +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) : @@ -25,23 +18,37 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO 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 getUsage( - params: AccountGetUsageParams, - requestOptions: RequestOptions, - ): AccountGetUsageResponse = - // get /v1/accounts/usage - withRawResponse().getUsage(params, requestOptions).parse() + 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 errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + 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 @@ -50,31 +57,10 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO clientOptions.toBuilder().apply(modifier::accept).build() ) - private val getUsageHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getUsage( - params: AccountGetUsageParams, - 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 { getUsageHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + 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/BulkJobService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobService.kt deleted file mode 100644 index 318adbb7..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobService.kt +++ /dev/null @@ -1,185 +0,0 @@ -// 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.bulkjobs.BulkJobCopyFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobCopyFolderResponse -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderResponse -import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusParams -import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusResponse -import java.util.function.Consumer - -interface BulkJobService { - - /** - * 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): BulkJobService - - /** - * 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 copyFolder(params: BulkJobCopyFolderParams): BulkJobCopyFolderResponse = - copyFolder(params, RequestOptions.none()) - - /** @see copyFolder */ - fun copyFolder( - params: BulkJobCopyFolderParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkJobCopyFolderResponse - - /** - * 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 moveFolder(params: BulkJobMoveFolderParams): BulkJobMoveFolderResponse = - moveFolder(params, RequestOptions.none()) - - /** @see moveFolder */ - fun moveFolder( - params: BulkJobMoveFolderParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkJobMoveFolderResponse - - /** This API returns the status of a bulk job like copy and move folder operations. */ - fun retrieveStatus(jobId: String): BulkJobRetrieveStatusResponse = - retrieveStatus(jobId, BulkJobRetrieveStatusParams.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkJobRetrieveStatusResponse = - retrieveStatus(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), - ): BulkJobRetrieveStatusResponse = retrieveStatus(jobId, params, RequestOptions.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - params: BulkJobRetrieveStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkJobRetrieveStatusResponse - - /** @see retrieveStatus */ - fun retrieveStatus(params: BulkJobRetrieveStatusParams): BulkJobRetrieveStatusResponse = - retrieveStatus(params, RequestOptions.none()) - - /** @see retrieveStatus */ - fun retrieveStatus( - jobId: String, - requestOptions: RequestOptions, - ): BulkJobRetrieveStatusResponse = - retrieveStatus(jobId, BulkJobRetrieveStatusParams.none(), requestOptions) - - /** A view of [BulkJobService] 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): BulkJobService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same - * as [BulkJobService.copyFolder]. - */ - @MustBeClosed - fun copyFolder( - params: BulkJobCopyFolderParams - ): HttpResponseFor = copyFolder(params, RequestOptions.none()) - - /** @see copyFolder */ - @MustBeClosed - fun copyFolder( - params: BulkJobCopyFolderParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same - * as [BulkJobService.moveFolder]. - */ - @MustBeClosed - fun moveFolder( - params: BulkJobMoveFolderParams - ): HttpResponseFor = moveFolder(params, RequestOptions.none()) - - /** @see moveFolder */ - @MustBeClosed - fun moveFolder( - params: BulkJobMoveFolderParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /v1/bulkJobs/{jobId}`, but is otherwise the same as - * [BulkJobService.retrieveStatus]. - */ - @MustBeClosed - fun retrieveStatus(jobId: String): HttpResponseFor = - retrieveStatus(jobId, BulkJobRetrieveStatusParams.none()) - - /** @see retrieveStatus */ - @MustBeClosed - fun retrieveStatus( - jobId: String, - params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieveStatus(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveStatus */ - @MustBeClosed - fun retrieveStatus( - jobId: String, - params: BulkJobRetrieveStatusParams = BulkJobRetrieveStatusParams.none(), - ): HttpResponseFor = - retrieveStatus(jobId, params, RequestOptions.none()) - - /** @see retrieveStatus */ - @MustBeClosed - fun retrieveStatus( - params: BulkJobRetrieveStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieveStatus */ - @MustBeClosed - fun retrieveStatus( - params: BulkJobRetrieveStatusParams - ): HttpResponseFor = - retrieveStatus(params, RequestOptions.none()) - - /** @see retrieveStatus */ - @MustBeClosed - fun retrieveStatus( - jobId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieveStatus(jobId, BulkJobRetrieveStatusParams.none(), requestOptions) - } -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobServiceImpl.kt deleted file mode 100644 index 6e8575f1..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BulkJobServiceImpl.kt +++ /dev/null @@ -1,160 +0,0 @@ -// 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.bulkjobs.BulkJobCopyFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobCopyFolderResponse -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderResponse -import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusParams -import com.imagekit.api.models.bulkjobs.BulkJobRetrieveStatusResponse -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BulkJobServiceImpl internal constructor(private val clientOptions: ClientOptions) : - BulkJobService { - - private val withRawResponse: BulkJobService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BulkJobService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BulkJobService = - BulkJobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun copyFolder( - params: BulkJobCopyFolderParams, - requestOptions: RequestOptions, - ): BulkJobCopyFolderResponse = - // post /v1/bulkJobs/copyFolder - withRawResponse().copyFolder(params, requestOptions).parse() - - override fun moveFolder( - params: BulkJobMoveFolderParams, - requestOptions: RequestOptions, - ): BulkJobMoveFolderResponse = - // post /v1/bulkJobs/moveFolder - withRawResponse().moveFolder(params, requestOptions).parse() - - override fun retrieveStatus( - params: BulkJobRetrieveStatusParams, - requestOptions: RequestOptions, - ): BulkJobRetrieveStatusResponse = - // get /v1/bulkJobs/{jobId} - withRawResponse().retrieveStatus(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BulkJobService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BulkJobService.WithRawResponse = - BulkJobServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val copyFolderHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun copyFolder( - params: BulkJobCopyFolderParams, - 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 { copyFolderHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val moveFolderHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun moveFolder( - params: BulkJobMoveFolderParams, - 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 { moveFolderHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveStatusHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveStatus( - params: BulkJobRetrieveStatusParams, - 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 { retrieveStatusHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} 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/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt index f9ec8ef0..d4b2ff80 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 @@ -7,29 +7,21 @@ 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.FileAddTagsParams -import com.imagekit.api.models.files.FileAddTagsResponse 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.FileListParams -import com.imagekit.api.models.files.FileListResponse +import com.imagekit.api.models.files.FileGetParams +import com.imagekit.api.models.files.FileGetResponse import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileMoveResponse -import com.imagekit.api.models.files.FileRemoveAiTagsParams -import com.imagekit.api.models.files.FileRemoveAiTagsResponse -import com.imagekit.api.models.files.FileRemoveTagsParams -import com.imagekit.api.models.files.FileRemoveTagsResponse import com.imagekit.api.models.files.FileRenameParams import com.imagekit.api.models.files.FileRenameResponse -import com.imagekit.api.models.files.FileUploadV1Params -import com.imagekit.api.models.files.FileUploadV1Response -import com.imagekit.api.models.files.FileUploadV2Params -import com.imagekit.api.models.files.FileUploadV2Response -import com.imagekit.api.services.blocking.files.BatchService -import com.imagekit.api.services.blocking.files.DetailService +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.PurgeService import com.imagekit.api.services.blocking.files.VersionService import java.util.function.Consumer @@ -47,37 +39,44 @@ interface FileService { */ fun withOptions(modifier: Consumer): FileService - fun details(): DetailService - - fun batch(): BatchService + fun bulk(): BulkService fun versions(): VersionService - fun purge(): PurgeService - fun metadata(): MetadataService /** - * 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`. + * 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 list(): List = list(FileListParams.none()) + 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 list */ - fun list( - params: FileListParams = FileListParams.none(), + /** @see update */ + fun update( + params: FileUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): List + ): FileUpdateResponse - /** @see list */ - fun list(params: FileListParams = FileListParams.none()): List = - list(params, RequestOptions.none()) + /** @see update */ + fun update(params: FileUpdateParams): FileUpdateResponse = update(params, RequestOptions.none()) - /** @see list */ - fun list(requestOptions: RequestOptions): List = - list(FileListParams.none(), requestOptions) + /** @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. @@ -109,19 +108,6 @@ interface FileService { fun delete(fileId: String, requestOptions: RequestOptions) = delete(fileId, FileDeleteParams.none(), requestOptions) - /** - * This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a - * time. - */ - fun addTags(params: FileAddTagsParams): FileAddTagsResponse = - addTags(params, RequestOptions.none()) - - /** @see addTags */ - fun addTags( - params: FileAddTagsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FileAddTagsResponse - /** * This will copy a file from one folder to another. * @@ -137,6 +123,35 @@ interface FileService { 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): FileGetResponse = get(fileId, FileGetParams.none()) + + /** @see get */ + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FileGetResponse = get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + fun get(fileId: String, params: FileGetParams = FileGetParams.none()): FileGetResponse = + get(fileId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: FileGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileGetResponse + + /** @see get */ + fun get(params: FileGetParams): FileGetResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get(fileId: String, requestOptions: RequestOptions): FileGetResponse = + get(fileId, FileGetParams.none(), requestOptions) + /** * This will move a file and all its versions from one folder to another. * @@ -151,32 +166,6 @@ interface FileService { requestOptions: RequestOptions = RequestOptions.none(), ): FileMoveResponse - /** - * This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified - * at a time. - */ - fun removeAiTags(params: FileRemoveAiTagsParams): FileRemoveAiTagsResponse = - removeAiTags(params, RequestOptions.none()) - - /** @see removeAiTags */ - fun removeAiTags( - params: FileRemoveAiTagsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FileRemoveAiTagsResponse - - /** - * This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at - * a time. - */ - fun removeTags(params: FileRemoveTagsParams): FileRemoveTagsResponse = - removeTags(params, RequestOptions.none()) - - /** @see removeTags */ - fun removeTags( - params: FileRemoveTagsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FileRemoveTagsResponse - /** * 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. @@ -216,45 +205,13 @@ 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 uploadV1(params: FileUploadV1Params): FileUploadV1Response = - uploadV1(params, RequestOptions.none()) - - /** @see uploadV1 */ - fun uploadV1( - params: FileUploadV1Params, - requestOptions: RequestOptions = RequestOptions.none(), - ): FileUploadV1Response - - /** - * 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 uploadV2(params: FileUploadV2Params): FileUploadV2Response = - uploadV2(params, RequestOptions.none()) + fun upload(params: FileUploadParams): FileUploadResponse = upload(params, RequestOptions.none()) - /** @see uploadV2 */ - fun uploadV2( - params: FileUploadV2Params, + /** @see upload */ + fun upload( + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), - ): FileUploadV2Response + ): FileUploadResponse /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -266,40 +223,55 @@ interface FileService { */ fun withOptions(modifier: Consumer): FileService.WithRawResponse - fun details(): DetailService.WithRawResponse - - fun batch(): BatchService.WithRawResponse + fun bulk(): BulkService.WithRawResponse fun versions(): VersionService.WithRawResponse - fun purge(): PurgeService.WithRawResponse - fun metadata(): MetadataService.WithRawResponse /** - * Returns a raw HTTP response for `get /v1/files`, but is otherwise the same as - * [FileService.list]. + * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the + * same as [FileService.update]. */ @MustBeClosed - fun list(): HttpResponseFor> = list(FileListParams.none()) + fun update(fileId: String): HttpResponseFor = + update(fileId, FileUpdateParams.none()) - /** @see list */ + /** @see update */ @MustBeClosed - fun list( - params: FileListParams = FileListParams.none(), + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + ): HttpResponseFor = + update(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see list */ + /** @see update */ @MustBeClosed - fun list( - params: FileListParams = FileListParams.none() - ): HttpResponseFor> = list(params, RequestOptions.none()) + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + ): HttpResponseFor = update(fileId, params, RequestOptions.none()) - /** @see list */ + /** @see update */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor> = - list(FileListParams.none(), requestOptions) + 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 @@ -339,21 +311,6 @@ interface FileService { fun delete(fileId: String, requestOptions: RequestOptions): HttpResponse = delete(fileId, FileDeleteParams.none(), requestOptions) - /** - * Returns a raw HTTP response for `post /v1/files/addTags`, but is otherwise the same as - * [FileService.addTags]. - */ - @MustBeClosed - fun addTags(params: FileAddTagsParams): HttpResponseFor = - addTags(params, RequestOptions.none()) - - /** @see addTags */ - @MustBeClosed - fun addTags( - params: FileAddTagsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - /** * Returns a raw HTTP response for `post /v1/files/copy`, but is otherwise the same as * [FileService.copy]. @@ -370,50 +327,60 @@ interface FileService { ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/files/move`, but is otherwise the same as - * [FileService.move]. + * Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the + * same as [FileService.get]. */ @MustBeClosed - fun move(params: FileMoveParams): HttpResponseFor = - move(params, RequestOptions.none()) + fun get(fileId: String): HttpResponseFor = + get(fileId, FileGetParams.none()) - /** @see move */ + /** @see get */ @MustBeClosed - fun move( - params: FileMoveParams, + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor = + get(params.toBuilder().fileId(fileId).build(), requestOptions) - /** - * Returns a raw HTTP response for `post /v1/files/removeAITags`, but is otherwise the same - * as [FileService.removeAiTags]. - */ + /** @see get */ @MustBeClosed - fun removeAiTags( - params: FileRemoveAiTagsParams - ): HttpResponseFor = removeAiTags(params, RequestOptions.none()) + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), + ): HttpResponseFor = get(fileId, params, RequestOptions.none()) - /** @see removeAiTags */ + /** @see get */ @MustBeClosed - fun removeAiTags( - params: FileRemoveAiTagsParams, + fun get( + params: FileGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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/removeTags`, but is otherwise the same as - * [FileService.removeTags]. + * Returns a raw HTTP response for `post /v1/files/move`, but is otherwise the same as + * [FileService.move]. */ @MustBeClosed - fun removeTags(params: FileRemoveTagsParams): HttpResponseFor = - removeTags(params, RequestOptions.none()) + fun move(params: FileMoveParams): HttpResponseFor = + move(params, RequestOptions.none()) - /** @see removeTags */ + /** @see move */ @MustBeClosed - fun removeTags( - params: FileRemoveTagsParams, + fun move( + params: FileMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/files/rename`, but is otherwise the same as @@ -432,32 +399,17 @@ interface FileService { /** * Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the same as - * [FileService.uploadV1]. - */ - @MustBeClosed - fun uploadV1(params: FileUploadV1Params): HttpResponseFor = - uploadV1(params, RequestOptions.none()) - - /** @see uploadV1 */ - @MustBeClosed - fun uploadV1( - params: FileUploadV1Params, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `post /api/v2/files/upload`, but is otherwise the same as - * [FileService.uploadV2]. + * [FileService.upload]. */ @MustBeClosed - fun uploadV2(params: FileUploadV2Params): HttpResponseFor = - uploadV2(params, RequestOptions.none()) + fun upload(params: FileUploadParams): HttpResponseFor = + upload(params, RequestOptions.none()) - /** @see uploadV2 */ + /** @see upload */ @MustBeClosed - fun uploadV2( - params: FileUploadV2Params, + fun upload( + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 index 8aea71f0..80924dcf 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 @@ -18,33 +18,23 @@ 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.FileAddTagsParams -import com.imagekit.api.models.files.FileAddTagsResponse 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.FileListParams -import com.imagekit.api.models.files.FileListResponse +import com.imagekit.api.models.files.FileGetParams +import com.imagekit.api.models.files.FileGetResponse import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileMoveResponse -import com.imagekit.api.models.files.FileRemoveAiTagsParams -import com.imagekit.api.models.files.FileRemoveAiTagsResponse -import com.imagekit.api.models.files.FileRemoveTagsParams -import com.imagekit.api.models.files.FileRemoveTagsResponse import com.imagekit.api.models.files.FileRenameParams import com.imagekit.api.models.files.FileRenameResponse -import com.imagekit.api.models.files.FileUploadV1Params -import com.imagekit.api.models.files.FileUploadV1Response -import com.imagekit.api.models.files.FileUploadV2Params -import com.imagekit.api.models.files.FileUploadV2Response -import com.imagekit.api.services.blocking.files.BatchService -import com.imagekit.api.services.blocking.files.BatchServiceImpl -import com.imagekit.api.services.blocking.files.DetailService -import com.imagekit.api.services.blocking.files.DetailServiceImpl +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.PurgeService -import com.imagekit.api.services.blocking.files.PurgeServiceImpl import com.imagekit.api.services.blocking.files.VersionService import com.imagekit.api.services.blocking.files.VersionServiceImpl import java.util.function.Consumer @@ -56,14 +46,10 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti WithRawResponseImpl(clientOptions) } - private val details: DetailService by lazy { DetailServiceImpl(clientOptions) } - - private val batch: BatchService by lazy { BatchServiceImpl(clientOptions) } + private val bulk: BulkService by lazy { BulkServiceImpl(clientOptions) } private val versions: VersionService by lazy { VersionServiceImpl(clientOptions) } - private val purge: PurgeService by lazy { PurgeServiceImpl(clientOptions) } - private val metadata: MetadataService by lazy { MetadataServiceImpl(clientOptions) } override fun withRawResponse(): FileService.WithRawResponse = withRawResponse @@ -71,57 +57,36 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): FileService = FileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun details(): DetailService = details - - override fun batch(): BatchService = batch + override fun bulk(): BulkService = bulk override fun versions(): VersionService = versions - override fun purge(): PurgeService = purge - override fun metadata(): MetadataService = metadata - override fun list( - params: FileListParams, + override fun update( + params: FileUpdateParams, requestOptions: RequestOptions, - ): List = - // get /v1/files - withRawResponse().list(params, requestOptions).parse() + ): 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 addTags( - params: FileAddTagsParams, - requestOptions: RequestOptions, - ): FileAddTagsResponse = - // post /v1/files/addTags - withRawResponse().addTags(params, requestOptions).parse() - override fun copy(params: FileCopyParams, requestOptions: RequestOptions): FileCopyResponse = // post /v1/files/copy withRawResponse().copy(params, requestOptions).parse() + override fun get(params: FileGetParams, requestOptions: RequestOptions): FileGetResponse = + // 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 removeAiTags( - params: FileRemoveAiTagsParams, - requestOptions: RequestOptions, - ): FileRemoveAiTagsResponse = - // post /v1/files/removeAITags - withRawResponse().removeAiTags(params, requestOptions).parse() - - override fun removeTags( - params: FileRemoveTagsParams, - requestOptions: RequestOptions, - ): FileRemoveTagsResponse = - // post /v1/files/removeTags - withRawResponse().removeTags(params, requestOptions).parse() - override fun rename( params: FileRenameParams, requestOptions: RequestOptions, @@ -129,19 +94,12 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti // put /v1/files/rename withRawResponse().rename(params, requestOptions).parse() - override fun uploadV1( - params: FileUploadV1Params, + override fun upload( + params: FileUploadParams, requestOptions: RequestOptions, - ): FileUploadV1Response = + ): FileUploadResponse = // post /api/v1/files/upload - withRawResponse().uploadV1(params, requestOptions).parse() - - override fun uploadV2( - params: FileUploadV2Params, - requestOptions: RequestOptions, - ): FileUploadV2Response = - // post /api/v2/files/upload - withRawResponse().uploadV2(params, requestOptions).parse() + withRawResponse().upload(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FileService.WithRawResponse { @@ -149,22 +107,14 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - private val details: DetailService.WithRawResponse by lazy { - DetailServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val batch: BatchService.WithRawResponse by lazy { - BatchServiceImpl.WithRawResponseImpl(clientOptions) + private val bulk: BulkService.WithRawResponse by lazy { + BulkServiceImpl.WithRawResponseImpl(clientOptions) } private val versions: VersionService.WithRawResponse by lazy { VersionServiceImpl.WithRawResponseImpl(clientOptions) } - private val purge: PurgeService.WithRawResponse by lazy { - PurgeServiceImpl.WithRawResponseImpl(clientOptions) - } - private val metadata: MetadataService.WithRawResponse by lazy { MetadataServiceImpl.WithRawResponseImpl(clientOptions) } @@ -176,38 +126,38 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) - override fun details(): DetailService.WithRawResponse = details - - override fun batch(): BatchService.WithRawResponse = batch + override fun bulk(): BulkService.WithRawResponse = bulk override fun versions(): VersionService.WithRawResponse = versions - override fun purge(): PurgeService.WithRawResponse = purge - override fun metadata(): MetadataService.WithRawResponse = metadata - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun list( - params: FileListParams, + override fun update( + params: FileUpdateParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.GET) + .method(HttpMethod.PATCH) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files") + .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 { listHandler.handle(it) } + .use { updateHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } + it.validate() } } } @@ -237,34 +187,6 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val addTagsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun addTags( - params: FileAddTagsParams, - 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 copyHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -293,54 +215,28 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val moveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun move( - params: FileMoveParams, + override fun get( + params: FileGetParams, 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 removeAiTagsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun removeAiTags( - params: FileRemoveAiTagsParams, - requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.POST) + .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", "removeAITags") - .body(json(clientOptions.jsonMapper, params._body())) + .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 { removeAiTagsHandler.handle(it) } + .use { getHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -349,18 +245,18 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val removeTagsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun removeTags( - params: FileRemoveTagsParams, + override fun move( + params: FileMoveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", "removeTags") + .addPathSegments("v1", "files", "move") .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) @@ -368,7 +264,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { removeTagsHandler.handle(it) } + .use { moveHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -405,13 +301,13 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val uploadV1Handler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val uploadHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun uploadV1( - params: FileUploadV1Params, + override fun upload( + params: FileUploadParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -427,38 +323,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { uploadV1Handler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val uploadV2Handler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun uploadV2( - params: FileUploadV2Params, - 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 { uploadV2Handler.handle(it) } + .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 index e5c54540..e38020e4 100644 --- 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 @@ -6,10 +6,17 @@ 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.folder.FolderCreateParams -import com.imagekit.api.models.folder.FolderCreateResponse -import com.imagekit.api.models.folder.FolderDeleteParams -import com.imagekit.api.models.folder.FolderDeleteResponse +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 { @@ -26,6 +33,8 @@ interface FolderService { */ 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. @@ -52,6 +61,48 @@ interface FolderService { 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 { @@ -62,6 +113,8 @@ interface FolderService { */ 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]. @@ -91,5 +144,50 @@ interface FolderService { 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 index 01f450b9..42a20bf2 100644 --- 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 @@ -15,10 +15,18 @@ 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.folder.FolderCreateParams -import com.imagekit.api.models.folder.FolderCreateResponse -import com.imagekit.api.models.folder.FolderDeleteParams -import com.imagekit.api.models.folder.FolderDeleteResponse +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) : @@ -28,11 +36,15 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp 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, @@ -47,12 +59,37 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp // 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 = @@ -60,6 +97,8 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) + override fun job(): JobService.WithRawResponse = job + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -115,5 +154,89 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } } + + 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/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..dd3048a9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt @@ -0,0 +1,301 @@ +// 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.OriginCreateResponse +import com.imagekit.api.models.accounts.origins.OriginDeleteParams +import com.imagekit.api.models.accounts.origins.OriginGetParams +import com.imagekit.api.models.accounts.origins.OriginGetResponse +import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginListResponse +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import com.imagekit.api.models.accounts.origins.OriginUpdateResponse +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): OriginCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OriginCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginCreateResponse + + /** + * **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): OriginUpdateResponse = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginUpdateResponse = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: OriginUpdateParams): OriginUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginUpdateResponse + + /** + * **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): OriginGetResponse = get(id, OriginGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: OriginGetParams = OriginGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginGetResponse = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get(id: String, params: OriginGetParams = OriginGetParams.none()): OriginGetResponse = + get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: OriginGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginGetResponse + + /** @see get */ + fun get(params: OriginGetParams): OriginGetResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): OriginGetResponse = + 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..5ddd229a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.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.origins.OriginCreateParams +import com.imagekit.api.models.accounts.origins.OriginCreateResponse +import com.imagekit.api.models.accounts.origins.OriginDeleteParams +import com.imagekit.api.models.accounts.origins.OriginGetParams +import com.imagekit.api.models.accounts.origins.OriginGetResponse +import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginListResponse +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import com.imagekit.api.models.accounts.origins.OriginUpdateResponse +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, + ): OriginCreateResponse = + // post /v1/accounts/origins + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: OriginUpdateParams, + requestOptions: RequestOptions, + ): OriginUpdateResponse = + // 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): OriginGetResponse = + // 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..56d86643 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt @@ -0,0 +1,322 @@ +// 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.UrlEndpointCreateResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateResponse +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): UrlEndpointCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointCreateResponse + + /** + * **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): UrlEndpointUpdateResponse = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointUpdateResponse = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: UrlEndpointUpdateParams): UrlEndpointUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointUpdateResponse + + /** + * **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): UrlEndpointGetResponse = get(id, UrlEndpointGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointGetResponse = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + ): UrlEndpointGetResponse = get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UrlEndpointGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointGetResponse + + /** @see get */ + fun get(params: UrlEndpointGetParams): UrlEndpointGetResponse = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): UrlEndpointGetResponse = + 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..6c52c43e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt @@ -0,0 +1,230 @@ +// 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.UrlEndpointCreateResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateResponse +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, + ): UrlEndpointCreateResponse = + // post /v1/accounts/url-endpoints + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions, + ): UrlEndpointUpdateResponse = + // 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, + ): UrlEndpointGetResponse = + // 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/files/BatchServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt similarity index 58% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt index 262953be..e9884d20 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package com.imagekit.api.services.blocking.accounts import com.imagekit.api.core.ClientOptions import com.imagekit.api.core.RequestOptions @@ -12,65 +12,60 @@ 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.batch.BatchDeleteParams -import com.imagekit.api.models.files.batch.BatchDeleteResponse +import com.imagekit.api.models.accounts.usage.UsageGetParams +import com.imagekit.api.models.accounts.usage.UsageGetResponse import java.util.function.Consumer -class BatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : - BatchService { +class UsageServiceImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService { - private val withRawResponse: BatchService.WithRawResponse by lazy { + private val withRawResponse: UsageService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - override fun withRawResponse(): BatchService.WithRawResponse = withRawResponse + override fun withRawResponse(): UsageService.WithRawResponse = withRawResponse - override fun withOptions(modifier: Consumer): BatchService = - BatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun withOptions(modifier: Consumer): UsageService = + UsageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun delete( - params: BatchDeleteParams, - requestOptions: RequestOptions, - ): BatchDeleteResponse = - // post /v1/files/batch/deleteByFileIds - withRawResponse().delete(params, requestOptions).parse() + 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) : - BatchService.WithRawResponse { + UsageService.WithRawResponse { private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer - ): BatchService.WithRawResponse = - BatchServiceImpl.WithRawResponseImpl( + ): UsageService.WithRawResponse = + UsageServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun delete( - params: BatchDeleteParams, + override fun get( + params: UsageGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() - .method(HttpMethod.POST) + .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", "batch", "deleteByFileIds") - .body(json(clientOptions.jsonMapper, params._body())) + .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 { deleteHandler.handle(it) } + .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/files/PurgeServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt similarity index 64% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt index 0b1a8cc2..72aee8db 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package com.imagekit.api.services.blocking.cache import com.imagekit.api.core.ClientOptions import com.imagekit.api.core.RequestOptions @@ -16,59 +16,59 @@ 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.purge.PurgeExecuteParams -import com.imagekit.api.models.files.purge.PurgeExecuteResponse -import com.imagekit.api.models.files.purge.PurgeStatusParams -import com.imagekit.api.models.files.purge.PurgeStatusResponse +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 PurgeServiceImpl internal constructor(private val clientOptions: ClientOptions) : - PurgeService { +class InvalidationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InvalidationService { - private val withRawResponse: PurgeService.WithRawResponse by lazy { + private val withRawResponse: InvalidationService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - override fun withRawResponse(): PurgeService.WithRawResponse = withRawResponse + override fun withRawResponse(): InvalidationService.WithRawResponse = withRawResponse - override fun withOptions(modifier: Consumer): PurgeService = - PurgeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun withOptions(modifier: Consumer): InvalidationService = + InvalidationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun execute( - params: PurgeExecuteParams, + override fun create( + params: InvalidationCreateParams, requestOptions: RequestOptions, - ): PurgeExecuteResponse = + ): InvalidationCreateResponse = // post /v1/files/purge - withRawResponse().execute(params, requestOptions).parse() + withRawResponse().create(params, requestOptions).parse() - override fun status( - params: PurgeStatusParams, + override fun get( + params: InvalidationGetParams, requestOptions: RequestOptions, - ): PurgeStatusResponse = + ): InvalidationGetResponse = // get /v1/files/purge/{requestId} - withRawResponse().status(params, requestOptions).parse() + withRawResponse().get(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - PurgeService.WithRawResponse { + InvalidationService.WithRawResponse { private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer - ): PurgeService.WithRawResponse = - PurgeServiceImpl.WithRawResponseImpl( + ): InvalidationService.WithRawResponse = + InvalidationServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - private val executeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun execute( - params: PurgeExecuteParams, + override fun create( + params: InvalidationCreateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -81,7 +81,7 @@ class PurgeServiceImpl internal constructor(private val clientOptions: ClientOpt val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { executeHandler.handle(it) } + .use { createHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -90,13 +90,13 @@ class PurgeServiceImpl internal constructor(private val clientOptions: ClientOpt } } - private val statusHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun status( - params: PurgeStatusParams, + override fun get( + params: InvalidationGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("requestId", params.requestId().getOrNull()) @@ -111,7 +111,7 @@ class PurgeServiceImpl internal constructor(private val clientOptions: ClientOpt val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { statusHandler.handle(it) } + .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/BatchService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchService.kt deleted file mode 100644 index 14b72088..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BatchService.kt +++ /dev/null @@ -1,70 +0,0 @@ -// 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.batch.BatchDeleteParams -import com.imagekit.api.models.files.batch.BatchDeleteResponse -import java.util.function.Consumer - -interface BatchService { - - /** - * 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): BatchService - - /** - * 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: BatchDeleteParams): BatchDeleteResponse = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: BatchDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchDeleteResponse - - /** A view of [BatchService] 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): BatchService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/files/batch/deleteByFileIds`, but is otherwise - * the same as [BatchService.delete]. - */ - @MustBeClosed - fun delete(params: BatchDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: BatchDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - } -} 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/DetailService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailService.kt deleted file mode 100644 index f089527f..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailService.kt +++ /dev/null @@ -1,194 +0,0 @@ -// 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.details.DetailRetrieveParams -import com.imagekit.api.models.files.details.DetailRetrieveResponse -import com.imagekit.api.models.files.details.DetailUpdateParams -import com.imagekit.api.models.files.details.DetailUpdateResponse -import java.util.function.Consumer - -interface DetailService { - - /** - * 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): DetailService - - /** - * This API returns an object with details or attributes about the current version of the file. - */ - fun retrieve(fileId: String): DetailRetrieveResponse = - retrieve(fileId, DetailRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - fileId: String, - params: DetailRetrieveParams = DetailRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): DetailRetrieveResponse = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - fileId: String, - params: DetailRetrieveParams = DetailRetrieveParams.none(), - ): DetailRetrieveResponse = retrieve(fileId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: DetailRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): DetailRetrieveResponse - - /** @see retrieve */ - fun retrieve(params: DetailRetrieveParams): DetailRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(fileId: String, requestOptions: RequestOptions): DetailRetrieveResponse = - retrieve(fileId, DetailRetrieveParams.none(), requestOptions) - - /** - * 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): DetailUpdateResponse = update(fileId, DetailUpdateParams.none()) - - /** @see update */ - fun update( - fileId: String, - params: DetailUpdateParams = DetailUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): DetailUpdateResponse = update(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see update */ - fun update( - fileId: String, - params: DetailUpdateParams = DetailUpdateParams.none(), - ): DetailUpdateResponse = update(fileId, params, RequestOptions.none()) - - /** @see update */ - fun update( - params: DetailUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): DetailUpdateResponse - - /** @see update */ - fun update(params: DetailUpdateParams): DetailUpdateResponse = - update(params, RequestOptions.none()) - - /** @see update */ - fun update(fileId: String, requestOptions: RequestOptions): DetailUpdateResponse = - update(fileId, DetailUpdateParams.none(), requestOptions) - - /** A view of [DetailService] 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): DetailService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the - * same as [DetailService.retrieve]. - */ - @MustBeClosed - fun retrieve(fileId: String): HttpResponseFor = - retrieve(fileId, DetailRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - fileId: String, - params: DetailRetrieveParams = DetailRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - fileId: String, - params: DetailRetrieveParams = DetailRetrieveParams.none(), - ): HttpResponseFor = retrieve(fileId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: DetailRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: DetailRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - fileId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(fileId, DetailRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the - * same as [DetailService.update]. - */ - @MustBeClosed - fun update(fileId: String): HttpResponseFor = - update(fileId, DetailUpdateParams.none()) - - /** @see update */ - @MustBeClosed - fun update( - fileId: String, - params: DetailUpdateParams = DetailUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - update(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update( - fileId: String, - params: DetailUpdateParams = DetailUpdateParams.none(), - ): HttpResponseFor = update(fileId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: DetailUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see update */ - @MustBeClosed - fun update(params: DetailUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - fileId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - update(fileId, DetailUpdateParams.none(), requestOptions) - } -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailServiceImpl.kt deleted file mode 100644 index 711fa353..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/DetailServiceImpl.kt +++ /dev/null @@ -1,126 +0,0 @@ -// 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.details.DetailRetrieveParams -import com.imagekit.api.models.files.details.DetailRetrieveResponse -import com.imagekit.api.models.files.details.DetailUpdateParams -import com.imagekit.api.models.files.details.DetailUpdateResponse -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class DetailServiceImpl internal constructor(private val clientOptions: ClientOptions) : - DetailService { - - private val withRawResponse: DetailService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): DetailService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): DetailService = - DetailServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: DetailRetrieveParams, - requestOptions: RequestOptions, - ): DetailRetrieveResponse = - // get /v1/files/{fileId}/details - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update( - params: DetailUpdateParams, - requestOptions: RequestOptions, - ): DetailUpdateResponse = - // patch /v1/files/{fileId}/details - withRawResponse().update(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DetailService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): DetailService.WithRawResponse = - DetailServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: DetailRetrieveParams, - 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 { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: DetailUpdateParams, - 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() - } - } - } - } - } -} 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 b2df43ae..ed9ded7f 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 @@ -6,10 +6,10 @@ 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.MetadataFromUrlParams -import com.imagekit.api.models.files.metadata.MetadataFromUrlResponse -import com.imagekit.api.models.files.metadata.MetadataRetrieveParams -import com.imagekit.api.models.files.metadata.MetadataRetrieveResponse +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlResponse +import com.imagekit.api.models.files.metadata.MetadataGetParams +import com.imagekit.api.models.files.metadata.MetadataGetResponse import java.util.function.Consumer interface MetadataService { @@ -33,48 +33,45 @@ interface MetadataService { * You can also get the metadata in upload API response by passing `metadata` in * `responseFields` parameter. */ - fun retrieve(fileId: String): MetadataRetrieveResponse = - retrieve(fileId, MetadataRetrieveParams.none()) + fun get(fileId: String): MetadataGetResponse = get(fileId, MetadataGetParams.none()) - /** @see retrieve */ - fun retrieve( + /** @see get */ + fun get( fileId: String, - params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + params: MetadataGetParams = MetadataGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): MetadataRetrieveResponse = - retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + ): MetadataGetResponse = get(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see retrieve */ - fun retrieve( + /** @see get */ + fun get( fileId: String, - params: MetadataRetrieveParams = MetadataRetrieveParams.none(), - ): MetadataRetrieveResponse = retrieve(fileId, params, RequestOptions.none()) + params: MetadataGetParams = MetadataGetParams.none(), + ): MetadataGetResponse = get(fileId, params, RequestOptions.none()) - /** @see retrieve */ - fun retrieve( - params: MetadataRetrieveParams, + /** @see get */ + fun get( + params: MetadataGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): MetadataRetrieveResponse + ): MetadataGetResponse - /** @see retrieve */ - fun retrieve(params: MetadataRetrieveParams): MetadataRetrieveResponse = - retrieve(params, RequestOptions.none()) + /** @see get */ + fun get(params: MetadataGetParams): MetadataGetResponse = get(params, RequestOptions.none()) - /** @see retrieve */ - fun retrieve(fileId: String, requestOptions: RequestOptions): MetadataRetrieveResponse = - retrieve(fileId, MetadataRetrieveParams.none(), requestOptions) + /** @see get */ + fun get(fileId: String, requestOptions: RequestOptions): MetadataGetResponse = + get(fileId, MetadataGetParams.none(), requestOptions) /** * Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. */ - fun fromUrl(params: MetadataFromUrlParams): MetadataFromUrlResponse = - fromUrl(params, RequestOptions.none()) + fun getFromUrl(params: MetadataGetFromUrlParams): MetadataGetFromUrlResponse = + getFromUrl(params, RequestOptions.none()) - /** @see fromUrl */ - fun fromUrl( - params: MetadataFromUrlParams, + /** @see getFromUrl */ + fun getFromUrl( + params: MetadataGetFromUrlParams, requestOptions: RequestOptions = RequestOptions.none(), - ): MetadataFromUrlResponse + ): MetadataGetFromUrlResponse /** A view of [MetadataService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -88,62 +85,62 @@ interface MetadataService { /** * Returns a raw HTTP response for `get /v1/files/{fileId}/metadata`, but is otherwise the - * same as [MetadataService.retrieve]. + * same as [MetadataService.get]. */ @MustBeClosed - fun retrieve(fileId: String): HttpResponseFor = - retrieve(fileId, MetadataRetrieveParams.none()) + fun get(fileId: String): HttpResponseFor = + get(fileId, MetadataGetParams.none()) - /** @see retrieve */ + /** @see get */ @MustBeClosed - fun retrieve( + fun get( fileId: String, - params: MetadataRetrieveParams = MetadataRetrieveParams.none(), + params: MetadataGetParams = MetadataGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + ): HttpResponseFor = + get(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see retrieve */ + /** @see get */ @MustBeClosed - fun retrieve( + fun get( fileId: String, - params: MetadataRetrieveParams = MetadataRetrieveParams.none(), - ): HttpResponseFor = - retrieve(fileId, params, RequestOptions.none()) + params: MetadataGetParams = MetadataGetParams.none(), + ): HttpResponseFor = get(fileId, params, RequestOptions.none()) - /** @see retrieve */ + /** @see get */ @MustBeClosed - fun retrieve( - params: MetadataRetrieveParams, + fun get( + params: MetadataGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor - /** @see retrieve */ + /** @see get */ @MustBeClosed - fun retrieve(params: MetadataRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun get(params: MetadataGetParams): HttpResponseFor = + get(params, RequestOptions.none()) - /** @see retrieve */ + /** @see get */ @MustBeClosed - fun retrieve( + fun get( fileId: String, requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(fileId, MetadataRetrieveParams.none(), requestOptions) + ): HttpResponseFor = + get(fileId, MetadataGetParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /v1/files/metadata`, but is otherwise the same as - * [MetadataService.fromUrl]. + * [MetadataService.getFromUrl]. */ @MustBeClosed - fun fromUrl(params: MetadataFromUrlParams): HttpResponseFor = - fromUrl(params, RequestOptions.none()) + fun getFromUrl( + params: MetadataGetFromUrlParams + ): HttpResponseFor = getFromUrl(params, RequestOptions.none()) - /** @see fromUrl */ + /** @see getFromUrl */ @MustBeClosed - fun fromUrl( - params: MetadataFromUrlParams, + fun getFromUrl( + params: MetadataGetFromUrlParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 index c23bd1c4..d6627d75 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 @@ -15,10 +15,10 @@ 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.MetadataFromUrlParams -import com.imagekit.api.models.files.metadata.MetadataFromUrlResponse -import com.imagekit.api.models.files.metadata.MetadataRetrieveParams -import com.imagekit.api.models.files.metadata.MetadataRetrieveResponse +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlResponse +import com.imagekit.api.models.files.metadata.MetadataGetParams +import com.imagekit.api.models.files.metadata.MetadataGetResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -34,19 +34,19 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client override fun withOptions(modifier: Consumer): MetadataService = MetadataServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun retrieve( - params: MetadataRetrieveParams, + override fun get( + params: MetadataGetParams, requestOptions: RequestOptions, - ): MetadataRetrieveResponse = + ): MetadataGetResponse = // get /v1/files/{fileId}/metadata - withRawResponse().retrieve(params, requestOptions).parse() + withRawResponse().get(params, requestOptions).parse() - override fun fromUrl( - params: MetadataFromUrlParams, + override fun getFromUrl( + params: MetadataGetFromUrlParams, requestOptions: RequestOptions, - ): MetadataFromUrlResponse = + ): MetadataGetFromUrlResponse = // get /v1/files/metadata - withRawResponse().fromUrl(params, requestOptions).parse() + withRawResponse().getFromUrl(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : MetadataService.WithRawResponse { @@ -61,13 +61,13 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun retrieve( - params: MetadataRetrieveParams, + override fun get( + params: MetadataGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fileId", params.fileId().getOrNull()) @@ -82,7 +82,7 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { retrieveHandler.handle(it) } + .use { getHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -91,13 +91,13 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client } } - private val fromUrlHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getFromUrlHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun fromUrl( - params: MetadataFromUrlParams, + override fun getFromUrl( + params: MetadataGetFromUrlParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -109,7 +109,7 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { fromUrlHandler.handle(it) } + .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/PurgeService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeService.kt deleted file mode 100644 index b21ba504..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/PurgeService.kt +++ /dev/null @@ -1,141 +0,0 @@ -// 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.purge.PurgeExecuteParams -import com.imagekit.api.models.files.purge.PurgeExecuteResponse -import com.imagekit.api.models.files.purge.PurgeStatusParams -import com.imagekit.api.models.files.purge.PurgeStatusResponse -import java.util.function.Consumer - -interface PurgeService { - - /** - * 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): PurgeService - - /** - * 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 execute(params: PurgeExecuteParams): PurgeExecuteResponse = - execute(params, RequestOptions.none()) - - /** @see execute */ - fun execute( - params: PurgeExecuteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): PurgeExecuteResponse - - /** This API returns the status of a purge cache request. */ - fun status(requestId: String): PurgeStatusResponse = status(requestId, PurgeStatusParams.none()) - - /** @see status */ - fun status( - requestId: String, - params: PurgeStatusParams = PurgeStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): PurgeStatusResponse = status(params.toBuilder().requestId(requestId).build(), requestOptions) - - /** @see status */ - fun status( - requestId: String, - params: PurgeStatusParams = PurgeStatusParams.none(), - ): PurgeStatusResponse = status(requestId, params, RequestOptions.none()) - - /** @see status */ - fun status( - params: PurgeStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): PurgeStatusResponse - - /** @see status */ - fun status(params: PurgeStatusParams): PurgeStatusResponse = - status(params, RequestOptions.none()) - - /** @see status */ - fun status(requestId: String, requestOptions: RequestOptions): PurgeStatusResponse = - status(requestId, PurgeStatusParams.none(), requestOptions) - - /** A view of [PurgeService] 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): PurgeService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v1/files/purge`, but is otherwise the same as - * [PurgeService.execute]. - */ - @MustBeClosed - fun execute(params: PurgeExecuteParams): HttpResponseFor = - execute(params, RequestOptions.none()) - - /** @see execute */ - @MustBeClosed - fun execute( - params: PurgeExecuteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /v1/files/purge/{requestId}`, but is otherwise the - * same as [PurgeService.status]. - */ - @MustBeClosed - fun status(requestId: String): HttpResponseFor = - status(requestId, PurgeStatusParams.none()) - - /** @see status */ - @MustBeClosed - fun status( - requestId: String, - params: PurgeStatusParams = PurgeStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - status(params.toBuilder().requestId(requestId).build(), requestOptions) - - /** @see status */ - @MustBeClosed - fun status( - requestId: String, - params: PurgeStatusParams = PurgeStatusParams.none(), - ): HttpResponseFor = status(requestId, params, RequestOptions.none()) - - /** @see status */ - @MustBeClosed - fun status( - params: PurgeStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see status */ - @MustBeClosed - fun status(params: PurgeStatusParams): HttpResponseFor = - status(params, RequestOptions.none()) - - /** @see status */ - @MustBeClosed - fun status( - requestId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - status(requestId, PurgeStatusParams.none(), requestOptions) - } -} 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 index 12ab91ab..9ce3b6c4 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/com/imagekit/api/services/blocking/files/VersionService.kt @@ -8,12 +8,12 @@ import com.imagekit.api.core.RequestOptions import com.imagekit.api.core.http.HttpResponseFor 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.VersionGetResponse import com.imagekit.api.models.files.versions.VersionListParams import com.imagekit.api.models.files.versions.VersionListResponse import com.imagekit.api.models.files.versions.VersionRestoreParams import com.imagekit.api.models.files.versions.VersionRestoreResponse -import com.imagekit.api.models.files.versions.VersionRetrieveParams -import com.imagekit.api.models.files.versions.VersionRetrieveResponse import java.util.function.Consumer interface VersionService { @@ -30,28 +30,6 @@ interface VersionService { */ fun withOptions(modifier: Consumer): VersionService - /** This API returns an object with details or attributes of a file version. */ - fun retrieve(versionId: String, params: VersionRetrieveParams): VersionRetrieveResponse = - retrieve(versionId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - versionId: String, - params: VersionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): VersionRetrieveResponse = - retrieve(params.toBuilder().versionId(versionId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(params: VersionRetrieveParams): VersionRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: VersionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): VersionRetrieveResponse - /** This API returns details of all versions of a file. */ fun list(fileId: String): List = list(fileId, VersionListParams.none()) @@ -108,6 +86,26 @@ interface VersionService { requestOptions: RequestOptions = RequestOptions.none(), ): VersionDeleteResponse + /** This API returns an object with details or attributes of a file version. */ + fun get(versionId: String, params: VersionGetParams): VersionGetResponse = + get(versionId, params, RequestOptions.none()) + + /** @see get */ + fun get( + versionId: String, + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionGetResponse = get(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see get */ + fun get(params: VersionGetParams): VersionGetResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionGetResponse + /** This API restores a file version as the current file version. */ fun restore(versionId: String, params: VersionRestoreParams): VersionRestoreResponse = restore(versionId, params, RequestOptions.none()) @@ -140,38 +138,6 @@ interface VersionService { */ fun withOptions(modifier: Consumer): VersionService.WithRawResponse - /** - * Returns a raw HTTP response for `get /v1/files/{fileId}/versions/{versionId}`, but is - * otherwise the same as [VersionService.retrieve]. - */ - @MustBeClosed - fun retrieve( - versionId: String, - params: VersionRetrieveParams, - ): HttpResponseFor = - retrieve(versionId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - versionId: String, - params: VersionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().versionId(versionId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: VersionRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: VersionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - /** * Returns a raw HTTP response for `get /v1/files/{fileId}/versions`, but is otherwise the * same as [VersionService.list]. @@ -247,6 +213,35 @@ interface VersionService { 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]. 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 index 781339e4..73ddc647 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/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -18,12 +18,12 @@ import com.imagekit.api.core.http.parseable import com.imagekit.api.core.prepare 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.VersionGetResponse import com.imagekit.api.models.files.versions.VersionListParams import com.imagekit.api.models.files.versions.VersionListResponse import com.imagekit.api.models.files.versions.VersionRestoreParams import com.imagekit.api.models.files.versions.VersionRestoreResponse -import com.imagekit.api.models.files.versions.VersionRetrieveParams -import com.imagekit.api.models.files.versions.VersionRetrieveResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -39,13 +39,6 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO override fun withOptions(modifier: Consumer): VersionService = VersionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun retrieve( - params: VersionRetrieveParams, - requestOptions: RequestOptions, - ): VersionRetrieveResponse = - // get /v1/files/{fileId}/versions/{versionId} - withRawResponse().retrieve(params, requestOptions).parse() - override fun list( params: VersionListParams, requestOptions: RequestOptions, @@ -60,6 +53,10 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO // delete /v1/files/{fileId}/versions/{versionId} withRawResponse().delete(params, requestOptions).parse() + override fun get(params: VersionGetParams, requestOptions: RequestOptions): VersionGetResponse = + // get /v1/files/{fileId}/versions/{versionId} + withRawResponse().get(params, requestOptions).parse() + override fun restore( params: VersionRestoreParams, requestOptions: RequestOptions, @@ -80,85 +77,86 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) - override fun retrieve( - params: VersionRetrieveParams, + override fun list( + params: VersionListParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. - checkRequired("versionId", params.versionId().getOrNull()) + checkRequired("fileId", params.fileId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "v1", - "files", - params._pathParam(0), - "versions", - params._pathParam(1), - ) + .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 { retrieveHandler.handle(it) } + .use { listHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.validate() + it.forEach { it.validate() } } } } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun list( - params: VersionListParams, + override fun delete( + params: VersionDeleteParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. - checkRequired("fileId", params.fileId().getOrNull()) + checkRequired("versionId", params.versionId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.GET) + .method(HttpMethod.DELETE) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", params._pathParam(0), "versions") + .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 { listHandler.handle(it) } + .use { deleteHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } + it.validate() } } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun delete( - params: VersionDeleteParams, + override fun get( + params: VersionGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("versionId", params.versionId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.DELETE) + .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) .addPathSegments( "v1", @@ -167,14 +165,13 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO "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) } + .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/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/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponseTest.kt deleted file mode 100644 index 6c469ac8..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageResponseTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.accounts - -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 AccountGetUsageResponseTest { - - @Test - fun create() { - val accountGetUsageResponse = - AccountGetUsageResponse.builder() - .bandwidthBytes(0L) - .extensionUnitsCount(0L) - .mediaLibraryStorageBytes(0L) - .originalCacheStorageBytes(0L) - .videoProcessingUnitsCount(0L) - .build() - - assertThat(accountGetUsageResponse.bandwidthBytes()).contains(0L) - assertThat(accountGetUsageResponse.extensionUnitsCount()).contains(0L) - assertThat(accountGetUsageResponse.mediaLibraryStorageBytes()).contains(0L) - assertThat(accountGetUsageResponse.originalCacheStorageBytes()).contains(0L) - assertThat(accountGetUsageResponse.videoProcessingUnitsCount()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val accountGetUsageResponse = - AccountGetUsageResponse.builder() - .bandwidthBytes(0L) - .extensionUnitsCount(0L) - .mediaLibraryStorageBytes(0L) - .originalCacheStorageBytes(0L) - .videoProcessingUnitsCount(0L) - .build() - - val roundtrippedAccountGetUsageResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(accountGetUsageResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAccountGetUsageResponse).isEqualTo(accountGetUsageResponse) - } -} 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..f091309e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt @@ -0,0 +1,95 @@ +// 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() + .body( + OriginCreateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginCreateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + OriginCreateParams.builder() + .body( + OriginCreateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginCreateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OriginCreateParams.Body.ofS3( + OriginCreateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginCreateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OriginCreateParams.builder() + .body( + OriginCreateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginCreateParams.Body.S3.Type.S3) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OriginCreateParams.Body.ofS3( + OriginCreateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginCreateParams.Body.S3.Type.S3) + .build() + ) + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt new file mode 100644 index 00000000..f11438ad --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt @@ -0,0 +1,437 @@ +// 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 OriginCreateResponseTest { + + @Test + fun ofS3() { + val s3 = + OriginCreateResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginCreateResponse.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originCreateResponse = OriginCreateResponse.ofS3(s3) + + assertThat(originCreateResponse.s3()).contains(s3) + assertThat(originCreateResponse.s3Compatible()).isEmpty + assertThat(originCreateResponse.cloudinaryBackup()).isEmpty + assertThat(originCreateResponse.webFolder()).isEmpty + assertThat(originCreateResponse.webProxy()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3Roundtrip() { + val jsonMapper = jsonMapper() + val originCreateResponse = + OriginCreateResponse.ofS3( + OriginCreateResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginCreateResponse.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) + } + + @Test + fun ofS3Compatible() { + val s3Compatible = + OriginCreateResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .s3ForcePathStyle(true) + .type(OriginCreateResponse.S3Compatible.Type.S3_COMPATIBLE) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originCreateResponse = OriginCreateResponse.ofS3Compatible(s3Compatible) + + assertThat(originCreateResponse.s3()).isEmpty + assertThat(originCreateResponse.s3Compatible()).contains(s3Compatible) + assertThat(originCreateResponse.cloudinaryBackup()).isEmpty + assertThat(originCreateResponse.webFolder()).isEmpty + assertThat(originCreateResponse.webProxy()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3CompatibleRoundtrip() { + val jsonMapper = jsonMapper() + val originCreateResponse = + OriginCreateResponse.ofS3Compatible( + OriginCreateResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .s3ForcePathStyle(true) + .type(OriginCreateResponse.S3Compatible.Type.S3_COMPATIBLE) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) + } + + @Test + fun ofCloudinaryBackup() { + val cloudinaryBackup = + OriginCreateResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginCreateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originCreateResponse = OriginCreateResponse.ofCloudinaryBackup(cloudinaryBackup) + + assertThat(originCreateResponse.s3()).isEmpty + assertThat(originCreateResponse.s3Compatible()).isEmpty + assertThat(originCreateResponse.cloudinaryBackup()).contains(cloudinaryBackup) + assertThat(originCreateResponse.webFolder()).isEmpty + assertThat(originCreateResponse.webProxy()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofCloudinaryBackupRoundtrip() { + val jsonMapper = jsonMapper() + val originCreateResponse = + OriginCreateResponse.ofCloudinaryBackup( + OriginCreateResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginCreateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) + } + + @Test + fun ofWebFolder() { + val webFolder = + OriginCreateResponse.WebFolder.builder() + .id("id") + .baseUrl(JsonValue.from("https://images.example.com/assets")) + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginCreateResponse.WebFolder.Type.WEB_FOLDER) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originCreateResponse = OriginCreateResponse.ofWebFolder(webFolder) + + assertThat(originCreateResponse.s3()).isEmpty + assertThat(originCreateResponse.s3Compatible()).isEmpty + assertThat(originCreateResponse.cloudinaryBackup()).isEmpty + assertThat(originCreateResponse.webFolder()).contains(webFolder) + assertThat(originCreateResponse.webProxy()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebFolderRoundtrip() { + val jsonMapper = jsonMapper() + val originCreateResponse = + OriginCreateResponse.ofWebFolder( + OriginCreateResponse.WebFolder.builder() + .id("id") + .baseUrl(JsonValue.from("https://images.example.com/assets")) + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginCreateResponse.WebFolder.Type.WEB_FOLDER) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) + } + + @Test + fun ofWebProxy() { + val webProxy = + OriginCreateResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginCreateResponse.WebProxy.Type.WEB_PROXY) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originCreateResponse = OriginCreateResponse.ofWebProxy(webProxy) + + assertThat(originCreateResponse.s3()).isEmpty + assertThat(originCreateResponse.s3Compatible()).isEmpty + assertThat(originCreateResponse.cloudinaryBackup()).isEmpty + assertThat(originCreateResponse.webFolder()).isEmpty + assertThat(originCreateResponse.webProxy()).contains(webProxy) + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebProxyRoundtrip() { + val jsonMapper = jsonMapper() + val originCreateResponse = + OriginCreateResponse.ofWebProxy( + OriginCreateResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginCreateResponse.WebProxy.Type.WEB_PROXY) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) + } + + @Test + fun ofGoogleCloudStorageGcs() { + val googleCloudStorageGcs = + OriginCreateResponse.GoogleCloudStorageGcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("products")) + .type(OriginCreateResponse.GoogleCloudStorageGcs.Type.GCS) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originCreateResponse = + OriginCreateResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + + assertThat(originCreateResponse.s3()).isEmpty + assertThat(originCreateResponse.s3Compatible()).isEmpty + assertThat(originCreateResponse.cloudinaryBackup()).isEmpty + assertThat(originCreateResponse.webFolder()).isEmpty + assertThat(originCreateResponse.webProxy()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) + assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofGoogleCloudStorageGcsRoundtrip() { + val jsonMapper = jsonMapper() + val originCreateResponse = + OriginCreateResponse.ofGoogleCloudStorageGcs( + OriginCreateResponse.GoogleCloudStorageGcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("products")) + .type(OriginCreateResponse.GoogleCloudStorageGcs.Type.GCS) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) + } + + @Test + fun ofAzureBlobStorage() { + val azureBlobStorage = + OriginCreateResponse.AzureBlobStorage.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("uploads")) + .type(OriginCreateResponse.AzureBlobStorage.Type.AZURE_BLOB) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originCreateResponse = OriginCreateResponse.ofAzureBlobStorage(azureBlobStorage) + + assertThat(originCreateResponse.s3()).isEmpty + assertThat(originCreateResponse.s3Compatible()).isEmpty + assertThat(originCreateResponse.cloudinaryBackup()).isEmpty + assertThat(originCreateResponse.webFolder()).isEmpty + assertThat(originCreateResponse.webProxy()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originCreateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofAzureBlobStorageRoundtrip() { + val jsonMapper = jsonMapper() + val originCreateResponse = + OriginCreateResponse.ofAzureBlobStorage( + OriginCreateResponse.AzureBlobStorage.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("uploads")) + .type(OriginCreateResponse.AzureBlobStorage.Type.AZURE_BLOB) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) + } + + @Test + fun ofAkeneoPim() { + val akeneoPim = + OriginCreateResponse.AkeneoPim.builder() + .id("id") + .baseUrl(JsonValue.from("https://akeneo.company.com")) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginCreateResponse.AkeneoPim.Type.AKENEO_PIM) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originCreateResponse = OriginCreateResponse.ofAkeneoPim(akeneoPim) + + assertThat(originCreateResponse.s3()).isEmpty + assertThat(originCreateResponse.s3Compatible()).isEmpty + assertThat(originCreateResponse.cloudinaryBackup()).isEmpty + assertThat(originCreateResponse.webFolder()).isEmpty + assertThat(originCreateResponse.webProxy()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.akeneoPim()).contains(akeneoPim) + } + + @Test + fun ofAkeneoPimRoundtrip() { + val jsonMapper = jsonMapper() + val originCreateResponse = + OriginCreateResponse.ofAkeneoPim( + OriginCreateResponse.AkeneoPim.builder() + .id("id") + .baseUrl(JsonValue.from("https://akeneo.company.com")) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginCreateResponse.AkeneoPim.Type.AKENEO_PIM) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) + } + + 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 originCreateResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { originCreateResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} 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/OriginGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt new file mode 100644 index 00000000..f248c20d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt @@ -0,0 +1,436 @@ +// 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 OriginGetResponseTest { + + @Test + fun ofS3() { + val s3 = + OriginGetResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginGetResponse.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originGetResponse = OriginGetResponse.ofS3(s3) + + assertThat(originGetResponse.s3()).contains(s3) + assertThat(originGetResponse.s3Compatible()).isEmpty + assertThat(originGetResponse.cloudinaryBackup()).isEmpty + assertThat(originGetResponse.webFolder()).isEmpty + assertThat(originGetResponse.webProxy()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3Roundtrip() { + val jsonMapper = jsonMapper() + val originGetResponse = + OriginGetResponse.ofS3( + OriginGetResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginGetResponse.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + } + + @Test + fun ofS3Compatible() { + val s3Compatible = + OriginGetResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .s3ForcePathStyle(true) + .type(OriginGetResponse.S3Compatible.Type.S3_COMPATIBLE) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originGetResponse = OriginGetResponse.ofS3Compatible(s3Compatible) + + assertThat(originGetResponse.s3()).isEmpty + assertThat(originGetResponse.s3Compatible()).contains(s3Compatible) + assertThat(originGetResponse.cloudinaryBackup()).isEmpty + assertThat(originGetResponse.webFolder()).isEmpty + assertThat(originGetResponse.webProxy()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3CompatibleRoundtrip() { + val jsonMapper = jsonMapper() + val originGetResponse = + OriginGetResponse.ofS3Compatible( + OriginGetResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .s3ForcePathStyle(true) + .type(OriginGetResponse.S3Compatible.Type.S3_COMPATIBLE) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + } + + @Test + fun ofCloudinaryBackup() { + val cloudinaryBackup = + OriginGetResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginGetResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originGetResponse = OriginGetResponse.ofCloudinaryBackup(cloudinaryBackup) + + assertThat(originGetResponse.s3()).isEmpty + assertThat(originGetResponse.s3Compatible()).isEmpty + assertThat(originGetResponse.cloudinaryBackup()).contains(cloudinaryBackup) + assertThat(originGetResponse.webFolder()).isEmpty + assertThat(originGetResponse.webProxy()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.akeneoPim()).isEmpty + } + + @Test + fun ofCloudinaryBackupRoundtrip() { + val jsonMapper = jsonMapper() + val originGetResponse = + OriginGetResponse.ofCloudinaryBackup( + OriginGetResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginGetResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + } + + @Test + fun ofWebFolder() { + val webFolder = + OriginGetResponse.WebFolder.builder() + .id("id") + .baseUrl(JsonValue.from("https://images.example.com/assets")) + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginGetResponse.WebFolder.Type.WEB_FOLDER) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originGetResponse = OriginGetResponse.ofWebFolder(webFolder) + + assertThat(originGetResponse.s3()).isEmpty + assertThat(originGetResponse.s3Compatible()).isEmpty + assertThat(originGetResponse.cloudinaryBackup()).isEmpty + assertThat(originGetResponse.webFolder()).contains(webFolder) + assertThat(originGetResponse.webProxy()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebFolderRoundtrip() { + val jsonMapper = jsonMapper() + val originGetResponse = + OriginGetResponse.ofWebFolder( + OriginGetResponse.WebFolder.builder() + .id("id") + .baseUrl(JsonValue.from("https://images.example.com/assets")) + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginGetResponse.WebFolder.Type.WEB_FOLDER) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + } + + @Test + fun ofWebProxy() { + val webProxy = + OriginGetResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginGetResponse.WebProxy.Type.WEB_PROXY) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originGetResponse = OriginGetResponse.ofWebProxy(webProxy) + + assertThat(originGetResponse.s3()).isEmpty + assertThat(originGetResponse.s3Compatible()).isEmpty + assertThat(originGetResponse.cloudinaryBackup()).isEmpty + assertThat(originGetResponse.webFolder()).isEmpty + assertThat(originGetResponse.webProxy()).contains(webProxy) + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebProxyRoundtrip() { + val jsonMapper = jsonMapper() + val originGetResponse = + OriginGetResponse.ofWebProxy( + OriginGetResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginGetResponse.WebProxy.Type.WEB_PROXY) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + } + + @Test + fun ofGoogleCloudStorageGcs() { + val googleCloudStorageGcs = + OriginGetResponse.GoogleCloudStorageGcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("products")) + .type(OriginGetResponse.GoogleCloudStorageGcs.Type.GCS) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originGetResponse = OriginGetResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + + assertThat(originGetResponse.s3()).isEmpty + assertThat(originGetResponse.s3Compatible()).isEmpty + assertThat(originGetResponse.cloudinaryBackup()).isEmpty + assertThat(originGetResponse.webFolder()).isEmpty + assertThat(originGetResponse.webProxy()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) + assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.akeneoPim()).isEmpty + } + + @Test + fun ofGoogleCloudStorageGcsRoundtrip() { + val jsonMapper = jsonMapper() + val originGetResponse = + OriginGetResponse.ofGoogleCloudStorageGcs( + OriginGetResponse.GoogleCloudStorageGcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("products")) + .type(OriginGetResponse.GoogleCloudStorageGcs.Type.GCS) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + } + + @Test + fun ofAzureBlobStorage() { + val azureBlobStorage = + OriginGetResponse.AzureBlobStorage.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("uploads")) + .type(OriginGetResponse.AzureBlobStorage.Type.AZURE_BLOB) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originGetResponse = OriginGetResponse.ofAzureBlobStorage(azureBlobStorage) + + assertThat(originGetResponse.s3()).isEmpty + assertThat(originGetResponse.s3Compatible()).isEmpty + assertThat(originGetResponse.cloudinaryBackup()).isEmpty + assertThat(originGetResponse.webFolder()).isEmpty + assertThat(originGetResponse.webProxy()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originGetResponse.akeneoPim()).isEmpty + } + + @Test + fun ofAzureBlobStorageRoundtrip() { + val jsonMapper = jsonMapper() + val originGetResponse = + OriginGetResponse.ofAzureBlobStorage( + OriginGetResponse.AzureBlobStorage.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("uploads")) + .type(OriginGetResponse.AzureBlobStorage.Type.AZURE_BLOB) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + } + + @Test + fun ofAkeneoPim() { + val akeneoPim = + OriginGetResponse.AkeneoPim.builder() + .id("id") + .baseUrl(JsonValue.from("https://akeneo.company.com")) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginGetResponse.AkeneoPim.Type.AKENEO_PIM) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originGetResponse = OriginGetResponse.ofAkeneoPim(akeneoPim) + + assertThat(originGetResponse.s3()).isEmpty + assertThat(originGetResponse.s3Compatible()).isEmpty + assertThat(originGetResponse.cloudinaryBackup()).isEmpty + assertThat(originGetResponse.webFolder()).isEmpty + assertThat(originGetResponse.webProxy()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.akeneoPim()).contains(akeneoPim) + } + + @Test + fun ofAkeneoPimRoundtrip() { + val jsonMapper = jsonMapper() + val originGetResponse = + OriginGetResponse.ofAkeneoPim( + OriginGetResponse.AkeneoPim.builder() + .id("id") + .baseUrl(JsonValue.from("https://akeneo.company.com")) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginGetResponse.AkeneoPim.Type.AKENEO_PIM) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + } + + 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 originGetResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { originGetResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} 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/OriginListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt new file mode 100644 index 00000000..7763d3a9 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt @@ -0,0 +1,436 @@ +// 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 OriginListResponseTest { + + @Test + fun ofS3() { + val s3 = + OriginListResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginListResponse.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originListResponse = OriginListResponse.ofS3(s3) + + assertThat(originListResponse.s3()).contains(s3) + assertThat(originListResponse.s3Compatible()).isEmpty + assertThat(originListResponse.cloudinaryBackup()).isEmpty + assertThat(originListResponse.webFolder()).isEmpty + assertThat(originListResponse.webProxy()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3Roundtrip() { + val jsonMapper = jsonMapper() + val originListResponse = + OriginListResponse.ofS3( + OriginListResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginListResponse.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) + } + + @Test + fun ofS3Compatible() { + val s3Compatible = + OriginListResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .s3ForcePathStyle(true) + .type(OriginListResponse.S3Compatible.Type.S3_COMPATIBLE) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originListResponse = OriginListResponse.ofS3Compatible(s3Compatible) + + assertThat(originListResponse.s3()).isEmpty + assertThat(originListResponse.s3Compatible()).contains(s3Compatible) + assertThat(originListResponse.cloudinaryBackup()).isEmpty + assertThat(originListResponse.webFolder()).isEmpty + assertThat(originListResponse.webProxy()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3CompatibleRoundtrip() { + val jsonMapper = jsonMapper() + val originListResponse = + OriginListResponse.ofS3Compatible( + OriginListResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .s3ForcePathStyle(true) + .type(OriginListResponse.S3Compatible.Type.S3_COMPATIBLE) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) + } + + @Test + fun ofCloudinaryBackup() { + val cloudinaryBackup = + OriginListResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginListResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originListResponse = OriginListResponse.ofCloudinaryBackup(cloudinaryBackup) + + assertThat(originListResponse.s3()).isEmpty + assertThat(originListResponse.s3Compatible()).isEmpty + assertThat(originListResponse.cloudinaryBackup()).contains(cloudinaryBackup) + assertThat(originListResponse.webFolder()).isEmpty + assertThat(originListResponse.webProxy()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.akeneoPim()).isEmpty + } + + @Test + fun ofCloudinaryBackupRoundtrip() { + val jsonMapper = jsonMapper() + val originListResponse = + OriginListResponse.ofCloudinaryBackup( + OriginListResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginListResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) + } + + @Test + fun ofWebFolder() { + val webFolder = + OriginListResponse.WebFolder.builder() + .id("id") + .baseUrl(JsonValue.from("https://images.example.com/assets")) + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginListResponse.WebFolder.Type.WEB_FOLDER) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originListResponse = OriginListResponse.ofWebFolder(webFolder) + + assertThat(originListResponse.s3()).isEmpty + assertThat(originListResponse.s3Compatible()).isEmpty + assertThat(originListResponse.cloudinaryBackup()).isEmpty + assertThat(originListResponse.webFolder()).contains(webFolder) + assertThat(originListResponse.webProxy()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebFolderRoundtrip() { + val jsonMapper = jsonMapper() + val originListResponse = + OriginListResponse.ofWebFolder( + OriginListResponse.WebFolder.builder() + .id("id") + .baseUrl(JsonValue.from("https://images.example.com/assets")) + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginListResponse.WebFolder.Type.WEB_FOLDER) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) + } + + @Test + fun ofWebProxy() { + val webProxy = + OriginListResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginListResponse.WebProxy.Type.WEB_PROXY) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originListResponse = OriginListResponse.ofWebProxy(webProxy) + + assertThat(originListResponse.s3()).isEmpty + assertThat(originListResponse.s3Compatible()).isEmpty + assertThat(originListResponse.cloudinaryBackup()).isEmpty + assertThat(originListResponse.webFolder()).isEmpty + assertThat(originListResponse.webProxy()).contains(webProxy) + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebProxyRoundtrip() { + val jsonMapper = jsonMapper() + val originListResponse = + OriginListResponse.ofWebProxy( + OriginListResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginListResponse.WebProxy.Type.WEB_PROXY) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) + } + + @Test + fun ofGoogleCloudStorageGcs() { + val googleCloudStorageGcs = + OriginListResponse.GoogleCloudStorageGcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("products")) + .type(OriginListResponse.GoogleCloudStorageGcs.Type.GCS) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originListResponse = OriginListResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + + assertThat(originListResponse.s3()).isEmpty + assertThat(originListResponse.s3Compatible()).isEmpty + assertThat(originListResponse.cloudinaryBackup()).isEmpty + assertThat(originListResponse.webFolder()).isEmpty + assertThat(originListResponse.webProxy()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) + assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.akeneoPim()).isEmpty + } + + @Test + fun ofGoogleCloudStorageGcsRoundtrip() { + val jsonMapper = jsonMapper() + val originListResponse = + OriginListResponse.ofGoogleCloudStorageGcs( + OriginListResponse.GoogleCloudStorageGcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("products")) + .type(OriginListResponse.GoogleCloudStorageGcs.Type.GCS) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) + } + + @Test + fun ofAzureBlobStorage() { + val azureBlobStorage = + OriginListResponse.AzureBlobStorage.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("uploads")) + .type(OriginListResponse.AzureBlobStorage.Type.AZURE_BLOB) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originListResponse = OriginListResponse.ofAzureBlobStorage(azureBlobStorage) + + assertThat(originListResponse.s3()).isEmpty + assertThat(originListResponse.s3Compatible()).isEmpty + assertThat(originListResponse.cloudinaryBackup()).isEmpty + assertThat(originListResponse.webFolder()).isEmpty + assertThat(originListResponse.webProxy()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originListResponse.akeneoPim()).isEmpty + } + + @Test + fun ofAzureBlobStorageRoundtrip() { + val jsonMapper = jsonMapper() + val originListResponse = + OriginListResponse.ofAzureBlobStorage( + OriginListResponse.AzureBlobStorage.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("uploads")) + .type(OriginListResponse.AzureBlobStorage.Type.AZURE_BLOB) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) + } + + @Test + fun ofAkeneoPim() { + val akeneoPim = + OriginListResponse.AkeneoPim.builder() + .id("id") + .baseUrl(JsonValue.from("https://akeneo.company.com")) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginListResponse.AkeneoPim.Type.AKENEO_PIM) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originListResponse = OriginListResponse.ofAkeneoPim(akeneoPim) + + assertThat(originListResponse.s3()).isEmpty + assertThat(originListResponse.s3Compatible()).isEmpty + assertThat(originListResponse.cloudinaryBackup()).isEmpty + assertThat(originListResponse.webFolder()).isEmpty + assertThat(originListResponse.webProxy()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.akeneoPim()).contains(akeneoPim) + } + + @Test + fun ofAkeneoPimRoundtrip() { + val jsonMapper = jsonMapper() + val originListResponse = + OriginListResponse.ofAkeneoPim( + OriginListResponse.AkeneoPim.builder() + .id("id") + .baseUrl(JsonValue.from("https://akeneo.company.com")) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginListResponse.AkeneoPim.Type.AKENEO_PIM) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) + } + + 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 originListResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { originListResponse.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..6def6f75 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt @@ -0,0 +1,119 @@ +// 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") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginUpdateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + OriginUpdateParams.builder() + .id("id") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginUpdateParams.Body.S3.Type.S3) + .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") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginUpdateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OriginUpdateParams.Body.ofS3( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginUpdateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OriginUpdateParams.builder() + .id("id") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginUpdateParams.Body.S3.Type.S3) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OriginUpdateParams.Body.ofS3( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginUpdateParams.Body.S3.Type.S3) + .build() + ) + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt new file mode 100644 index 00000000..b1c8831d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt @@ -0,0 +1,437 @@ +// 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 OriginUpdateResponseTest { + + @Test + fun ofS3() { + val s3 = + OriginUpdateResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginUpdateResponse.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originUpdateResponse = OriginUpdateResponse.ofS3(s3) + + assertThat(originUpdateResponse.s3()).contains(s3) + assertThat(originUpdateResponse.s3Compatible()).isEmpty + assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty + assertThat(originUpdateResponse.webFolder()).isEmpty + assertThat(originUpdateResponse.webProxy()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3Roundtrip() { + val jsonMapper = jsonMapper() + val originUpdateResponse = + OriginUpdateResponse.ofS3( + OriginUpdateResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginUpdateResponse.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) + } + + @Test + fun ofS3Compatible() { + val s3Compatible = + OriginUpdateResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .s3ForcePathStyle(true) + .type(OriginUpdateResponse.S3Compatible.Type.S3_COMPATIBLE) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originUpdateResponse = OriginUpdateResponse.ofS3Compatible(s3Compatible) + + assertThat(originUpdateResponse.s3()).isEmpty + assertThat(originUpdateResponse.s3Compatible()).contains(s3Compatible) + assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty + assertThat(originUpdateResponse.webFolder()).isEmpty + assertThat(originUpdateResponse.webProxy()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3CompatibleRoundtrip() { + val jsonMapper = jsonMapper() + val originUpdateResponse = + OriginUpdateResponse.ofS3Compatible( + OriginUpdateResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .s3ForcePathStyle(true) + .type(OriginUpdateResponse.S3Compatible.Type.S3_COMPATIBLE) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) + } + + @Test + fun ofCloudinaryBackup() { + val cloudinaryBackup = + OriginUpdateResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginUpdateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originUpdateResponse = OriginUpdateResponse.ofCloudinaryBackup(cloudinaryBackup) + + assertThat(originUpdateResponse.s3()).isEmpty + assertThat(originUpdateResponse.s3Compatible()).isEmpty + assertThat(originUpdateResponse.cloudinaryBackup()).contains(cloudinaryBackup) + assertThat(originUpdateResponse.webFolder()).isEmpty + assertThat(originUpdateResponse.webProxy()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofCloudinaryBackupRoundtrip() { + val jsonMapper = jsonMapper() + val originUpdateResponse = + OriginUpdateResponse.ofCloudinaryBackup( + OriginUpdateResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("raw-assets")) + .type(OriginUpdateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) + } + + @Test + fun ofWebFolder() { + val webFolder = + OriginUpdateResponse.WebFolder.builder() + .id("id") + .baseUrl(JsonValue.from("https://images.example.com/assets")) + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginUpdateResponse.WebFolder.Type.WEB_FOLDER) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originUpdateResponse = OriginUpdateResponse.ofWebFolder(webFolder) + + assertThat(originUpdateResponse.s3()).isEmpty + assertThat(originUpdateResponse.s3Compatible()).isEmpty + assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty + assertThat(originUpdateResponse.webFolder()).contains(webFolder) + assertThat(originUpdateResponse.webProxy()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebFolderRoundtrip() { + val jsonMapper = jsonMapper() + val originUpdateResponse = + OriginUpdateResponse.ofWebFolder( + OriginUpdateResponse.WebFolder.builder() + .id("id") + .baseUrl(JsonValue.from("https://images.example.com/assets")) + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginUpdateResponse.WebFolder.Type.WEB_FOLDER) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) + } + + @Test + fun ofWebProxy() { + val webProxy = + OriginUpdateResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginUpdateResponse.WebProxy.Type.WEB_PROXY) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originUpdateResponse = OriginUpdateResponse.ofWebProxy(webProxy) + + assertThat(originUpdateResponse.s3()).isEmpty + assertThat(originUpdateResponse.s3Compatible()).isEmpty + assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty + assertThat(originUpdateResponse.webFolder()).isEmpty + assertThat(originUpdateResponse.webProxy()).contains(webProxy) + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebProxyRoundtrip() { + val jsonMapper = jsonMapper() + val originUpdateResponse = + OriginUpdateResponse.ofWebProxy( + OriginUpdateResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginUpdateResponse.WebProxy.Type.WEB_PROXY) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) + } + + @Test + fun ofGoogleCloudStorageGcs() { + val googleCloudStorageGcs = + OriginUpdateResponse.GoogleCloudStorageGcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("products")) + .type(OriginUpdateResponse.GoogleCloudStorageGcs.Type.GCS) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originUpdateResponse = + OriginUpdateResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + + assertThat(originUpdateResponse.s3()).isEmpty + assertThat(originUpdateResponse.s3Compatible()).isEmpty + assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty + assertThat(originUpdateResponse.webFolder()).isEmpty + assertThat(originUpdateResponse.webProxy()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofGoogleCloudStorageGcsRoundtrip() { + val jsonMapper = jsonMapper() + val originUpdateResponse = + OriginUpdateResponse.ofGoogleCloudStorageGcs( + OriginUpdateResponse.GoogleCloudStorageGcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("products")) + .type(OriginUpdateResponse.GoogleCloudStorageGcs.Type.GCS) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) + } + + @Test + fun ofAzureBlobStorage() { + val azureBlobStorage = + OriginUpdateResponse.AzureBlobStorage.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("uploads")) + .type(OriginUpdateResponse.AzureBlobStorage.Type.AZURE_BLOB) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originUpdateResponse = OriginUpdateResponse.ofAzureBlobStorage(azureBlobStorage) + + assertThat(originUpdateResponse.s3()).isEmpty + assertThat(originUpdateResponse.s3Compatible()).isEmpty + assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty + assertThat(originUpdateResponse.webFolder()).isEmpty + assertThat(originUpdateResponse.webProxy()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originUpdateResponse.akeneoPim()).isEmpty + } + + @Test + fun ofAzureBlobStorageRoundtrip() { + val jsonMapper = jsonMapper() + val originUpdateResponse = + OriginUpdateResponse.ofAzureBlobStorage( + OriginUpdateResponse.AzureBlobStorage.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix(JsonValue.from("uploads")) + .type(OriginUpdateResponse.AzureBlobStorage.Type.AZURE_BLOB) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) + } + + @Test + fun ofAkeneoPim() { + val akeneoPim = + OriginUpdateResponse.AkeneoPim.builder() + .id("id") + .baseUrl(JsonValue.from("https://akeneo.company.com")) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginUpdateResponse.AkeneoPim.Type.AKENEO_PIM) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originUpdateResponse = OriginUpdateResponse.ofAkeneoPim(akeneoPim) + + assertThat(originUpdateResponse.s3()).isEmpty + assertThat(originUpdateResponse.s3Compatible()).isEmpty + assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty + assertThat(originUpdateResponse.webFolder()).isEmpty + assertThat(originUpdateResponse.webProxy()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.akeneoPim()).contains(akeneoPim) + } + + @Test + fun ofAkeneoPimRoundtrip() { + val jsonMapper = jsonMapper() + val originUpdateResponse = + OriginUpdateResponse.ofAkeneoPim( + OriginUpdateResponse.AkeneoPim.builder() + .id("id") + .baseUrl(JsonValue.from("https://akeneo.company.com")) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .type(OriginUpdateResponse.AkeneoPim.Type.AKENEO_PIM) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) + } + + 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 originUpdateResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { originUpdateResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} 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..fb9504c0 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UrlEndpointCreateParamsTest { + + @Test + fun create() { + UrlEndpointCreateParams.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type(UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY) + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + UrlEndpointCreateParams.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.description()).isEqualTo("My custom URL endpoint") + assertThat(body.origins().getOrNull()).containsExactly("origin-id-1") + assertThat(body.urlPrefix()).contains("product-images") + assertThat(body.urlRewriter()) + .contains( + UrlEndpointCreateParams.UrlRewriter.ofCloudinary( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .preserveAssetDeliveryTypes(true) + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = UrlEndpointCreateParams.builder().description("My custom URL endpoint").build() + + val body = params._body() + + assertThat(body.description()).isEqualTo("My custom URL endpoint") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt new file mode 100644 index 00000000..579b5930 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt @@ -0,0 +1,80 @@ +// 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 UrlEndpointCreateResponseTest { + + @Test + fun create() { + val urlEndpointCreateResponse = + UrlEndpointCreateResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + .build() + + assertThat(urlEndpointCreateResponse.id()).isEqualTo("id") + assertThat(urlEndpointCreateResponse.description()).isEqualTo("My custom URL endpoint") + assertThat(urlEndpointCreateResponse.origins()) + .containsExactly("origin-id-1", "origin-id-2") + assertThat(urlEndpointCreateResponse.urlPrefix()).isEqualTo("product-images") + assertThat(urlEndpointCreateResponse.urlRewriter()) + .contains( + UrlEndpointCreateResponse.UrlRewriter.ofCloudinary( + UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val urlEndpointCreateResponse = + UrlEndpointCreateResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + .build() + + val roundtrippedUrlEndpointCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(urlEndpointCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUrlEndpointCreateResponse).isEqualTo(urlEndpointCreateResponse) + } +} 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/UrlEndpointGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt new file mode 100644 index 00000000..56ed6a2a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt @@ -0,0 +1,76 @@ +// 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 UrlEndpointGetResponseTest { + + @Test + fun create() { + val urlEndpointGetResponse = + UrlEndpointGetResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY + ) + .build() + ) + .build() + + assertThat(urlEndpointGetResponse.id()).isEqualTo("id") + assertThat(urlEndpointGetResponse.description()).isEqualTo("My custom URL endpoint") + assertThat(urlEndpointGetResponse.origins()).containsExactly("origin-id-1", "origin-id-2") + assertThat(urlEndpointGetResponse.urlPrefix()).isEqualTo("product-images") + assertThat(urlEndpointGetResponse.urlRewriter()) + .contains( + UrlEndpointGetResponse.UrlRewriter.ofCloudinary( + UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY + ) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val urlEndpointGetResponse = + UrlEndpointGetResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY + ) + .build() + ) + .build() + + val roundtrippedUrlEndpointGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(urlEndpointGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUrlEndpointGetResponse).isEqualTo(urlEndpointGetResponse) + } +} 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/UrlEndpointListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt new file mode 100644 index 00000000..716c1e1f --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt @@ -0,0 +1,79 @@ +// 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 UrlEndpointListResponseTest { + + @Test + fun create() { + val urlEndpointListResponse = + UrlEndpointListResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + .build() + + assertThat(urlEndpointListResponse.id()).isEqualTo("id") + assertThat(urlEndpointListResponse.description()).isEqualTo("My custom URL endpoint") + assertThat(urlEndpointListResponse.origins()).containsExactly("origin-id-1", "origin-id-2") + assertThat(urlEndpointListResponse.urlPrefix()).isEqualTo("product-images") + assertThat(urlEndpointListResponse.urlRewriter()) + .contains( + UrlEndpointListResponse.UrlRewriter.ofCloudinary( + UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val urlEndpointListResponse = + UrlEndpointListResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + .build() + + val roundtrippedUrlEndpointListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(urlEndpointListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUrlEndpointListResponse).isEqualTo(urlEndpointListResponse) + } +} 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..0019ab2c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UrlEndpointUpdateParamsTest { + + @Test + fun create() { + UrlEndpointUpdateParams.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type(UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY) + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + UrlEndpointUpdateParams.builder().id("id").description("My custom URL endpoint").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") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.description()).isEqualTo("My custom URL endpoint") + assertThat(body.origins().getOrNull()).containsExactly("origin-id-1") + assertThat(body.urlPrefix()).contains("product-images") + assertThat(body.urlRewriter()) + .contains( + UrlEndpointUpdateParams.UrlRewriter.ofCloudinary( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .preserveAssetDeliveryTypes(true) + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + UrlEndpointUpdateParams.builder().id("id").description("My custom URL endpoint").build() + + val body = params._body() + + assertThat(body.description()).isEqualTo("My custom URL endpoint") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt new file mode 100644 index 00000000..2e8ee57a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt @@ -0,0 +1,80 @@ +// 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 UrlEndpointUpdateResponseTest { + + @Test + fun create() { + val urlEndpointUpdateResponse = + UrlEndpointUpdateResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + .build() + + assertThat(urlEndpointUpdateResponse.id()).isEqualTo("id") + assertThat(urlEndpointUpdateResponse.description()).isEqualTo("My custom URL endpoint") + assertThat(urlEndpointUpdateResponse.origins()) + .containsExactly("origin-id-1", "origin-id-2") + assertThat(urlEndpointUpdateResponse.urlPrefix()).isEqualTo("product-images") + assertThat(urlEndpointUpdateResponse.urlRewriter()) + .contains( + UrlEndpointUpdateResponse.UrlRewriter.ofCloudinary( + UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val urlEndpointUpdateResponse = + UrlEndpointUpdateResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + .preserveAssetDeliveryTypes(true) + .type( + UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .build() + ) + .build() + + val roundtrippedUrlEndpointUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(urlEndpointUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUrlEndpointUpdateResponse).isEqualTo(urlEndpointUpdateResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt similarity index 83% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt index 86891087..260fb488 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/AccountGetUsageParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts +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 AccountGetUsageParamsTest { +internal class UsageGetParamsTest { @Test fun create() { - AccountGetUsageParams.builder() + UsageGetParams.builder() .endDate(LocalDate.parse("2019-12-27")) .startDate(LocalDate.parse("2019-12-27")) .build() @@ -20,7 +20,7 @@ internal class AccountGetUsageParamsTest { @Test fun queryParams() { val params = - AccountGetUsageParams.builder() + UsageGetParams.builder() .endDate(LocalDate.parse("2019-12-27")) .startDate(LocalDate.parse("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/files/FileListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt similarity index 56% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt index 98a14d38..711b9e12 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt @@ -1,37 +1,37 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +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 FileListParamsTest { +internal class AssetListParamsTest { @Test fun create() { - FileListParams.builder() - .fileType("fileType") - .limit("limit") + AssetListParams.builder() + .fileType(AssetListParams.FileType.ALL) + .limit(1L) .path("path") .searchQuery("searchQuery") - .skip("skip") - .sort("sort") - .type(FileListParams.Type.FILE) + .skip(0L) + .sort(AssetListParams.Sort.ASC_NAME) + .type(AssetListParams.Type.FILE) .build() } @Test fun queryParams() { val params = - FileListParams.builder() - .fileType("fileType") - .limit("limit") + AssetListParams.builder() + .fileType(AssetListParams.FileType.ALL) + .limit(1L) .path("path") .searchQuery("searchQuery") - .skip("skip") - .sort("sort") - .type(FileListParams.Type.FILE) + .skip(0L) + .sort(AssetListParams.Sort.ASC_NAME) + .type(AssetListParams.Type.FILE) .build() val queryParams = params._queryParams() @@ -39,12 +39,12 @@ internal class FileListParamsTest { assertThat(queryParams) .isEqualTo( QueryParams.builder() - .put("fileType", "fileType") - .put("limit", "limit") + .put("fileType", "all") + .put("limit", "1") .put("path", "path") .put("searchQuery", "searchQuery") - .put("skip", "skip") - .put("sort", "sort") + .put("skip", "0") + .put("sort", "ASC_NAME") .put("type", "file") .build() ) @@ -52,7 +52,7 @@ internal class FileListParamsTest { @Test fun queryParamsWithoutOptionalFields() { - val params = FileListParams.builder().build() + val params = AssetListParams.builder().build() val queryParams = params._queryParams() 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..b54b0df8 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt @@ -0,0 +1,170 @@ +// 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 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 ofFileDetails() { + val fileDetails = + AssetListResponse.FileDetails.builder() + .addAiTag( + AssetListResponse.FileDetails.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + AssetListResponse.FileDetails.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .width(0.0) + .build() + + val assetListResponse = AssetListResponse.ofFileDetails(fileDetails) + + assertThat(assetListResponse.fileDetails()).contains(fileDetails) + assertThat(assetListResponse.folderDetails()).isEmpty + } + + @Test + fun ofFileDetailsRoundtrip() { + val jsonMapper = jsonMapper() + val assetListResponse = + AssetListResponse.ofFileDetails( + AssetListResponse.FileDetails.builder() + .addAiTag( + AssetListResponse.FileDetails.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + AssetListResponse.FileDetails.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 ofFolderDetails() { + val folderDetails = + AssetListResponse.FolderDetails.builder() + .createdAt("createdAt") + .folderId("folderId") + .folderPath("folderPath") + .name("name") + .type(AssetListResponse.FolderDetails.Type.FOLDER) + .updatedAt("updatedAt") + .build() + + val assetListResponse = AssetListResponse.ofFolderDetails(folderDetails) + + assertThat(assetListResponse.fileDetails()).isEmpty + assertThat(assetListResponse.folderDetails()).contains(folderDetails) + } + + @Test + fun ofFolderDetailsRoundtrip() { + val jsonMapper = jsonMapper() + val assetListResponse = + AssetListResponse.ofFolderDetails( + AssetListResponse.FolderDetails.builder() + .createdAt("createdAt") + .folderId("folderId") + .folderPath("folderPath") + .name("name") + .type(AssetListResponse.FolderDetails.Type.FOLDER) + .updatedAt("updatedAt") + .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..f34d18bc --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -0,0 +1,330 @@ +// 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") + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name(FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .build() + ) + .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.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() + .protocol( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.Type + .ABS + ) + .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") + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING + ) + .build() + ) + .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.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() + .protocol( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .Type + .ABS + ) + .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.ofRemovedotBg( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name + .REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension + .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() + ), + ) + ), + "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.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post + .GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .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..8fa7013f --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt @@ -0,0 +1,437 @@ +// 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 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(JsonValue.from(mapOf())) + .duration(0L) + .embeddedMetadata( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + FileUploadResponse.ExtensionStatus.builder() + .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( + FileUploadResponse.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadResponse.Metadata.Exif.builder() + .exif( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) + .image( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadResponse.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + FileUploadResponse.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()) + .isEqualTo(JsonValue.from(mapOf())) + 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() + .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( + FileUploadResponse.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadResponse.Metadata.Exif.builder() + .exif( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) + .image( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadResponse.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + FileUploadResponse.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(JsonValue.from(mapOf())) + .duration(0L) + .embeddedMetadata( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + FileUploadResponse.ExtensionStatus.builder() + .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( + FileUploadResponse.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadResponse.Metadata.Exif.builder() + .exif( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) + .image( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadResponse.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + FileUploadResponse.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/bulkjobs/BulkJobCopyFolderResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponseTest.kt deleted file mode 100644 index 4038db3e..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.bulkjobs - -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 BulkJobCopyFolderResponseTest { - - @Test - fun create() { - val bulkJobCopyFolderResponse = BulkJobCopyFolderResponse.builder().jobId("jobId").build() - - assertThat(bulkJobCopyFolderResponse.jobId()).contains("jobId") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkJobCopyFolderResponse = BulkJobCopyFolderResponse.builder().jobId("jobId").build() - - val roundtrippedBulkJobCopyFolderResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkJobCopyFolderResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkJobCopyFolderResponse).isEqualTo(bulkJobCopyFolderResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponseTest.kt deleted file mode 100644 index 836bde09..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.bulkjobs - -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 BulkJobMoveFolderResponseTest { - - @Test - fun create() { - val bulkJobMoveFolderResponse = BulkJobMoveFolderResponse.builder().jobId("jobId").build() - - assertThat(bulkJobMoveFolderResponse.jobId()).contains("jobId") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkJobMoveFolderResponse = BulkJobMoveFolderResponse.builder().jobId("jobId").build() - - val roundtrippedBulkJobMoveFolderResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkJobMoveFolderResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkJobMoveFolderResponse).isEqualTo(bulkJobMoveFolderResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponseTest.kt deleted file mode 100644 index 5b4f7ca8..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusResponseTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.bulkjobs - -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 BulkJobRetrieveStatusResponseTest { - - @Test - fun create() { - val bulkJobRetrieveStatusResponse = - BulkJobRetrieveStatusResponse.builder() - .jobId("5d5b1a9b4c8c4c0001f3e4a2") - .status("Completed") - .type("COPY_FOLDER") - .build() - - assertThat(bulkJobRetrieveStatusResponse.jobId()).contains("5d5b1a9b4c8c4c0001f3e4a2") - assertThat(bulkJobRetrieveStatusResponse.status()).contains("Completed") - assertThat(bulkJobRetrieveStatusResponse.type()).contains("COPY_FOLDER") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkJobRetrieveStatusResponse = - BulkJobRetrieveStatusResponse.builder() - .jobId("5d5b1a9b4c8c4c0001f3e4a2") - .status("Completed") - .type("COPY_FOLDER") - .build() - - val roundtrippedBulkJobRetrieveStatusResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkJobRetrieveStatusResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkJobRetrieveStatusResponse) - .isEqualTo(bulkJobRetrieveStatusResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt similarity index 75% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt index 0fbd833e..94ef7b2c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.purge +package com.imagekit.api.models.cache.invalidation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class PurgeExecuteParamsTest { +internal class InvalidationCreateParamsTest { @Test fun create() { - PurgeExecuteParams.builder() + InvalidationCreateParams.builder() .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") .build() } @@ -17,7 +17,7 @@ internal class PurgeExecuteParamsTest { @Test fun body() { val params = - PurgeExecuteParams.builder() + InvalidationCreateParams.builder() .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") .build() 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/files/purge/PurgeStatusParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt similarity index 60% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt index ac95f1a3..452b8982 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.purge +package com.imagekit.api.models.cache.invalidation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class PurgeStatusParamsTest { +internal class InvalidationGetParamsTest { @Test fun create() { - PurgeStatusParams.builder().requestId("requestId").build() + InvalidationGetParams.builder().requestId("requestId").build() } @Test fun pathParams() { - val params = PurgeStatusParams.builder().requestId("requestId").build() + val params = InvalidationGetParams.builder().requestId("requestId").build() assertThat(params._pathParam(0)).isEqualTo("requestId") // out-of-bound path param 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/files/ExifDetailsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifDetailsTest.kt deleted file mode 100644 index bb999288..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifDetailsTest.kt +++ /dev/null @@ -1,113 +0,0 @@ -// 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 ExifDetailsTest { - - @Test - fun create() { - val exifDetails = - ExifDetails.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() - - assertThat(exifDetails.apertureValue()).contains(0.0) - assertThat(exifDetails.colorSpace()).contains(0L) - assertThat(exifDetails.createDate()).contains("CreateDate") - assertThat(exifDetails.customRendered()).contains(0L) - assertThat(exifDetails.dateTimeOriginal()).contains("DateTimeOriginal") - assertThat(exifDetails.exifImageHeight()).contains(0L) - assertThat(exifDetails.exifImageWidth()).contains(0L) - assertThat(exifDetails.exifVersion()).contains("ExifVersion") - assertThat(exifDetails.exposureCompensation()).contains(0.0) - assertThat(exifDetails.exposureMode()).contains(0L) - assertThat(exifDetails.exposureProgram()).contains(0L) - assertThat(exifDetails.exposureTime()).contains(0.0) - assertThat(exifDetails.flash()).contains(0L) - assertThat(exifDetails.flashpixVersion()).contains("FlashpixVersion") - assertThat(exifDetails.fNumber()).contains(0.0) - assertThat(exifDetails.focalLength()).contains(0L) - assertThat(exifDetails.focalPlaneResolutionUnit()).contains(0L) - assertThat(exifDetails.focalPlaneXResolution()).contains(0.0) - assertThat(exifDetails.focalPlaneYResolution()).contains(0.0) - assertThat(exifDetails.interopOffset()).contains(0L) - assertThat(exifDetails.iso()).contains(0L) - assertThat(exifDetails.meteringMode()).contains(0L) - assertThat(exifDetails.sceneCaptureType()).contains(0L) - assertThat(exifDetails.shutterSpeedValue()).contains(0.0) - assertThat(exifDetails.subSecTime()).contains("SubSecTime") - assertThat(exifDetails.whiteBalance()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val exifDetails = - ExifDetails.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() - - val roundtrippedExifDetails = - jsonMapper.readValue( - jsonMapper.writeValueAsString(exifDetails), - jacksonTypeRef(), - ) - - assertThat(roundtrippedExifDetails).isEqualTo(exifDetails) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifImageTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifImageTest.kt deleted file mode 100644 index 19d1e50e..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ExifImageTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -// 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 ExifImageTest { - - @Test - fun create() { - val exifImage = - ExifImage.builder() - .exifOffset(0L) - .gpsInfo(0L) - .make("Make") - .model("Model") - .modifyDate("ModifyDate") - .orientation(0L) - .resolutionUnit(0L) - .software("Software") - .xResolution(0L) - .yCbCrPositioning(0L) - .yResolution(0L) - .build() - - assertThat(exifImage.exifOffset()).contains(0L) - assertThat(exifImage.gpsInfo()).contains(0L) - assertThat(exifImage.make()).contains("Make") - assertThat(exifImage.model()).contains("Model") - assertThat(exifImage.modifyDate()).contains("ModifyDate") - assertThat(exifImage.orientation()).contains(0L) - assertThat(exifImage.resolutionUnit()).contains(0L) - assertThat(exifImage.software()).contains("Software") - assertThat(exifImage.xResolution()).contains(0L) - assertThat(exifImage.yCbCrPositioning()).contains(0L) - assertThat(exifImage.yResolution()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val exifImage = - ExifImage.builder() - .exifOffset(0L) - .gpsInfo(0L) - .make("Make") - .model("Model") - .modifyDate("ModifyDate") - .orientation(0L) - .resolutionUnit(0L) - .software("Software") - .xResolution(0L) - .yCbCrPositioning(0L) - .yResolution(0L) - .build() - - val roundtrippedExifImage = - jsonMapper.readValue( - jsonMapper.writeValueAsString(exifImage), - jacksonTypeRef(), - ) - - assertThat(roundtrippedExifImage).isEqualTo(exifImage) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsResponseTest.kt deleted file mode 100644 index 02f7e41d..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsResponseTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FileAddTagsResponseTest { - - @Test - fun create() { - val fileAddTagsResponse = - FileAddTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() - - assertThat(fileAddTagsResponse.successfullyUpdatedFileIds().getOrNull()) - .containsExactly("string") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val fileAddTagsResponse = - FileAddTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() - - val roundtrippedFileAddTagsResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fileAddTagsResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFileAddTagsResponse).isEqualTo(fileAddTagsResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt similarity index 61% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt index 38bd15de..633e0e5e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.details +package com.imagekit.api.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class DetailRetrieveParamsTest { +internal class FileGetParamsTest { @Test fun create() { - DetailRetrieveParams.builder().fileId("fileId").build() + FileGetParams.builder().fileId("fileId").build() } @Test fun pathParams() { - val params = DetailRetrieveParams.builder().fileId("fileId").build() + val params = FileGetParams.builder().fileId("fileId").build() assertThat(params._pathParam(0)).isEqualTo("fileId") // out-of-bound path param diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt similarity index 53% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt index 10b34caf..956cdfb6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt @@ -9,14 +9,14 @@ import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileListResponseTest { +internal class FileGetResponseTest { @Test fun create() { - val fileListResponse = - FileListResponse.builder() + val fileGetResponse = + FileGetResponse.builder() .addAiTag( - FileListResponse.AiTag.builder() + FileGetResponse.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -40,49 +40,49 @@ internal class FileListResponseTest { .type("type") .updatedAt("updatedAt") .url("url") - .versionInfo(FileListResponse.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() - assertThat(fileListResponse.aiTags().getOrNull()) + assertThat(fileGetResponse.aiTags().getOrNull()) .containsExactly( - FileListResponse.AiTag.builder() + FileGetResponse.AiTag.builder() .confidence(0.0) .name("name") .source("source") .build() ) - assertThat(fileListResponse.createdAt()).contains("createdAt") - assertThat(fileListResponse.customCoordinates()).contains("customCoordinates") - assertThat(fileListResponse._customMetadata()) + assertThat(fileGetResponse.createdAt()).contains("createdAt") + assertThat(fileGetResponse.customCoordinates()).contains("customCoordinates") + assertThat(fileGetResponse._customMetadata()) .isEqualTo(JsonValue.from(mapOf())) - assertThat(fileListResponse.fileId()).contains("fileId") - assertThat(fileListResponse.filePath()).contains("filePath") - assertThat(fileListResponse.fileType()).contains("fileType") - assertThat(fileListResponse.hasAlpha()).contains(true) - assertThat(fileListResponse.height()).contains(0.0) - assertThat(fileListResponse.isPrivateFile()).contains(true) - assertThat(fileListResponse.isPublished()).contains(true) - assertThat(fileListResponse.mime()).contains("mime") - assertThat(fileListResponse.name()).contains("name") - assertThat(fileListResponse.size()).contains(0.0) - assertThat(fileListResponse.tags().getOrNull()).containsExactly("string") - assertThat(fileListResponse.thumbnail()).contains("thumbnail") - assertThat(fileListResponse.type()).contains("type") - assertThat(fileListResponse.updatedAt()).contains("updatedAt") - assertThat(fileListResponse.url()).contains("url") - assertThat(fileListResponse.versionInfo()) - .contains(FileListResponse.VersionInfo.builder().id("id").name("name").build()) - assertThat(fileListResponse.width()).contains(0.0) + assertThat(fileGetResponse.fileId()).contains("fileId") + assertThat(fileGetResponse.filePath()).contains("filePath") + assertThat(fileGetResponse.fileType()).contains("fileType") + assertThat(fileGetResponse.hasAlpha()).contains(true) + assertThat(fileGetResponse.height()).contains(0.0) + assertThat(fileGetResponse.isPrivateFile()).contains(true) + assertThat(fileGetResponse.isPublished()).contains(true) + assertThat(fileGetResponse.mime()).contains("mime") + assertThat(fileGetResponse.name()).contains("name") + assertThat(fileGetResponse.size()).contains(0.0) + assertThat(fileGetResponse.tags().getOrNull()).containsExactly("string") + assertThat(fileGetResponse.thumbnail()).contains("thumbnail") + assertThat(fileGetResponse.type()).contains("type") + assertThat(fileGetResponse.updatedAt()).contains("updatedAt") + assertThat(fileGetResponse.url()).contains("url") + assertThat(fileGetResponse.versionInfo()) + .contains(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileGetResponse.width()).contains(0.0) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val fileListResponse = - FileListResponse.builder() + val fileGetResponse = + FileGetResponse.builder() .addAiTag( - FileListResponse.AiTag.builder() + FileGetResponse.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -106,16 +106,16 @@ internal class FileListResponseTest { .type("type") .updatedAt("updatedAt") .url("url") - .versionInfo(FileListResponse.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() - val roundtrippedFileListResponse = + val roundtrippedFileGetResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(fileListResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileGetResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedFileListResponse).isEqualTo(fileListResponse) + assertThat(roundtrippedFileGetResponse).isEqualTo(fileGetResponse) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponseTest.kt deleted file mode 100644 index ae58571c..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsResponseTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FileRemoveAiTagsResponseTest { - - @Test - fun create() { - val fileRemoveAiTagsResponse = - FileRemoveAiTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() - - assertThat(fileRemoveAiTagsResponse.successfullyUpdatedFileIds().getOrNull()) - .containsExactly("string") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val fileRemoveAiTagsResponse = - FileRemoveAiTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() - - val roundtrippedFileRemoveAiTagsResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fileRemoveAiTagsResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFileRemoveAiTagsResponse).isEqualTo(fileRemoveAiTagsResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponseTest.kt deleted file mode 100644 index 314af3ce..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsResponseTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FileRemoveTagsResponseTest { - - @Test - fun create() { - val fileRemoveTagsResponse = - FileRemoveTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() - - assertThat(fileRemoveTagsResponse.successfullyUpdatedFileIds().getOrNull()) - .containsExactly("string") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val fileRemoveTagsResponse = - FileRemoveTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() - - val roundtrippedFileRemoveTagsResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fileRemoveTagsResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFileRemoveTagsResponse).isEqualTo(fileRemoveTagsResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt similarity index 61% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index 388987cc..34db684e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -1,36 +1,37 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.details +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 DetailUpdateParamsTest { +internal class FileUpdateParamsTest { @Test fun create() { - DetailUpdateParams.builder() + FileUpdateParams.builder() .fileId("fileId") .body( - DetailUpdateParams.Body.UpdateFileDetails.builder() + FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .description("description") .extensions( listOf( - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -42,34 +43,46 @@ internal class DetailUpdateParamsTest { ) .build() ), - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -83,7 +96,7 @@ internal class DetailUpdateParamsTest { @Test fun pathParams() { - val params = DetailUpdateParams.builder().fileId("fileId").build() + val params = FileUpdateParams.builder().fileId("fileId").build() assertThat(params._pathParam(0)).isEqualTo("fileId") // out-of-bound path param @@ -93,26 +106,27 @@ internal class DetailUpdateParamsTest { @Test fun body() { val params = - DetailUpdateParams.builder() + FileUpdateParams.builder() .fileId("fileId") .body( - DetailUpdateParams.Body.UpdateFileDetails.builder() + FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .description("description") .extensions( listOf( - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -124,34 +138,46 @@ internal class DetailUpdateParamsTest { ) .build() ), - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -166,24 +192,25 @@ internal class DetailUpdateParamsTest { assertThat(body) .isEqualTo( - DetailUpdateParams.Body.ofUpdateFileDetails( - DetailUpdateParams.Body.UpdateFileDetails.builder() + FileUpdateParams.Body.ofUpdateFileDetails( + FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .description("description") .extensions( listOf( - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -195,34 +222,46 @@ internal class DetailUpdateParamsTest { ) .build() ), - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - DetailUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - DetailUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -236,7 +275,7 @@ internal class DetailUpdateParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = DetailUpdateParams.builder().fileId("fileId").build() + 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..0ffc1b09 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt @@ -0,0 +1,154 @@ +// 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 FileUpdateResponseTest { + + @Test + fun create() { + val fileUpdateResponse = + FileUpdateResponse.builder() + .addAiTag( + FileUpdateResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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() + ) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .build() + + assertThat(fileUpdateResponse.aiTags().getOrNull()) + .containsExactly( + FileUpdateResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(fileUpdateResponse.createdAt()).contains("createdAt") + assertThat(fileUpdateResponse.customCoordinates()).contains("customCoordinates") + assertThat(fileUpdateResponse._customMetadata()) + .isEqualTo(JsonValue.from(mapOf())) + 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() + ) + 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("thumbnail") + assertThat(fileUpdateResponse.type()).contains("type") + assertThat(fileUpdateResponse.updatedAt()).contains("updatedAt") + assertThat(fileUpdateResponse.url()).contains("url") + assertThat(fileUpdateResponse.versionInfo()) + .contains(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileUpdateResponse.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileUpdateResponse = + FileUpdateResponse.builder() + .addAiTag( + FileUpdateResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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() + ) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .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..212f5dfc --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -0,0 +1,339 @@ +// 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) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name(FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .build() + ) + .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.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() + .protocol( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.Type + .ABS + ) + .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) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING + ) + .build() + ) + .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.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() + .protocol( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .Type + .ABS + ) + .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.ofRemovedotBg( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name + .REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension + .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() + ), + ) + ), + "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.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post + .GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .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..fa9f7de7 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt @@ -0,0 +1,437 @@ +// 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(JsonValue.from(mapOf())) + .duration(0L) + .embeddedMetadata( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + FileUploadResponse.ExtensionStatus.builder() + .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( + FileUploadResponse.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadResponse.Metadata.Exif.builder() + .exif( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) + .image( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadResponse.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + FileUploadResponse.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()) + .isEqualTo(JsonValue.from(mapOf())) + 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() + .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( + FileUploadResponse.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadResponse.Metadata.Exif.builder() + .exif( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) + .image( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadResponse.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + FileUploadResponse.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(JsonValue.from(mapOf())) + .duration(0L) + .embeddedMetadata( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + FileUploadResponse.ExtensionStatus.builder() + .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( + FileUploadResponse.Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + FileUploadResponse.Metadata.Exif.builder() + .exif( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) + .image( + FileUploadResponse.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( + FileUploadResponse.Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + FileUploadResponse.Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + FileUploadResponse.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/FileUploadV1ParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ParamsTest.kt deleted file mode 100644 index 2851c583..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ParamsTest.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files - -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 FileUploadV1ParamsTest { - - @Test - fun create() { - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata("\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n") - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" - ) - .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) - .publicKey("publicKey") - .responseFields("responseFields") - .signature("signature") - .tags("t-shirt,round-neck,men") - .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" - ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") - .build() - } - - @Test - fun body() { - val params = - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" - ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" - ) - .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) - .publicKey("publicKey") - .responseFields("responseFields") - .signature("signature") - .tags("t-shirt,round-neck,men") - .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" - ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") - .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("https://www.example.com/rest-of-the-image-path.jpg"), - "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( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" - ), - "expire" to MultipartField.of("expire"), - "extensions" to - MultipartField.of( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" - ), - "folder" to MultipartField.of("folder"), - "isPrivateFile" to MultipartField.of(FileUploadV1Params.IsPrivateFile.TRUE), - "isPublished" to MultipartField.of(FileUploadV1Params.IsPublished.TRUE), - "overwriteAITags" to - MultipartField.of(FileUploadV1Params.OverwriteAiTags.TRUE), - "overwriteCustomMetadata" to - MultipartField.of(FileUploadV1Params.OverwriteCustomMetadata.TRUE), - "overwriteFile" to MultipartField.of("overwriteFile"), - "overwriteTags" to MultipartField.of(FileUploadV1Params.OverwriteTags.TRUE), - "publicKey" to MultipartField.of("publicKey"), - "responseFields" to MultipartField.of("responseFields"), - "signature" to MultipartField.of("signature"), - "tags" to MultipartField.of("t-shirt,round-neck,men"), - "transformation" to - MultipartField.of( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" - ), - "useUniqueFileName" to - MultipartField.of(FileUploadV1Params.UseUniqueFileName.TRUE), - "webhookUrl" to MultipartField.of("webhookUrl"), - ) - .mapValues { (_, field) -> - field.map { (it as? ByteArray)?.inputStream() ?: it } - } - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") - .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("https://www.example.com/rest-of-the-image-path.jpg"), - "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/FileUploadV1ResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ResponseTest.kt deleted file mode 100644 index c5efd039..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV1ResponseTest.kt +++ /dev/null @@ -1,1335 +0,0 @@ -// 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 FileUploadV1ResponseTest { - - @Test - fun create() { - val fileUploadV1Response = - FileUploadV1Response.builder() - .addAiTag( - FileUploadV1Response.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .audioCodec("audioCodec") - .bitRate(0L) - .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) - .duration(0L) - .embeddedMetadata( - FileUploadV1Response.EmbeddedMetadata.builder() - .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") - .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") - .aboutCvTermName("CV-Term Name 1 (ref2019.1)") - .aboutCvTermRefinedAbout( - "http://example.com/cv/refinements2/ref2019.1/codeX145" - ) - .additionalModelInformation("Additional Model Info (ref2019.1)") - .applicationRecordVersion(4L) - .artist("Creator1 (ref2019.1)") - .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") - .artworkContentDescription("AO Content Description 1 (ref2019.1)") - .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") - .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") - .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") - .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") - .addArtworkCreator("AO Creator Name 1a (ref2019.1)") - .addArtworkCreator("AO Creator Name 1b (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") - .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) - .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") - .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") - .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") - .artworkSource("AO Source 1 (ref2019.1)") - .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") - .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") - .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") - .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") - .artworkTitle("AO Title 1 (ref2019.1)") - .authorsPosition("Creator's Job Title (ref2019.1)") - .byline("Creator1 (ref2019.1)") - .bylineTitle("Creator's Job Title (ref2019.1)") - .caption("The description aka caption (ref2019.1)") - .captionAbstract("The description aka caption (ref2019.1)") - .captionWriter("Description Writer (ref2019.1)") - .city("City (Core) (ref2019.1)") - .colorSpace("Uncalibrated") - .componentsConfiguration("Y,Cb,Cr,-") - .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .copyrightNotice( - "Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)" - ) - .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") - .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") - .country("Country (Core) (ref2019.1)") - .countryCode("R19") - .countryPrimaryLocationCode("R19") - .countryPrimaryLocationName("Country (Core) (ref2019.1)") - .creator("Creator1 (ref2019.1)") - .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") - .creatorCity("Creator's CI: City (ref2019.1)") - .creatorCountry("Creator's CI: Country (ref2019.1)") - .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") - .creatorRegion("Creator's CI: State/Province (ref2019.1)") - .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") - .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") - .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") - .credit("Credit Line (ref2019.1)") - .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) - .description("The description aka caption (ref2019.1)") - .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") - .digitalSourceType( - "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" - ) - .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") - .embeddedEncodedRightsExprLangId( - "http://example.org/RELids/id4711/ref2019.1" - ) - .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .event("An Event (ref2019.1)") - .exifVersion("0232") - .flashpixVersion("0100") - .genreCvId("http://example.com/cv/genre/ref2019.1") - .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") - .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") - .genreCvTermRefinedAbout( - "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" - ) - .headline("The Headline (ref2019.1)") - .imageCreatorId("Image Creator Id 1 (ref2019.1)") - .imageCreatorImageId("Image Creator Image ID (ref2019.1)") - .imageCreatorName("Image Creator Name 1 (ref2019.1)") - .imageDescription("The description aka caption (ref2019.1)") - .addImageRegionBoundaryH(0.385) - .addImageRegionBoundaryRx(0.068) - .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) - .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) - .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) - .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) - .addImageRegionBoundaryW(0.127) - .addImageRegionBoundaryX(0.31) - .addImageRegionBoundaryX(0.59) - .addImageRegionBoundaryY(0.18) - .addImageRegionBoundaryY(0.426) - .imageRegionCtypeIdentifier( - listOf( - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - ) - ) - .imageRegionCtypeName( - listOf( - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - ) - ) - .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) - .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) - .imageRegionOrganisationInImageName( - listOf( - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr3 (ref2019.1)", - ) - ) - .imageRegionPersonInImage( - listOf( - "Person name no 1 in region persltr2 (ref2019.1)", - "Person name no 1 in region persltr3 (ref2019.1)", - "Person name no 1 in region persltr1 (ref2019.1)", - ) - ) - .imageRegionRoleIdentifier( - listOf( - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - ) - ) - .imageRegionRoleName( - listOf( - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - ) - ) - .imageSupplierId("Image Supplier Id (ref2019.1)") - .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") - .imageSupplierName("Image Supplier Name (ref2019.1)") - .instructions("An Instruction (ref2019.1)") - .intellectualGenre("A Genre (ref2019.1)") - .keywords( - listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") - ) - .addLicensorCity("Licensor City 1 (ref2019.1)") - .addLicensorCity("Licensor City 2 (ref2019.1)") - .addLicensorCountry("Licensor Country 1 (ref2019.1)") - .addLicensorCountry("Licensor Country 2 (ref2019.1)") - .addLicensorEmail("Licensor Email 1 (ref2019.1)") - .addLicensorEmail("Licensor Email 2 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") - .addLicensorId("Licensor ID 1 (ref2019.1)") - .addLicensorId("Licensor ID 2 (ref2019.1)") - .addLicensorName("Licensor Name 1 (ref2019.1)") - .addLicensorName("Licensor Name 2 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") - .addLicensorRegion("Licensor Region 1 (ref2019.1)") - .addLicensorRegion("Licensor Region 2 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") - .addLicensorUrl("Licensor URL 1 (ref2019.1)") - .addLicensorUrl("Licensor URL 2 (ref2019.1)") - .linkedEncodedRightsExpr( - "http://example.org/linkedrightsexpression/id986/ref2019.1" - ) - .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") - .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .location("Sublocation (Core) (ref2019.1)") - .locationCreatedCity("City (Location created1) (ref2019.1)") - .locationCreatedCountryCode("R17") - .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") - .locationCreatedGpsAltitude("480 m") - .locationCreatedGpsLatitude("48,16.5N") - .locationCreatedGpsLongitude("16,20.28E") - .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") - .locationCreatedLocationName( - "Location Name (Location created1) (ref2019.1)" - ) - .locationCreatedProvinceState( - "Province/State (Location created1) (ref2019.1)" - ) - .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") - .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") - .addLocationShownCity("City (Location shown1) (ref2019.1)") - .addLocationShownCity("City (Location shown2) (ref2019.1)") - .addLocationShownCountryCode("R17") - .addLocationShownCountryCode("R17") - .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") - .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") - .addLocationShownGpsAltitude("140 m") - .addLocationShownGpsAltitude("120 m") - .addLocationShownGpsLatitude("48,8.82N") - .addLocationShownGpsLatitude("47,57.12N") - .addLocationShownGpsLongitude("17,5.88E") - .addLocationShownGpsLongitude("16,49.8E") - .locationShownLocationId( - listOf( - "Location Id 1a(Location shown1) (ref2019.1)", - "Location Id 1b(Location shown1) (ref2019.1)", - "Location Id 2a(Location shown2) (ref2019.1)", - "Location Id 2b(Location shown2) (ref2019.1)", - ) - ) - .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") - .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") - .addLocationShownProvinceState( - "Province/State (Location shown1) (ref2019.1)" - ) - .addLocationShownProvinceState( - "Province/State (Location shown2) (ref2019.1)" - ) - .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") - .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") - .maxAvailHeight(20.0) - .maxAvailWidth(19.0) - .modelAge(listOf(25.0, 27.0, 30.0)) - .addModelReleaseId("Model Release ID 1 (ref2019.1)") - .addModelReleaseId("Model Release ID 2 (ref2019.1)") - .objectAttributeReference("A Genre (ref2019.1)") - .objectName("The Title (ref2019.1)") - .offsetTimeOriginal("+00:00") - .organisationInImageCode( - listOf( - "Organisation Code 1 (ref2019.1)", - "Organisation Code 2 (ref2019.1)", - "Organisation Code 3 (ref2019.1)", - ) - ) - .organisationInImageName( - listOf( - "Organisation Name 1 (ref2019.1)", - "Organisation Name 2 (ref2019.1)", - "Organisation Name 3 (ref2019.1)", - ) - ) - .orientation("Horizontal (normal)") - .originalTransmissionReference("Job Id (ref2019.1)") - .addPersonInImage("Person Shown 1 (ref2019.1)") - .addPersonInImage("Person Shown 2 (ref2019.1)") - .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") - .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") - .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") - .addPersonInImageCvTermRefinedAbout( - "http://example.com/cv/refinements987/codeY765/ref2019.1" - ) - .addPersonInImageDescription("Person Description 1 (ref2019.1)") - .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") - .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") - .addPersonInImageName("Person Name 1 (ref2019.1)") - .addProductInImageDescription("Product Description 1 (ref2019.1)") - .addProductInImageGtin(123456782019.1) - .addProductInImageName("Product Name 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") - .provinceState("Province/State(Core)(ref2019.1)") - .rating(1L) - .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") - .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") - .addRegistryItemId("Registry Image ID 1 (ref2019.1)") - .addRegistryItemId("Registry Image ID 2 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") - .resolutionUnit("inches") - .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .addScene("IPTC-Scene-Code1 (ref2019.1)") - .addScene("IPTC-Scene-Code2 (ref2019.1)") - .source("Source (ref2019.1)") - .specialInstructions("An Instruction (ref2019.1)") - .state("Province/State(Core)(ref2019.1)") - .subject( - listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") - ) - .subjectCode( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .subjectReference( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .sublocation("Sublocation (Core) (ref2019.1)") - .timeCreated("19:01:03+00:00") - .title("The Title (ref2019.1)") - .transmissionReference("Job Id (ref2019.1)") - .usageTerms("Rights Usage Terms (ref2019.1)") - .webStatement("http://www.WebStatementOfRights.org/2019.1") - .writer("Description Writer (ref2019.1)") - .writerEditor("Description Writer (ref2019.1)") - .xResolution(72.0) - .yResolution(72.0) - .build() - ) - .extensionStatus( - FileUploadV1Response.ExtensionStatus.builder() - .awsAutoTagging(FileUploadV1Response.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - FileUploadV1Response.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(FileUploadV1Response.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - .fileId("fileId") - .filePath("filePath") - .fileType("fileType") - .height(0.0) - .isPrivateFile(true) - .isPublished(true) - .metadata( - FileUploadV1Response.Metadata.builder() - .audioCodec("audioCodec") - .bitRate(0L) - .density(0L) - .duration(0L) - .exif( - FileUploadV1Response.Metadata.Exif.builder() - .exif( - ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) - .image( - ExifImage.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( - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - FileUploadV1Response.Metadata.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - 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( - FileUploadV1Response.VersionInfo.builder().id("id").name("name").build() - ) - .videoCodec("videoCodec") - .width(0.0) - .build() - - assertThat(fileUploadV1Response.aiTags().getOrNull()) - .containsExactly( - FileUploadV1Response.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - assertThat(fileUploadV1Response.audioCodec()).contains("audioCodec") - assertThat(fileUploadV1Response.bitRate()).contains(0L) - assertThat(fileUploadV1Response.customCoordinates()).contains("customCoordinates") - assertThat(fileUploadV1Response._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(fileUploadV1Response.duration()).contains(0L) - assertThat(fileUploadV1Response.embeddedMetadata()) - .contains( - FileUploadV1Response.EmbeddedMetadata.builder() - .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") - .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") - .aboutCvTermName("CV-Term Name 1 (ref2019.1)") - .aboutCvTermRefinedAbout( - "http://example.com/cv/refinements2/ref2019.1/codeX145" - ) - .additionalModelInformation("Additional Model Info (ref2019.1)") - .applicationRecordVersion(4L) - .artist("Creator1 (ref2019.1)") - .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") - .artworkContentDescription("AO Content Description 1 (ref2019.1)") - .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") - .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") - .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") - .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") - .addArtworkCreator("AO Creator Name 1a (ref2019.1)") - .addArtworkCreator("AO Creator Name 1b (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") - .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) - .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") - .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") - .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") - .artworkSource("AO Source 1 (ref2019.1)") - .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") - .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") - .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") - .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") - .artworkTitle("AO Title 1 (ref2019.1)") - .authorsPosition("Creator's Job Title (ref2019.1)") - .byline("Creator1 (ref2019.1)") - .bylineTitle("Creator's Job Title (ref2019.1)") - .caption("The description aka caption (ref2019.1)") - .captionAbstract("The description aka caption (ref2019.1)") - .captionWriter("Description Writer (ref2019.1)") - .city("City (Core) (ref2019.1)") - .colorSpace("Uncalibrated") - .componentsConfiguration("Y,Cb,Cr,-") - .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .copyrightNotice("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") - .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") - .country("Country (Core) (ref2019.1)") - .countryCode("R19") - .countryPrimaryLocationCode("R19") - .countryPrimaryLocationName("Country (Core) (ref2019.1)") - .creator("Creator1 (ref2019.1)") - .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") - .creatorCity("Creator's CI: City (ref2019.1)") - .creatorCountry("Creator's CI: Country (ref2019.1)") - .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") - .creatorRegion("Creator's CI: State/Province (ref2019.1)") - .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") - .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") - .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") - .credit("Credit Line (ref2019.1)") - .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) - .description("The description aka caption (ref2019.1)") - .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") - .digitalSourceType( - "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" - ) - .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") - .embeddedEncodedRightsExprLangId("http://example.org/RELids/id4711/ref2019.1") - .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .event("An Event (ref2019.1)") - .exifVersion("0232") - .flashpixVersion("0100") - .genreCvId("http://example.com/cv/genre/ref2019.1") - .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") - .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") - .genreCvTermRefinedAbout( - "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" - ) - .headline("The Headline (ref2019.1)") - .imageCreatorId("Image Creator Id 1 (ref2019.1)") - .imageCreatorImageId("Image Creator Image ID (ref2019.1)") - .imageCreatorName("Image Creator Name 1 (ref2019.1)") - .imageDescription("The description aka caption (ref2019.1)") - .addImageRegionBoundaryH(0.385) - .addImageRegionBoundaryRx(0.068) - .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) - .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) - .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) - .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) - .addImageRegionBoundaryW(0.127) - .addImageRegionBoundaryX(0.31) - .addImageRegionBoundaryX(0.59) - .addImageRegionBoundaryY(0.18) - .addImageRegionBoundaryY(0.426) - .imageRegionCtypeIdentifier( - listOf( - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - ) - ) - .imageRegionCtypeName( - listOf( - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - ) - ) - .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) - .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) - .imageRegionOrganisationInImageName( - listOf( - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr3 (ref2019.1)", - ) - ) - .imageRegionPersonInImage( - listOf( - "Person name no 1 in region persltr2 (ref2019.1)", - "Person name no 1 in region persltr3 (ref2019.1)", - "Person name no 1 in region persltr1 (ref2019.1)", - ) - ) - .imageRegionRoleIdentifier( - listOf( - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - ) - ) - .imageRegionRoleName( - listOf( - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - ) - ) - .imageSupplierId("Image Supplier Id (ref2019.1)") - .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") - .imageSupplierName("Image Supplier Name (ref2019.1)") - .instructions("An Instruction (ref2019.1)") - .intellectualGenre("A Genre (ref2019.1)") - .keywords(listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1")) - .addLicensorCity("Licensor City 1 (ref2019.1)") - .addLicensorCity("Licensor City 2 (ref2019.1)") - .addLicensorCountry("Licensor Country 1 (ref2019.1)") - .addLicensorCountry("Licensor Country 2 (ref2019.1)") - .addLicensorEmail("Licensor Email 1 (ref2019.1)") - .addLicensorEmail("Licensor Email 2 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") - .addLicensorId("Licensor ID 1 (ref2019.1)") - .addLicensorId("Licensor ID 2 (ref2019.1)") - .addLicensorName("Licensor Name 1 (ref2019.1)") - .addLicensorName("Licensor Name 2 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") - .addLicensorRegion("Licensor Region 1 (ref2019.1)") - .addLicensorRegion("Licensor Region 2 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") - .addLicensorUrl("Licensor URL 1 (ref2019.1)") - .addLicensorUrl("Licensor URL 2 (ref2019.1)") - .linkedEncodedRightsExpr( - "http://example.org/linkedrightsexpression/id986/ref2019.1" - ) - .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") - .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .location("Sublocation (Core) (ref2019.1)") - .locationCreatedCity("City (Location created1) (ref2019.1)") - .locationCreatedCountryCode("R17") - .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") - .locationCreatedGpsAltitude("480 m") - .locationCreatedGpsLatitude("48,16.5N") - .locationCreatedGpsLongitude("16,20.28E") - .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") - .locationCreatedLocationName("Location Name (Location created1) (ref2019.1)") - .locationCreatedProvinceState("Province/State (Location created1) (ref2019.1)") - .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") - .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") - .addLocationShownCity("City (Location shown1) (ref2019.1)") - .addLocationShownCity("City (Location shown2) (ref2019.1)") - .addLocationShownCountryCode("R17") - .addLocationShownCountryCode("R17") - .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") - .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") - .addLocationShownGpsAltitude("140 m") - .addLocationShownGpsAltitude("120 m") - .addLocationShownGpsLatitude("48,8.82N") - .addLocationShownGpsLatitude("47,57.12N") - .addLocationShownGpsLongitude("17,5.88E") - .addLocationShownGpsLongitude("16,49.8E") - .locationShownLocationId( - listOf( - "Location Id 1a(Location shown1) (ref2019.1)", - "Location Id 1b(Location shown1) (ref2019.1)", - "Location Id 2a(Location shown2) (ref2019.1)", - "Location Id 2b(Location shown2) (ref2019.1)", - ) - ) - .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") - .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") - .addLocationShownProvinceState("Province/State (Location shown1) (ref2019.1)") - .addLocationShownProvinceState("Province/State (Location shown2) (ref2019.1)") - .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") - .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") - .maxAvailHeight(20.0) - .maxAvailWidth(19.0) - .modelAge(listOf(25.0, 27.0, 30.0)) - .addModelReleaseId("Model Release ID 1 (ref2019.1)") - .addModelReleaseId("Model Release ID 2 (ref2019.1)") - .objectAttributeReference("A Genre (ref2019.1)") - .objectName("The Title (ref2019.1)") - .offsetTimeOriginal("+00:00") - .organisationInImageCode( - listOf( - "Organisation Code 1 (ref2019.1)", - "Organisation Code 2 (ref2019.1)", - "Organisation Code 3 (ref2019.1)", - ) - ) - .organisationInImageName( - listOf( - "Organisation Name 1 (ref2019.1)", - "Organisation Name 2 (ref2019.1)", - "Organisation Name 3 (ref2019.1)", - ) - ) - .orientation("Horizontal (normal)") - .originalTransmissionReference("Job Id (ref2019.1)") - .addPersonInImage("Person Shown 1 (ref2019.1)") - .addPersonInImage("Person Shown 2 (ref2019.1)") - .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") - .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") - .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") - .addPersonInImageCvTermRefinedAbout( - "http://example.com/cv/refinements987/codeY765/ref2019.1" - ) - .addPersonInImageDescription("Person Description 1 (ref2019.1)") - .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") - .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") - .addPersonInImageName("Person Name 1 (ref2019.1)") - .addProductInImageDescription("Product Description 1 (ref2019.1)") - .addProductInImageGtin(123456782019.1) - .addProductInImageName("Product Name 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") - .provinceState("Province/State(Core)(ref2019.1)") - .rating(1L) - .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") - .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") - .addRegistryItemId("Registry Image ID 1 (ref2019.1)") - .addRegistryItemId("Registry Image ID 2 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") - .resolutionUnit("inches") - .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .addScene("IPTC-Scene-Code1 (ref2019.1)") - .addScene("IPTC-Scene-Code2 (ref2019.1)") - .source("Source (ref2019.1)") - .specialInstructions("An Instruction (ref2019.1)") - .state("Province/State(Core)(ref2019.1)") - .subject(listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1")) - .subjectCode(listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1")) - .subjectReference( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .sublocation("Sublocation (Core) (ref2019.1)") - .timeCreated("19:01:03+00:00") - .title("The Title (ref2019.1)") - .transmissionReference("Job Id (ref2019.1)") - .usageTerms("Rights Usage Terms (ref2019.1)") - .webStatement("http://www.WebStatementOfRights.org/2019.1") - .writer("Description Writer (ref2019.1)") - .writerEditor("Description Writer (ref2019.1)") - .xResolution(72.0) - .yResolution(72.0) - .build() - ) - assertThat(fileUploadV1Response.extensionStatus()) - .contains( - FileUploadV1Response.ExtensionStatus.builder() - .awsAutoTagging(FileUploadV1Response.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - FileUploadV1Response.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(FileUploadV1Response.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - assertThat(fileUploadV1Response.fileId()).contains("fileId") - assertThat(fileUploadV1Response.filePath()).contains("filePath") - assertThat(fileUploadV1Response.fileType()).contains("fileType") - assertThat(fileUploadV1Response.height()).contains(0.0) - assertThat(fileUploadV1Response.isPrivateFile()).contains(true) - assertThat(fileUploadV1Response.isPublished()).contains(true) - assertThat(fileUploadV1Response.metadata()) - .contains( - FileUploadV1Response.Metadata.builder() - .audioCodec("audioCodec") - .bitRate(0L) - .density(0L) - .duration(0L) - .exif( - FileUploadV1Response.Metadata.Exif.builder() - .exif( - ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) - .image( - ExifImage.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( - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - FileUploadV1Response.Metadata.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - 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(fileUploadV1Response.name()).contains("name") - assertThat(fileUploadV1Response.size()).contains(0.0) - assertThat(fileUploadV1Response.tags().getOrNull()).containsExactly("string") - assertThat(fileUploadV1Response.thumbnailUrl()).contains("thumbnailUrl") - assertThat(fileUploadV1Response.url()).contains("url") - assertThat(fileUploadV1Response.versionInfo()) - .contains(FileUploadV1Response.VersionInfo.builder().id("id").name("name").build()) - assertThat(fileUploadV1Response.videoCodec()).contains("videoCodec") - assertThat(fileUploadV1Response.width()).contains(0.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val fileUploadV1Response = - FileUploadV1Response.builder() - .addAiTag( - FileUploadV1Response.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .audioCodec("audioCodec") - .bitRate(0L) - .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) - .duration(0L) - .embeddedMetadata( - FileUploadV1Response.EmbeddedMetadata.builder() - .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") - .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") - .aboutCvTermName("CV-Term Name 1 (ref2019.1)") - .aboutCvTermRefinedAbout( - "http://example.com/cv/refinements2/ref2019.1/codeX145" - ) - .additionalModelInformation("Additional Model Info (ref2019.1)") - .applicationRecordVersion(4L) - .artist("Creator1 (ref2019.1)") - .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") - .artworkContentDescription("AO Content Description 1 (ref2019.1)") - .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") - .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") - .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") - .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") - .addArtworkCreator("AO Creator Name 1a (ref2019.1)") - .addArtworkCreator("AO Creator Name 1b (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") - .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) - .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") - .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") - .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") - .artworkSource("AO Source 1 (ref2019.1)") - .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") - .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") - .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") - .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") - .artworkTitle("AO Title 1 (ref2019.1)") - .authorsPosition("Creator's Job Title (ref2019.1)") - .byline("Creator1 (ref2019.1)") - .bylineTitle("Creator's Job Title (ref2019.1)") - .caption("The description aka caption (ref2019.1)") - .captionAbstract("The description aka caption (ref2019.1)") - .captionWriter("Description Writer (ref2019.1)") - .city("City (Core) (ref2019.1)") - .colorSpace("Uncalibrated") - .componentsConfiguration("Y,Cb,Cr,-") - .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .copyrightNotice( - "Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)" - ) - .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") - .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") - .country("Country (Core) (ref2019.1)") - .countryCode("R19") - .countryPrimaryLocationCode("R19") - .countryPrimaryLocationName("Country (Core) (ref2019.1)") - .creator("Creator1 (ref2019.1)") - .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") - .creatorCity("Creator's CI: City (ref2019.1)") - .creatorCountry("Creator's CI: Country (ref2019.1)") - .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") - .creatorRegion("Creator's CI: State/Province (ref2019.1)") - .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") - .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") - .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") - .credit("Credit Line (ref2019.1)") - .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) - .description("The description aka caption (ref2019.1)") - .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") - .digitalSourceType( - "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" - ) - .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") - .embeddedEncodedRightsExprLangId( - "http://example.org/RELids/id4711/ref2019.1" - ) - .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .event("An Event (ref2019.1)") - .exifVersion("0232") - .flashpixVersion("0100") - .genreCvId("http://example.com/cv/genre/ref2019.1") - .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") - .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") - .genreCvTermRefinedAbout( - "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" - ) - .headline("The Headline (ref2019.1)") - .imageCreatorId("Image Creator Id 1 (ref2019.1)") - .imageCreatorImageId("Image Creator Image ID (ref2019.1)") - .imageCreatorName("Image Creator Name 1 (ref2019.1)") - .imageDescription("The description aka caption (ref2019.1)") - .addImageRegionBoundaryH(0.385) - .addImageRegionBoundaryRx(0.068) - .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) - .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) - .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) - .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) - .addImageRegionBoundaryW(0.127) - .addImageRegionBoundaryX(0.31) - .addImageRegionBoundaryX(0.59) - .addImageRegionBoundaryY(0.18) - .addImageRegionBoundaryY(0.426) - .imageRegionCtypeIdentifier( - listOf( - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - ) - ) - .imageRegionCtypeName( - listOf( - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - ) - ) - .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) - .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) - .imageRegionOrganisationInImageName( - listOf( - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr3 (ref2019.1)", - ) - ) - .imageRegionPersonInImage( - listOf( - "Person name no 1 in region persltr2 (ref2019.1)", - "Person name no 1 in region persltr3 (ref2019.1)", - "Person name no 1 in region persltr1 (ref2019.1)", - ) - ) - .imageRegionRoleIdentifier( - listOf( - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - ) - ) - .imageRegionRoleName( - listOf( - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - ) - ) - .imageSupplierId("Image Supplier Id (ref2019.1)") - .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") - .imageSupplierName("Image Supplier Name (ref2019.1)") - .instructions("An Instruction (ref2019.1)") - .intellectualGenre("A Genre (ref2019.1)") - .keywords( - listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") - ) - .addLicensorCity("Licensor City 1 (ref2019.1)") - .addLicensorCity("Licensor City 2 (ref2019.1)") - .addLicensorCountry("Licensor Country 1 (ref2019.1)") - .addLicensorCountry("Licensor Country 2 (ref2019.1)") - .addLicensorEmail("Licensor Email 1 (ref2019.1)") - .addLicensorEmail("Licensor Email 2 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") - .addLicensorId("Licensor ID 1 (ref2019.1)") - .addLicensorId("Licensor ID 2 (ref2019.1)") - .addLicensorName("Licensor Name 1 (ref2019.1)") - .addLicensorName("Licensor Name 2 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") - .addLicensorRegion("Licensor Region 1 (ref2019.1)") - .addLicensorRegion("Licensor Region 2 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") - .addLicensorUrl("Licensor URL 1 (ref2019.1)") - .addLicensorUrl("Licensor URL 2 (ref2019.1)") - .linkedEncodedRightsExpr( - "http://example.org/linkedrightsexpression/id986/ref2019.1" - ) - .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") - .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .location("Sublocation (Core) (ref2019.1)") - .locationCreatedCity("City (Location created1) (ref2019.1)") - .locationCreatedCountryCode("R17") - .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") - .locationCreatedGpsAltitude("480 m") - .locationCreatedGpsLatitude("48,16.5N") - .locationCreatedGpsLongitude("16,20.28E") - .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") - .locationCreatedLocationName( - "Location Name (Location created1) (ref2019.1)" - ) - .locationCreatedProvinceState( - "Province/State (Location created1) (ref2019.1)" - ) - .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") - .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") - .addLocationShownCity("City (Location shown1) (ref2019.1)") - .addLocationShownCity("City (Location shown2) (ref2019.1)") - .addLocationShownCountryCode("R17") - .addLocationShownCountryCode("R17") - .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") - .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") - .addLocationShownGpsAltitude("140 m") - .addLocationShownGpsAltitude("120 m") - .addLocationShownGpsLatitude("48,8.82N") - .addLocationShownGpsLatitude("47,57.12N") - .addLocationShownGpsLongitude("17,5.88E") - .addLocationShownGpsLongitude("16,49.8E") - .locationShownLocationId( - listOf( - "Location Id 1a(Location shown1) (ref2019.1)", - "Location Id 1b(Location shown1) (ref2019.1)", - "Location Id 2a(Location shown2) (ref2019.1)", - "Location Id 2b(Location shown2) (ref2019.1)", - ) - ) - .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") - .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") - .addLocationShownProvinceState( - "Province/State (Location shown1) (ref2019.1)" - ) - .addLocationShownProvinceState( - "Province/State (Location shown2) (ref2019.1)" - ) - .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") - .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") - .maxAvailHeight(20.0) - .maxAvailWidth(19.0) - .modelAge(listOf(25.0, 27.0, 30.0)) - .addModelReleaseId("Model Release ID 1 (ref2019.1)") - .addModelReleaseId("Model Release ID 2 (ref2019.1)") - .objectAttributeReference("A Genre (ref2019.1)") - .objectName("The Title (ref2019.1)") - .offsetTimeOriginal("+00:00") - .organisationInImageCode( - listOf( - "Organisation Code 1 (ref2019.1)", - "Organisation Code 2 (ref2019.1)", - "Organisation Code 3 (ref2019.1)", - ) - ) - .organisationInImageName( - listOf( - "Organisation Name 1 (ref2019.1)", - "Organisation Name 2 (ref2019.1)", - "Organisation Name 3 (ref2019.1)", - ) - ) - .orientation("Horizontal (normal)") - .originalTransmissionReference("Job Id (ref2019.1)") - .addPersonInImage("Person Shown 1 (ref2019.1)") - .addPersonInImage("Person Shown 2 (ref2019.1)") - .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") - .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") - .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") - .addPersonInImageCvTermRefinedAbout( - "http://example.com/cv/refinements987/codeY765/ref2019.1" - ) - .addPersonInImageDescription("Person Description 1 (ref2019.1)") - .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") - .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") - .addPersonInImageName("Person Name 1 (ref2019.1)") - .addProductInImageDescription("Product Description 1 (ref2019.1)") - .addProductInImageGtin(123456782019.1) - .addProductInImageName("Product Name 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") - .provinceState("Province/State(Core)(ref2019.1)") - .rating(1L) - .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") - .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") - .addRegistryItemId("Registry Image ID 1 (ref2019.1)") - .addRegistryItemId("Registry Image ID 2 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") - .resolutionUnit("inches") - .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .addScene("IPTC-Scene-Code1 (ref2019.1)") - .addScene("IPTC-Scene-Code2 (ref2019.1)") - .source("Source (ref2019.1)") - .specialInstructions("An Instruction (ref2019.1)") - .state("Province/State(Core)(ref2019.1)") - .subject( - listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") - ) - .subjectCode( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .subjectReference( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .sublocation("Sublocation (Core) (ref2019.1)") - .timeCreated("19:01:03+00:00") - .title("The Title (ref2019.1)") - .transmissionReference("Job Id (ref2019.1)") - .usageTerms("Rights Usage Terms (ref2019.1)") - .webStatement("http://www.WebStatementOfRights.org/2019.1") - .writer("Description Writer (ref2019.1)") - .writerEditor("Description Writer (ref2019.1)") - .xResolution(72.0) - .yResolution(72.0) - .build() - ) - .extensionStatus( - FileUploadV1Response.ExtensionStatus.builder() - .awsAutoTagging(FileUploadV1Response.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - FileUploadV1Response.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(FileUploadV1Response.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - .fileId("fileId") - .filePath("filePath") - .fileType("fileType") - .height(0.0) - .isPrivateFile(true) - .isPublished(true) - .metadata( - FileUploadV1Response.Metadata.builder() - .audioCodec("audioCodec") - .bitRate(0L) - .density(0L) - .duration(0L) - .exif( - FileUploadV1Response.Metadata.Exif.builder() - .exif( - ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) - .image( - ExifImage.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( - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - FileUploadV1Response.Metadata.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - 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( - FileUploadV1Response.VersionInfo.builder().id("id").name("name").build() - ) - .videoCodec("videoCodec") - .width(0.0) - .build() - - val roundtrippedFileUploadV1Response = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fileUploadV1Response), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFileUploadV1Response).isEqualTo(fileUploadV1Response) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ParamsTest.kt deleted file mode 100644 index 9489ce69..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ParamsTest.kt +++ /dev/null @@ -1,152 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files - -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 FileUploadV2ParamsTest { - - @Test - fun create() { - FileUploadV2Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata("\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" - ) - .folder("folder") - .isPrivateFile(FileUploadV2Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV2Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV2Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV2Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV2Params.OverwriteTags.TRUE) - .responseFields("responseFields") - .tags("t-shirt,round-neck,men") - .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" - ) - .useUniqueFileName(FileUploadV2Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") - .build() - } - - @Test - fun body() { - val params = - FileUploadV2Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" - ) - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" - ) - .folder("folder") - .isPrivateFile(FileUploadV2Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV2Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV2Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV2Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV2Params.OverwriteTags.TRUE) - .responseFields("responseFields") - .tags("t-shirt,round-neck,men") - .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" - ) - .useUniqueFileName(FileUploadV2Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") - .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("https://www.example.com/rest-of-the-image-path.jpg"), - "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( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" - ), - "extensions" to - MultipartField.of( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" - ), - "folder" to MultipartField.of("folder"), - "isPrivateFile" to MultipartField.of(FileUploadV2Params.IsPrivateFile.TRUE), - "isPublished" to MultipartField.of(FileUploadV2Params.IsPublished.TRUE), - "overwriteAITags" to - MultipartField.of(FileUploadV2Params.OverwriteAiTags.TRUE), - "overwriteCustomMetadata" to - MultipartField.of(FileUploadV2Params.OverwriteCustomMetadata.TRUE), - "overwriteFile" to MultipartField.of("overwriteFile"), - "overwriteTags" to MultipartField.of(FileUploadV2Params.OverwriteTags.TRUE), - "responseFields" to MultipartField.of("responseFields"), - "tags" to MultipartField.of("t-shirt,round-neck,men"), - "transformation" to - MultipartField.of( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" - ), - "useUniqueFileName" to - MultipartField.of(FileUploadV2Params.UseUniqueFileName.TRUE), - "webhookUrl" to MultipartField.of("webhookUrl"), - ) - .mapValues { (_, field) -> - field.map { (it as? ByteArray)?.inputStream() ?: it } - } - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - FileUploadV2Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") - .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("https://www.example.com/rest-of-the-image-path.jpg"), - "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/FileUploadV2ResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ResponseTest.kt deleted file mode 100644 index acb48c21..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadV2ResponseTest.kt +++ /dev/null @@ -1,1335 +0,0 @@ -// 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 FileUploadV2ResponseTest { - - @Test - fun create() { - val fileUploadV2Response = - FileUploadV2Response.builder() - .addAiTag( - FileUploadV2Response.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .audioCodec("audioCodec") - .bitRate(0L) - .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) - .duration(0L) - .embeddedMetadata( - FileUploadV2Response.EmbeddedMetadata.builder() - .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") - .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") - .aboutCvTermName("CV-Term Name 1 (ref2019.1)") - .aboutCvTermRefinedAbout( - "http://example.com/cv/refinements2/ref2019.1/codeX145" - ) - .additionalModelInformation("Additional Model Info (ref2019.1)") - .applicationRecordVersion(4L) - .artist("Creator1 (ref2019.1)") - .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") - .artworkContentDescription("AO Content Description 1 (ref2019.1)") - .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") - .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") - .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") - .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") - .addArtworkCreator("AO Creator Name 1a (ref2019.1)") - .addArtworkCreator("AO Creator Name 1b (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") - .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) - .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") - .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") - .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") - .artworkSource("AO Source 1 (ref2019.1)") - .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") - .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") - .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") - .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") - .artworkTitle("AO Title 1 (ref2019.1)") - .authorsPosition("Creator's Job Title (ref2019.1)") - .byline("Creator1 (ref2019.1)") - .bylineTitle("Creator's Job Title (ref2019.1)") - .caption("The description aka caption (ref2019.1)") - .captionAbstract("The description aka caption (ref2019.1)") - .captionWriter("Description Writer (ref2019.1)") - .city("City (Core) (ref2019.1)") - .colorSpace("Uncalibrated") - .componentsConfiguration("Y,Cb,Cr,-") - .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .copyrightNotice( - "Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)" - ) - .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") - .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") - .country("Country (Core) (ref2019.1)") - .countryCode("R19") - .countryPrimaryLocationCode("R19") - .countryPrimaryLocationName("Country (Core) (ref2019.1)") - .creator("Creator1 (ref2019.1)") - .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") - .creatorCity("Creator's CI: City (ref2019.1)") - .creatorCountry("Creator's CI: Country (ref2019.1)") - .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") - .creatorRegion("Creator's CI: State/Province (ref2019.1)") - .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") - .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") - .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") - .credit("Credit Line (ref2019.1)") - .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) - .description("The description aka caption (ref2019.1)") - .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") - .digitalSourceType( - "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" - ) - .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") - .embeddedEncodedRightsExprLangId( - "http://example.org/RELids/id4711/ref2019.1" - ) - .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .event("An Event (ref2019.1)") - .exifVersion("0232") - .flashpixVersion("0100") - .genreCvId("http://example.com/cv/genre/ref2019.1") - .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") - .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") - .genreCvTermRefinedAbout( - "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" - ) - .headline("The Headline (ref2019.1)") - .imageCreatorId("Image Creator Id 1 (ref2019.1)") - .imageCreatorImageId("Image Creator Image ID (ref2019.1)") - .imageCreatorName("Image Creator Name 1 (ref2019.1)") - .imageDescription("The description aka caption (ref2019.1)") - .addImageRegionBoundaryH(0.385) - .addImageRegionBoundaryRx(0.068) - .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) - .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) - .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) - .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) - .addImageRegionBoundaryW(0.127) - .addImageRegionBoundaryX(0.31) - .addImageRegionBoundaryX(0.59) - .addImageRegionBoundaryY(0.18) - .addImageRegionBoundaryY(0.426) - .imageRegionCtypeIdentifier( - listOf( - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - ) - ) - .imageRegionCtypeName( - listOf( - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - ) - ) - .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) - .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) - .imageRegionOrganisationInImageName( - listOf( - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr3 (ref2019.1)", - ) - ) - .imageRegionPersonInImage( - listOf( - "Person name no 1 in region persltr2 (ref2019.1)", - "Person name no 1 in region persltr3 (ref2019.1)", - "Person name no 1 in region persltr1 (ref2019.1)", - ) - ) - .imageRegionRoleIdentifier( - listOf( - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - ) - ) - .imageRegionRoleName( - listOf( - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - ) - ) - .imageSupplierId("Image Supplier Id (ref2019.1)") - .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") - .imageSupplierName("Image Supplier Name (ref2019.1)") - .instructions("An Instruction (ref2019.1)") - .intellectualGenre("A Genre (ref2019.1)") - .keywords( - listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") - ) - .addLicensorCity("Licensor City 1 (ref2019.1)") - .addLicensorCity("Licensor City 2 (ref2019.1)") - .addLicensorCountry("Licensor Country 1 (ref2019.1)") - .addLicensorCountry("Licensor Country 2 (ref2019.1)") - .addLicensorEmail("Licensor Email 1 (ref2019.1)") - .addLicensorEmail("Licensor Email 2 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") - .addLicensorId("Licensor ID 1 (ref2019.1)") - .addLicensorId("Licensor ID 2 (ref2019.1)") - .addLicensorName("Licensor Name 1 (ref2019.1)") - .addLicensorName("Licensor Name 2 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") - .addLicensorRegion("Licensor Region 1 (ref2019.1)") - .addLicensorRegion("Licensor Region 2 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") - .addLicensorUrl("Licensor URL 1 (ref2019.1)") - .addLicensorUrl("Licensor URL 2 (ref2019.1)") - .linkedEncodedRightsExpr( - "http://example.org/linkedrightsexpression/id986/ref2019.1" - ) - .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") - .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .location("Sublocation (Core) (ref2019.1)") - .locationCreatedCity("City (Location created1) (ref2019.1)") - .locationCreatedCountryCode("R17") - .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") - .locationCreatedGpsAltitude("480 m") - .locationCreatedGpsLatitude("48,16.5N") - .locationCreatedGpsLongitude("16,20.28E") - .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") - .locationCreatedLocationName( - "Location Name (Location created1) (ref2019.1)" - ) - .locationCreatedProvinceState( - "Province/State (Location created1) (ref2019.1)" - ) - .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") - .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") - .addLocationShownCity("City (Location shown1) (ref2019.1)") - .addLocationShownCity("City (Location shown2) (ref2019.1)") - .addLocationShownCountryCode("R17") - .addLocationShownCountryCode("R17") - .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") - .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") - .addLocationShownGpsAltitude("140 m") - .addLocationShownGpsAltitude("120 m") - .addLocationShownGpsLatitude("48,8.82N") - .addLocationShownGpsLatitude("47,57.12N") - .addLocationShownGpsLongitude("17,5.88E") - .addLocationShownGpsLongitude("16,49.8E") - .locationShownLocationId( - listOf( - "Location Id 1a(Location shown1) (ref2019.1)", - "Location Id 1b(Location shown1) (ref2019.1)", - "Location Id 2a(Location shown2) (ref2019.1)", - "Location Id 2b(Location shown2) (ref2019.1)", - ) - ) - .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") - .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") - .addLocationShownProvinceState( - "Province/State (Location shown1) (ref2019.1)" - ) - .addLocationShownProvinceState( - "Province/State (Location shown2) (ref2019.1)" - ) - .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") - .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") - .maxAvailHeight(20.0) - .maxAvailWidth(19.0) - .modelAge(listOf(25.0, 27.0, 30.0)) - .addModelReleaseId("Model Release ID 1 (ref2019.1)") - .addModelReleaseId("Model Release ID 2 (ref2019.1)") - .objectAttributeReference("A Genre (ref2019.1)") - .objectName("The Title (ref2019.1)") - .offsetTimeOriginal("+00:00") - .organisationInImageCode( - listOf( - "Organisation Code 1 (ref2019.1)", - "Organisation Code 2 (ref2019.1)", - "Organisation Code 3 (ref2019.1)", - ) - ) - .organisationInImageName( - listOf( - "Organisation Name 1 (ref2019.1)", - "Organisation Name 2 (ref2019.1)", - "Organisation Name 3 (ref2019.1)", - ) - ) - .orientation("Horizontal (normal)") - .originalTransmissionReference("Job Id (ref2019.1)") - .addPersonInImage("Person Shown 1 (ref2019.1)") - .addPersonInImage("Person Shown 2 (ref2019.1)") - .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") - .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") - .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") - .addPersonInImageCvTermRefinedAbout( - "http://example.com/cv/refinements987/codeY765/ref2019.1" - ) - .addPersonInImageDescription("Person Description 1 (ref2019.1)") - .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") - .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") - .addPersonInImageName("Person Name 1 (ref2019.1)") - .addProductInImageDescription("Product Description 1 (ref2019.1)") - .addProductInImageGtin(123456782019.1) - .addProductInImageName("Product Name 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") - .provinceState("Province/State(Core)(ref2019.1)") - .rating(1L) - .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") - .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") - .addRegistryItemId("Registry Image ID 1 (ref2019.1)") - .addRegistryItemId("Registry Image ID 2 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") - .resolutionUnit("inches") - .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .addScene("IPTC-Scene-Code1 (ref2019.1)") - .addScene("IPTC-Scene-Code2 (ref2019.1)") - .source("Source (ref2019.1)") - .specialInstructions("An Instruction (ref2019.1)") - .state("Province/State(Core)(ref2019.1)") - .subject( - listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") - ) - .subjectCode( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .subjectReference( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .sublocation("Sublocation (Core) (ref2019.1)") - .timeCreated("19:01:03+00:00") - .title("The Title (ref2019.1)") - .transmissionReference("Job Id (ref2019.1)") - .usageTerms("Rights Usage Terms (ref2019.1)") - .webStatement("http://www.WebStatementOfRights.org/2019.1") - .writer("Description Writer (ref2019.1)") - .writerEditor("Description Writer (ref2019.1)") - .xResolution(72.0) - .yResolution(72.0) - .build() - ) - .extensionStatus( - FileUploadV2Response.ExtensionStatus.builder() - .awsAutoTagging(FileUploadV2Response.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - FileUploadV2Response.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(FileUploadV2Response.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - .fileId("fileId") - .filePath("filePath") - .fileType("fileType") - .height(0.0) - .isPrivateFile(true) - .isPublished(true) - .metadata( - FileUploadV2Response.Metadata.builder() - .audioCodec("audioCodec") - .bitRate(0L) - .density(0L) - .duration(0L) - .exif( - FileUploadV2Response.Metadata.Exif.builder() - .exif( - ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) - .image( - ExifImage.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( - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - FileUploadV2Response.Metadata.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - 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( - FileUploadV2Response.VersionInfo.builder().id("id").name("name").build() - ) - .videoCodec("videoCodec") - .width(0.0) - .build() - - assertThat(fileUploadV2Response.aiTags().getOrNull()) - .containsExactly( - FileUploadV2Response.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - assertThat(fileUploadV2Response.audioCodec()).contains("audioCodec") - assertThat(fileUploadV2Response.bitRate()).contains(0L) - assertThat(fileUploadV2Response.customCoordinates()).contains("customCoordinates") - assertThat(fileUploadV2Response._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(fileUploadV2Response.duration()).contains(0L) - assertThat(fileUploadV2Response.embeddedMetadata()) - .contains( - FileUploadV2Response.EmbeddedMetadata.builder() - .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") - .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") - .aboutCvTermName("CV-Term Name 1 (ref2019.1)") - .aboutCvTermRefinedAbout( - "http://example.com/cv/refinements2/ref2019.1/codeX145" - ) - .additionalModelInformation("Additional Model Info (ref2019.1)") - .applicationRecordVersion(4L) - .artist("Creator1 (ref2019.1)") - .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") - .artworkContentDescription("AO Content Description 1 (ref2019.1)") - .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") - .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") - .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") - .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") - .addArtworkCreator("AO Creator Name 1a (ref2019.1)") - .addArtworkCreator("AO Creator Name 1b (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") - .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) - .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") - .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") - .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") - .artworkSource("AO Source 1 (ref2019.1)") - .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") - .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") - .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") - .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") - .artworkTitle("AO Title 1 (ref2019.1)") - .authorsPosition("Creator's Job Title (ref2019.1)") - .byline("Creator1 (ref2019.1)") - .bylineTitle("Creator's Job Title (ref2019.1)") - .caption("The description aka caption (ref2019.1)") - .captionAbstract("The description aka caption (ref2019.1)") - .captionWriter("Description Writer (ref2019.1)") - .city("City (Core) (ref2019.1)") - .colorSpace("Uncalibrated") - .componentsConfiguration("Y,Cb,Cr,-") - .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .copyrightNotice("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") - .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") - .country("Country (Core) (ref2019.1)") - .countryCode("R19") - .countryPrimaryLocationCode("R19") - .countryPrimaryLocationName("Country (Core) (ref2019.1)") - .creator("Creator1 (ref2019.1)") - .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") - .creatorCity("Creator's CI: City (ref2019.1)") - .creatorCountry("Creator's CI: Country (ref2019.1)") - .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") - .creatorRegion("Creator's CI: State/Province (ref2019.1)") - .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") - .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") - .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") - .credit("Credit Line (ref2019.1)") - .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) - .description("The description aka caption (ref2019.1)") - .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") - .digitalSourceType( - "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" - ) - .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") - .embeddedEncodedRightsExprLangId("http://example.org/RELids/id4711/ref2019.1") - .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .event("An Event (ref2019.1)") - .exifVersion("0232") - .flashpixVersion("0100") - .genreCvId("http://example.com/cv/genre/ref2019.1") - .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") - .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") - .genreCvTermRefinedAbout( - "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" - ) - .headline("The Headline (ref2019.1)") - .imageCreatorId("Image Creator Id 1 (ref2019.1)") - .imageCreatorImageId("Image Creator Image ID (ref2019.1)") - .imageCreatorName("Image Creator Name 1 (ref2019.1)") - .imageDescription("The description aka caption (ref2019.1)") - .addImageRegionBoundaryH(0.385) - .addImageRegionBoundaryRx(0.068) - .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) - .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) - .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) - .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) - .addImageRegionBoundaryW(0.127) - .addImageRegionBoundaryX(0.31) - .addImageRegionBoundaryX(0.59) - .addImageRegionBoundaryY(0.18) - .addImageRegionBoundaryY(0.426) - .imageRegionCtypeIdentifier( - listOf( - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - ) - ) - .imageRegionCtypeName( - listOf( - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - ) - ) - .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) - .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) - .imageRegionOrganisationInImageName( - listOf( - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr3 (ref2019.1)", - ) - ) - .imageRegionPersonInImage( - listOf( - "Person name no 1 in region persltr2 (ref2019.1)", - "Person name no 1 in region persltr3 (ref2019.1)", - "Person name no 1 in region persltr1 (ref2019.1)", - ) - ) - .imageRegionRoleIdentifier( - listOf( - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - ) - ) - .imageRegionRoleName( - listOf( - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - ) - ) - .imageSupplierId("Image Supplier Id (ref2019.1)") - .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") - .imageSupplierName("Image Supplier Name (ref2019.1)") - .instructions("An Instruction (ref2019.1)") - .intellectualGenre("A Genre (ref2019.1)") - .keywords(listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1")) - .addLicensorCity("Licensor City 1 (ref2019.1)") - .addLicensorCity("Licensor City 2 (ref2019.1)") - .addLicensorCountry("Licensor Country 1 (ref2019.1)") - .addLicensorCountry("Licensor Country 2 (ref2019.1)") - .addLicensorEmail("Licensor Email 1 (ref2019.1)") - .addLicensorEmail("Licensor Email 2 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") - .addLicensorId("Licensor ID 1 (ref2019.1)") - .addLicensorId("Licensor ID 2 (ref2019.1)") - .addLicensorName("Licensor Name 1 (ref2019.1)") - .addLicensorName("Licensor Name 2 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") - .addLicensorRegion("Licensor Region 1 (ref2019.1)") - .addLicensorRegion("Licensor Region 2 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") - .addLicensorUrl("Licensor URL 1 (ref2019.1)") - .addLicensorUrl("Licensor URL 2 (ref2019.1)") - .linkedEncodedRightsExpr( - "http://example.org/linkedrightsexpression/id986/ref2019.1" - ) - .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") - .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .location("Sublocation (Core) (ref2019.1)") - .locationCreatedCity("City (Location created1) (ref2019.1)") - .locationCreatedCountryCode("R17") - .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") - .locationCreatedGpsAltitude("480 m") - .locationCreatedGpsLatitude("48,16.5N") - .locationCreatedGpsLongitude("16,20.28E") - .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") - .locationCreatedLocationName("Location Name (Location created1) (ref2019.1)") - .locationCreatedProvinceState("Province/State (Location created1) (ref2019.1)") - .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") - .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") - .addLocationShownCity("City (Location shown1) (ref2019.1)") - .addLocationShownCity("City (Location shown2) (ref2019.1)") - .addLocationShownCountryCode("R17") - .addLocationShownCountryCode("R17") - .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") - .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") - .addLocationShownGpsAltitude("140 m") - .addLocationShownGpsAltitude("120 m") - .addLocationShownGpsLatitude("48,8.82N") - .addLocationShownGpsLatitude("47,57.12N") - .addLocationShownGpsLongitude("17,5.88E") - .addLocationShownGpsLongitude("16,49.8E") - .locationShownLocationId( - listOf( - "Location Id 1a(Location shown1) (ref2019.1)", - "Location Id 1b(Location shown1) (ref2019.1)", - "Location Id 2a(Location shown2) (ref2019.1)", - "Location Id 2b(Location shown2) (ref2019.1)", - ) - ) - .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") - .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") - .addLocationShownProvinceState("Province/State (Location shown1) (ref2019.1)") - .addLocationShownProvinceState("Province/State (Location shown2) (ref2019.1)") - .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") - .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") - .maxAvailHeight(20.0) - .maxAvailWidth(19.0) - .modelAge(listOf(25.0, 27.0, 30.0)) - .addModelReleaseId("Model Release ID 1 (ref2019.1)") - .addModelReleaseId("Model Release ID 2 (ref2019.1)") - .objectAttributeReference("A Genre (ref2019.1)") - .objectName("The Title (ref2019.1)") - .offsetTimeOriginal("+00:00") - .organisationInImageCode( - listOf( - "Organisation Code 1 (ref2019.1)", - "Organisation Code 2 (ref2019.1)", - "Organisation Code 3 (ref2019.1)", - ) - ) - .organisationInImageName( - listOf( - "Organisation Name 1 (ref2019.1)", - "Organisation Name 2 (ref2019.1)", - "Organisation Name 3 (ref2019.1)", - ) - ) - .orientation("Horizontal (normal)") - .originalTransmissionReference("Job Id (ref2019.1)") - .addPersonInImage("Person Shown 1 (ref2019.1)") - .addPersonInImage("Person Shown 2 (ref2019.1)") - .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") - .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") - .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") - .addPersonInImageCvTermRefinedAbout( - "http://example.com/cv/refinements987/codeY765/ref2019.1" - ) - .addPersonInImageDescription("Person Description 1 (ref2019.1)") - .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") - .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") - .addPersonInImageName("Person Name 1 (ref2019.1)") - .addProductInImageDescription("Product Description 1 (ref2019.1)") - .addProductInImageGtin(123456782019.1) - .addProductInImageName("Product Name 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") - .provinceState("Province/State(Core)(ref2019.1)") - .rating(1L) - .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") - .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") - .addRegistryItemId("Registry Image ID 1 (ref2019.1)") - .addRegistryItemId("Registry Image ID 2 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") - .resolutionUnit("inches") - .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .addScene("IPTC-Scene-Code1 (ref2019.1)") - .addScene("IPTC-Scene-Code2 (ref2019.1)") - .source("Source (ref2019.1)") - .specialInstructions("An Instruction (ref2019.1)") - .state("Province/State(Core)(ref2019.1)") - .subject(listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1")) - .subjectCode(listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1")) - .subjectReference( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .sublocation("Sublocation (Core) (ref2019.1)") - .timeCreated("19:01:03+00:00") - .title("The Title (ref2019.1)") - .transmissionReference("Job Id (ref2019.1)") - .usageTerms("Rights Usage Terms (ref2019.1)") - .webStatement("http://www.WebStatementOfRights.org/2019.1") - .writer("Description Writer (ref2019.1)") - .writerEditor("Description Writer (ref2019.1)") - .xResolution(72.0) - .yResolution(72.0) - .build() - ) - assertThat(fileUploadV2Response.extensionStatus()) - .contains( - FileUploadV2Response.ExtensionStatus.builder() - .awsAutoTagging(FileUploadV2Response.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - FileUploadV2Response.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(FileUploadV2Response.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - assertThat(fileUploadV2Response.fileId()).contains("fileId") - assertThat(fileUploadV2Response.filePath()).contains("filePath") - assertThat(fileUploadV2Response.fileType()).contains("fileType") - assertThat(fileUploadV2Response.height()).contains(0.0) - assertThat(fileUploadV2Response.isPrivateFile()).contains(true) - assertThat(fileUploadV2Response.isPublished()).contains(true) - assertThat(fileUploadV2Response.metadata()) - .contains( - FileUploadV2Response.Metadata.builder() - .audioCodec("audioCodec") - .bitRate(0L) - .density(0L) - .duration(0L) - .exif( - FileUploadV2Response.Metadata.Exif.builder() - .exif( - ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) - .image( - ExifImage.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( - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - FileUploadV2Response.Metadata.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - 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(fileUploadV2Response.name()).contains("name") - assertThat(fileUploadV2Response.size()).contains(0.0) - assertThat(fileUploadV2Response.tags().getOrNull()).containsExactly("string") - assertThat(fileUploadV2Response.thumbnailUrl()).contains("thumbnailUrl") - assertThat(fileUploadV2Response.url()).contains("url") - assertThat(fileUploadV2Response.versionInfo()) - .contains(FileUploadV2Response.VersionInfo.builder().id("id").name("name").build()) - assertThat(fileUploadV2Response.videoCodec()).contains("videoCodec") - assertThat(fileUploadV2Response.width()).contains(0.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val fileUploadV2Response = - FileUploadV2Response.builder() - .addAiTag( - FileUploadV2Response.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .audioCodec("audioCodec") - .bitRate(0L) - .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) - .duration(0L) - .embeddedMetadata( - FileUploadV2Response.EmbeddedMetadata.builder() - .aboutCvTermCvId("http://example.com/cv/about/ref2019.1") - .aboutCvTermId("http://example.com/cv/about/ref2019.1/code987") - .aboutCvTermName("CV-Term Name 1 (ref2019.1)") - .aboutCvTermRefinedAbout( - "http://example.com/cv/refinements2/ref2019.1/codeX145" - ) - .additionalModelInformation("Additional Model Info (ref2019.1)") - .applicationRecordVersion(4L) - .artist("Creator1 (ref2019.1)") - .artworkCircaDateCreated("AO Circa Date: between 1550 and 1600 (ref2019.1)") - .artworkContentDescription("AO Content Description 1 (ref2019.1)") - .artworkContributionDescription("AO Contribution Description 1 (ref2019.1)") - .artworkCopyrightNotice("AO Copyright Notice 1 (ref2019.1)") - .artworkCopyrightOwnerId("AO Current Copyright Owner ID 1 (ref2019.1)") - .artworkCopyrightOwnerName("AO Current Copyright Owner Name 1 (ref2019.1)") - .addArtworkCreator("AO Creator Name 1a (ref2019.1)") - .addArtworkCreator("AO Creator Name 1b (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1a (ref2019.1)") - .addArtworkCreatorId("AO Creator Id 1b (ref2019.1)") - .artworkDateCreated(OffsetDateTime.parse("1919-10-16T19:01:00.000Z")) - .artworkLicensorId("AO Current Licensor ID 1 (ref2019.1)") - .artworkLicensorName("AO Current Licensor Name 1 (ref2019.1)") - .artworkPhysicalDescription("AO Physical Description 1 (ref2019.1)") - .artworkSource("AO Source 1 (ref2019.1)") - .artworkSourceInventoryNo("AO Source Inventory No 1 (ref2019.1)") - .artworkSourceInvUrl("AO Source Inventory URL (ref2019.1)") - .addArtworkStylePeriod("AO Style Baroque (ref2019.1)") - .addArtworkStylePeriod("AO Style Italian Baroque (ref2019.1)") - .artworkTitle("AO Title 1 (ref2019.1)") - .authorsPosition("Creator's Job Title (ref2019.1)") - .byline("Creator1 (ref2019.1)") - .bylineTitle("Creator's Job Title (ref2019.1)") - .caption("The description aka caption (ref2019.1)") - .captionAbstract("The description aka caption (ref2019.1)") - .captionWriter("Description Writer (ref2019.1)") - .city("City (Core) (ref2019.1)") - .colorSpace("Uncalibrated") - .componentsConfiguration("Y,Cb,Cr,-") - .copyright("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .copyrightNotice( - "Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)" - ) - .addCopyrightOwnerId("Copyright Owner Id 1 (ref2019.1)") - .addCopyrightOwnerId("Copyright Owner Id 2 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 1 (ref2019.1)") - .addCopyrightOwnerName("Copyright Owner Name 2 (ref2019.1)") - .country("Country (Core) (ref2019.1)") - .countryCode("R19") - .countryPrimaryLocationCode("R19") - .countryPrimaryLocationName("Country (Core) (ref2019.1)") - .creator("Creator1 (ref2019.1)") - .creatorAddress("Creator's CI: Address, line 1 (ref2019.1)") - .creatorCity("Creator's CI: City (ref2019.1)") - .creatorCountry("Creator's CI: Country (ref2019.1)") - .creatorPostalCode("Creator's CI: Postcode (ref2019.1)") - .creatorRegion("Creator's CI: State/Province (ref2019.1)") - .creatorWorkEmail("Creator's CI: Email@1, Email@2 (ref2019.1)") - .creatorWorkTelephone("Creator's CI: Phone # 1, Phone # 2 (ref2019.1)") - .creatorWorkUrl("http://www.Creators.CI/WebAddress/ref2019.1") - .credit("Credit Line (ref2019.1)") - .dateCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeCreated(OffsetDateTime.parse("2019-10-16T00:00:00.000Z")) - .dateTimeOriginal(OffsetDateTime.parse("2019-10-16T19:01:03.000Z")) - .description("The description aka caption (ref2019.1)") - .digitalImageGuid("http://example.com/imageGUIDs/TestGUID12345/ref2019.1") - .digitalSourceType( - "http://cv.iptc.org/newscodes/digitalsourcetype/softwareImage" - ) - .embeddedEncodedRightsExpr("The Encoded Rights Expression (ref2019.1)") - .embeddedEncodedRightsExprLangId( - "http://example.org/RELids/id4711/ref2019.1" - ) - .embeddedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .event("An Event (ref2019.1)") - .exifVersion("0232") - .flashpixVersion("0100") - .genreCvId("http://example.com/cv/genre/ref2019.1") - .genreCvTermId("http://example.com/cv/genre/ref2019.1/code1369") - .genreCvTermName("Genre CV-Term Name 1 (ref2019.1)") - .genreCvTermRefinedAbout( - "http://example.com/cv/genrerefinements2/ref2019.1/codeY864" - ) - .headline("The Headline (ref2019.1)") - .imageCreatorId("Image Creator Id 1 (ref2019.1)") - .imageCreatorImageId("Image Creator Image ID (ref2019.1)") - .imageCreatorName("Image Creator Name 1 (ref2019.1)") - .imageDescription("The description aka caption (ref2019.1)") - .addImageRegionBoundaryH(0.385) - .addImageRegionBoundaryRx(0.068) - .imageRegionBoundaryShape(listOf("rectangle", "circle", "polygon")) - .imageRegionBoundaryUnit(listOf("relative", "relative", "relative")) - .imageRegionBoundaryVerticesX(listOf(0.05, 0.148, 0.375)) - .imageRegionBoundaryVerticesY(listOf(0.713, 0.041, 0.863)) - .addImageRegionBoundaryW(0.127) - .addImageRegionBoundaryX(0.31) - .addImageRegionBoundaryX(0.59) - .addImageRegionBoundaryY(0.18) - .addImageRegionBoundaryY(0.426) - .imageRegionCtypeIdentifier( - listOf( - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - "https://example.org/rctype/type2019.1a", - "https://example.org/rctype/type2019.1b", - ) - ) - .imageRegionCtypeName( - listOf( - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - "Region Boundary Content Type Name (ref2019.1)", - ) - ) - .imageRegionId(listOf("persltr2", "persltr3", "persltr1")) - .imageRegionName(listOf("Listener 1", "Listener 2", "Speaker 1")) - .imageRegionOrganisationInImageName( - listOf( - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr2 (ref2019.1)", - "Organisation name no 1 in region persltr3 (ref2019.1)", - ) - ) - .imageRegionPersonInImage( - listOf( - "Person name no 1 in region persltr2 (ref2019.1)", - "Person name no 1 in region persltr3 (ref2019.1)", - "Person name no 1 in region persltr1 (ref2019.1)", - ) - ) - .imageRegionRoleIdentifier( - listOf( - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - "https://example.org/rrole/role2019.1a", - "https://example.org/rrole/role2019.1b", - ) - ) - .imageRegionRoleName( - listOf( - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - "Region Boundary Content Role Name (ref2019.1)", - ) - ) - .imageSupplierId("Image Supplier Id (ref2019.1)") - .imageSupplierImageId("Image Supplier Image ID (ref2019.1)") - .imageSupplierName("Image Supplier Name (ref2019.1)") - .instructions("An Instruction (ref2019.1)") - .intellectualGenre("A Genre (ref2019.1)") - .keywords( - listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") - ) - .addLicensorCity("Licensor City 1 (ref2019.1)") - .addLicensorCity("Licensor City 2 (ref2019.1)") - .addLicensorCountry("Licensor Country 1 (ref2019.1)") - .addLicensorCountry("Licensor Country 2 (ref2019.1)") - .addLicensorEmail("Licensor Email 1 (ref2019.1)") - .addLicensorEmail("Licensor Email 2 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 1 (ref2019.1)") - .addLicensorExtendedAddress("Licensor Ext Addr 2 (ref2019.1)") - .addLicensorId("Licensor ID 1 (ref2019.1)") - .addLicensorId("Licensor ID 2 (ref2019.1)") - .addLicensorName("Licensor Name 1 (ref2019.1)") - .addLicensorName("Licensor Name 2 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 1 (ref2019.1)") - .addLicensorPostalCode("Licensor Postcode 2 (ref2019.1)") - .addLicensorRegion("Licensor Region 1 (ref2019.1)") - .addLicensorRegion("Licensor Region 2 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 1 (ref2019.1)") - .addLicensorStreetAddress("Licensor Street Addr 2 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 1 (ref2019.1)") - .addLicensorTelephone1("Licensor Phone1 2 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 1 (ref2019.1)") - .addLicensorTelephone2("Licensor Phone2 2 (ref2019.1)") - .addLicensorUrl("Licensor URL 1 (ref2019.1)") - .addLicensorUrl("Licensor URL 2 (ref2019.1)") - .linkedEncodedRightsExpr( - "http://example.org/linkedrightsexpression/id986/ref2019.1" - ) - .linkedEncodedRightsExprLangId("http://example.org/RELids/id4712/ref2019.1") - .linkedEncodedRightsExprType("IANA Media Type of ERE (ref2019.1)") - .location("Sublocation (Core) (ref2019.1)") - .locationCreatedCity("City (Location created1) (ref2019.1)") - .locationCreatedCountryCode("R17") - .locationCreatedCountryName("CountryName (Location created1) (ref2019.1)") - .locationCreatedGpsAltitude("480 m") - .locationCreatedGpsLatitude("48,16.5N") - .locationCreatedGpsLongitude("16,20.28E") - .locationCreatedLocationId("Location Id (Location created1) (ref2019.1)") - .locationCreatedLocationName( - "Location Name (Location created1) (ref2019.1)" - ) - .locationCreatedProvinceState( - "Province/State (Location created1) (ref2019.1)" - ) - .locationCreatedSublocation("Sublocation (Location created1) (ref2019.1)") - .locationCreatedWorldRegion("Worldregion (Location created1) (ref2019.1)") - .addLocationShownCity("City (Location shown1) (ref2019.1)") - .addLocationShownCity("City (Location shown2) (ref2019.1)") - .addLocationShownCountryCode("R17") - .addLocationShownCountryCode("R17") - .addLocationShownCountryName("CountryName (Location shown1) (ref2019.1)") - .addLocationShownCountryName("CountryName (Location shown2) (ref2019.1)") - .addLocationShownGpsAltitude("140 m") - .addLocationShownGpsAltitude("120 m") - .addLocationShownGpsLatitude("48,8.82N") - .addLocationShownGpsLatitude("47,57.12N") - .addLocationShownGpsLongitude("17,5.88E") - .addLocationShownGpsLongitude("16,49.8E") - .locationShownLocationId( - listOf( - "Location Id 1a(Location shown1) (ref2019.1)", - "Location Id 1b(Location shown1) (ref2019.1)", - "Location Id 2a(Location shown2) (ref2019.1)", - "Location Id 2b(Location shown2) (ref2019.1)", - ) - ) - .addLocationShownLocationName("Location Name (Location shown1) (ref2019.1)") - .addLocationShownLocationName("Location Name (Location shown2) (ref2019.1)") - .addLocationShownProvinceState( - "Province/State (Location shown1) (ref2019.1)" - ) - .addLocationShownProvinceState( - "Province/State (Location shown2) (ref2019.1)" - ) - .addLocationShownSublocation("Sublocation (Location shown1) (ref2019.1)") - .addLocationShownSublocation("Sublocation (Location shown2) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown1) (ref2019.1)") - .addLocationShownWorldRegion("Worldregion (Location shown2) (ref2019.1)") - .maxAvailHeight(20.0) - .maxAvailWidth(19.0) - .modelAge(listOf(25.0, 27.0, 30.0)) - .addModelReleaseId("Model Release ID 1 (ref2019.1)") - .addModelReleaseId("Model Release ID 2 (ref2019.1)") - .objectAttributeReference("A Genre (ref2019.1)") - .objectName("The Title (ref2019.1)") - .offsetTimeOriginal("+00:00") - .organisationInImageCode( - listOf( - "Organisation Code 1 (ref2019.1)", - "Organisation Code 2 (ref2019.1)", - "Organisation Code 3 (ref2019.1)", - ) - ) - .organisationInImageName( - listOf( - "Organisation Name 1 (ref2019.1)", - "Organisation Name 2 (ref2019.1)", - "Organisation Name 3 (ref2019.1)", - ) - ) - .orientation("Horizontal (normal)") - .originalTransmissionReference("Job Id (ref2019.1)") - .addPersonInImage("Person Shown 1 (ref2019.1)") - .addPersonInImage("Person Shown 2 (ref2019.1)") - .addPersonInImageCvTermCvId("http://example.com/cv/test99/ref2019.1") - .addPersonInImageCvTermId("http://example.com/cv/test99/code987/ref2019.1") - .addPersonInImageCvTermName("Person Characteristic Name 1 (ref2019.1)") - .addPersonInImageCvTermRefinedAbout( - "http://example.com/cv/refinements987/codeY765/ref2019.1" - ) - .addPersonInImageDescription("Person Description 1 (ref2019.1)") - .addPersonInImageId("http://wikidata.org/item/Q123456789/ref2019.1") - .addPersonInImageId("http://freebase.com/m/987654321/ref2019.1") - .addPersonInImageName("Person Name 1 (ref2019.1)") - .addProductInImageDescription("Product Description 1 (ref2019.1)") - .addProductInImageGtin(123456782019.1) - .addProductInImageName("Product Name 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 1 (ref2019.1)") - .addPropertyReleaseId("Property Release ID 2 (ref2019.1)") - .provinceState("Province/State(Core)(ref2019.1)") - .rating(1L) - .addRegistryEntryRole("Registry Entry Role ID 1 (ref2019.1)") - .addRegistryEntryRole("Registry Entry Role ID 2 (ref2019.1)") - .addRegistryItemId("Registry Image ID 1 (ref2019.1)") - .addRegistryItemId("Registry Image ID 2 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 1 (ref2019.1)") - .addRegistryOrganisationId("Registry Organisation ID 2 (ref2019.1)") - .resolutionUnit("inches") - .rights("Copyright (Notice) 2019.1 IPTC - www.iptc.org (ref2019.1)") - .addScene("IPTC-Scene-Code1 (ref2019.1)") - .addScene("IPTC-Scene-Code2 (ref2019.1)") - .source("Source (ref2019.1)") - .specialInstructions("An Instruction (ref2019.1)") - .state("Province/State(Core)(ref2019.1)") - .subject( - listOf("Keyword1ref2019.1", "Keyword2ref2019.1", "Keyword3ref2019.1") - ) - .subjectCode( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .subjectReference( - listOf("IPTC:1ref2019.1", "IPTC:2ref2019.1", "IPTC:3ref2019.1") - ) - .sublocation("Sublocation (Core) (ref2019.1)") - .timeCreated("19:01:03+00:00") - .title("The Title (ref2019.1)") - .transmissionReference("Job Id (ref2019.1)") - .usageTerms("Rights Usage Terms (ref2019.1)") - .webStatement("http://www.WebStatementOfRights.org/2019.1") - .writer("Description Writer (ref2019.1)") - .writerEditor("Description Writer (ref2019.1)") - .xResolution(72.0) - .yResolution(72.0) - .build() - ) - .extensionStatus( - FileUploadV2Response.ExtensionStatus.builder() - .awsAutoTagging(FileUploadV2Response.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - FileUploadV2Response.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(FileUploadV2Response.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - .fileId("fileId") - .filePath("filePath") - .fileType("fileType") - .height(0.0) - .isPrivateFile(true) - .isPublished(true) - .metadata( - FileUploadV2Response.Metadata.builder() - .audioCodec("audioCodec") - .bitRate(0L) - .density(0L) - .duration(0L) - .exif( - FileUploadV2Response.Metadata.Exif.builder() - .exif( - ExifDetails.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(Gps.builder().addGpsVersionId(0L).build()) - .image( - ExifImage.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( - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - FileUploadV2Response.Metadata.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - 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( - FileUploadV2Response.VersionInfo.builder().id("id").name("name").build() - ) - .videoCodec("videoCodec") - .width(0.0) - .build() - - val roundtrippedFileUploadV2Response = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fileUploadV2Response), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFileUploadV2Response).isEqualTo(fileUploadV2Response) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/GpsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/GpsTest.kt deleted file mode 100644 index f7e622aa..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/GpsTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class GpsTest { - - @Test - fun create() { - val gps = Gps.builder().addGpsVersionId(0L).build() - - assertThat(gps.gpsVersionId().getOrNull()).containsExactly(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val gps = Gps.builder().addGpsVersionId(0L).build() - - val roundtrippedGps = - jsonMapper.readValue(jsonMapper.writeValueAsString(gps), jacksonTypeRef()) - - assertThat(roundtrippedGps).isEqualTo(gps) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/InteroperabilityTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/InteroperabilityTest.kt deleted file mode 100644 index d0d26859..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/InteroperabilityTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -// 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 InteroperabilityTest { - - @Test - fun create() { - val interoperability = - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - - assertThat(interoperability.interopIndex()).contains("InteropIndex") - assertThat(interoperability.interopVersion()).contains("InteropVersion") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val interoperability = - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - - val roundtrippedInteroperability = - jsonMapper.readValue( - jsonMapper.writeValueAsString(interoperability), - jacksonTypeRef(), - ) - - assertThat(roundtrippedInteroperability).isEqualTo(interoperability) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ThumbnailTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ThumbnailTest.kt deleted file mode 100644 index 9fa4db51..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/ThumbnailTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -// 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 ThumbnailTest { - - @Test - fun create() { - val thumbnail = - Thumbnail.builder() - .compression(0L) - .resolutionUnit(0L) - .thumbnailLength(0L) - .thumbnailOffset(0L) - .xResolution(0L) - .yResolution(0L) - .build() - - assertThat(thumbnail.compression()).contains(0L) - assertThat(thumbnail.resolutionUnit()).contains(0L) - assertThat(thumbnail.thumbnailLength()).contains(0L) - assertThat(thumbnail.thumbnailOffset()).contains(0L) - assertThat(thumbnail.xResolution()).contains(0L) - assertThat(thumbnail.yResolution()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val thumbnail = - Thumbnail.builder() - .compression(0L) - .resolutionUnit(0L) - .thumbnailLength(0L) - .thumbnailOffset(0L) - .xResolution(0L) - .yResolution(0L) - .build() - - val roundtrippedThumbnail = - jsonMapper.readValue( - jsonMapper.writeValueAsString(thumbnail), - jacksonTypeRef(), - ) - - assertThat(roundtrippedThumbnail).isEqualTo(thumbnail) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponseTest.kt deleted file mode 100644 index 0fd76815..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteResponseTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.batch - -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 BatchDeleteResponseTest { - - @Test - fun create() { - val batchDeleteResponse = - BatchDeleteResponse.builder().addSuccessfullyDeletedFileId("string").build() - - assertThat(batchDeleteResponse.successfullyDeletedFileIds().getOrNull()) - .containsExactly("string") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchDeleteResponse = - BatchDeleteResponse.builder().addSuccessfullyDeletedFileId("string").build() - - val roundtrippedBatchDeleteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchDeleteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchDeleteResponse).isEqualTo(batchDeleteResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt similarity index 84% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt index 9d69b7e3..e4f87508 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileAddTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileAddTagsParamsTest { +internal class BulkAddTagsParamsTest { @Test fun create() { - FileAddTagsParams.builder() + BulkAddTagsParams.builder() .addFileId("598821f949c0a938d57563bd") .addFileId("598821f949c0a938d57563be") .tags(listOf("t-shirt", "round-neck", "sale2019")) @@ -19,7 +19,7 @@ internal class FileAddTagsParamsTest { @Test fun body() { val params = - FileAddTagsParams.builder() + BulkAddTagsParams.builder() .addFileId("598821f949c0a938d57563bd") .addFileId("598821f949c0a938d57563be") .tags(listOf("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/batch/BatchDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt similarity index 80% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt index 4734ceb4..c7ff4764 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/batch/BatchDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.batch +package com.imagekit.api.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class BatchDeleteParamsTest { +internal class BulkDeleteParamsTest { @Test fun create() { - BatchDeleteParams.builder() + BulkDeleteParams.builder() .addFileId("598821f949c0a938d57563bd") .addFileId("598821f949c0a938d57563be") .build() @@ -18,7 +18,7 @@ internal class BatchDeleteParamsTest { @Test fun body() { val params = - BatchDeleteParams.builder() + BulkDeleteParams.builder() .addFileId("598821f949c0a938d57563bd") .addFileId("598821f949c0a938d57563be") .build() 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/FileRemoveAiTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt similarity index 83% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt index a516a53d..21a08ec7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveAiTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileRemoveAiTagsParamsTest { +internal class BulkRemoveAiTagsParamsTest { @Test fun create() { - FileRemoveAiTagsParams.builder() + BulkRemoveAiTagsParams.builder() .aiTags(listOf("t-shirt", "round-neck", "sale2019")) .addFileId("598821f949c0a938d57563bd") .addFileId("598821f949c0a938d57563be") @@ -19,7 +19,7 @@ internal class FileRemoveAiTagsParamsTest { @Test fun body() { val params = - FileRemoveAiTagsParams.builder() + BulkRemoveAiTagsParams.builder() .aiTags(listOf("t-shirt", "round-neck", "sale2019")) .addFileId("598821f949c0a938d57563bd") .addFileId("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/FileRemoveTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt similarity index 83% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt index a3293050..0f1de44e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRemoveTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileRemoveTagsParamsTest { +internal class BulkRemoveTagsParamsTest { @Test fun create() { - FileRemoveTagsParams.builder() + BulkRemoveTagsParams.builder() .addFileId("598821f949c0a938d57563bd") .addFileId("598821f949c0a938d57563be") .tags(listOf("t-shirt", "round-neck", "sale2019")) @@ -19,7 +19,7 @@ internal class FileRemoveTagsParamsTest { @Test fun body() { val params = - FileRemoveTagsParams.builder() + BulkRemoveTagsParams.builder() .addFileId("598821f949c0a938d57563bd") .addFileId("598821f949c0a938d57563be") .tags(listOf("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/details/DetailRetrieveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponseTest.kt deleted file mode 100644 index 70671f73..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailRetrieveResponseTest.kt +++ /dev/null @@ -1,125 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.details - -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 DetailRetrieveResponseTest { - - @Test - fun create() { - val detailRetrieveResponse = - DetailRetrieveResponse.builder() - .addAiTag( - DetailRetrieveResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt("createdAt") - .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) - .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("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") - .versionInfo( - DetailRetrieveResponse.VersionInfo.builder().id("id").name("name").build() - ) - .width(0.0) - .build() - - assertThat(detailRetrieveResponse.aiTags().getOrNull()) - .containsExactly( - DetailRetrieveResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - assertThat(detailRetrieveResponse.createdAt()).contains("createdAt") - assertThat(detailRetrieveResponse.customCoordinates()).contains("customCoordinates") - assertThat(detailRetrieveResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(detailRetrieveResponse.fileId()).contains("fileId") - assertThat(detailRetrieveResponse.filePath()).contains("filePath") - assertThat(detailRetrieveResponse.fileType()).contains("fileType") - assertThat(detailRetrieveResponse.hasAlpha()).contains(true) - assertThat(detailRetrieveResponse.height()).contains(0.0) - assertThat(detailRetrieveResponse.isPrivateFile()).contains(true) - assertThat(detailRetrieveResponse.isPublished()).contains(true) - assertThat(detailRetrieveResponse.mime()).contains("mime") - assertThat(detailRetrieveResponse.name()).contains("name") - assertThat(detailRetrieveResponse.size()).contains(0.0) - assertThat(detailRetrieveResponse.tags().getOrNull()).containsExactly("string") - assertThat(detailRetrieveResponse.thumbnail()).contains("thumbnail") - assertThat(detailRetrieveResponse.type()).contains("type") - assertThat(detailRetrieveResponse.updatedAt()).contains("updatedAt") - assertThat(detailRetrieveResponse.url()).contains("url") - assertThat(detailRetrieveResponse.versionInfo()) - .contains(DetailRetrieveResponse.VersionInfo.builder().id("id").name("name").build()) - assertThat(detailRetrieveResponse.width()).contains(0.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val detailRetrieveResponse = - DetailRetrieveResponse.builder() - .addAiTag( - DetailRetrieveResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt("createdAt") - .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) - .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("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") - .versionInfo( - DetailRetrieveResponse.VersionInfo.builder().id("id").name("name").build() - ) - .width(0.0) - .build() - - val roundtrippedDetailRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(detailRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedDetailRetrieveResponse).isEqualTo(detailRetrieveResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponseTest.kt deleted file mode 100644 index c590f5c8..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/details/DetailUpdateResponseTest.kt +++ /dev/null @@ -1,153 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.details - -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 DetailUpdateResponseTest { - - @Test - fun create() { - val detailUpdateResponse = - DetailUpdateResponse.builder() - .addAiTag( - DetailUpdateResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt("createdAt") - .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) - .extensionStatus( - DetailUpdateResponse.ExtensionStatus.builder() - .awsAutoTagging(DetailUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - DetailUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(DetailUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - .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("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") - .versionInfo( - DetailUpdateResponse.VersionInfo.builder().id("id").name("name").build() - ) - .width(0.0) - .build() - - assertThat(detailUpdateResponse.aiTags().getOrNull()) - .containsExactly( - DetailUpdateResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - assertThat(detailUpdateResponse.createdAt()).contains("createdAt") - assertThat(detailUpdateResponse.customCoordinates()).contains("customCoordinates") - assertThat(detailUpdateResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(detailUpdateResponse.extensionStatus()) - .contains( - DetailUpdateResponse.ExtensionStatus.builder() - .awsAutoTagging(DetailUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - DetailUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(DetailUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - assertThat(detailUpdateResponse.fileId()).contains("fileId") - assertThat(detailUpdateResponse.filePath()).contains("filePath") - assertThat(detailUpdateResponse.fileType()).contains("fileType") - assertThat(detailUpdateResponse.hasAlpha()).contains(true) - assertThat(detailUpdateResponse.height()).contains(0.0) - assertThat(detailUpdateResponse.isPrivateFile()).contains(true) - assertThat(detailUpdateResponse.isPublished()).contains(true) - assertThat(detailUpdateResponse.mime()).contains("mime") - assertThat(detailUpdateResponse.name()).contains("name") - assertThat(detailUpdateResponse.size()).contains(0.0) - assertThat(detailUpdateResponse.tags().getOrNull()).containsExactly("string") - assertThat(detailUpdateResponse.thumbnail()).contains("thumbnail") - assertThat(detailUpdateResponse.type()).contains("type") - assertThat(detailUpdateResponse.updatedAt()).contains("updatedAt") - assertThat(detailUpdateResponse.url()).contains("url") - assertThat(detailUpdateResponse.versionInfo()) - .contains(DetailUpdateResponse.VersionInfo.builder().id("id").name("name").build()) - assertThat(detailUpdateResponse.width()).contains(0.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val detailUpdateResponse = - DetailUpdateResponse.builder() - .addAiTag( - DetailUpdateResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt("createdAt") - .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) - .extensionStatus( - DetailUpdateResponse.ExtensionStatus.builder() - .awsAutoTagging(DetailUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) - .googleAutoTagging( - DetailUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS - ) - .removeBg(DetailUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) - .build() - ) - .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("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") - .versionInfo( - DetailUpdateResponse.VersionInfo.builder().id("id").name("name").build() - ) - .width(0.0) - .build() - - val roundtrippedDetailUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(detailUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedDetailUpdateResponse).isEqualTo(detailUpdateResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt similarity index 52% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt index 19940214..2d4617b6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt @@ -6,19 +6,20 @@ import com.imagekit.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class MetadataFromUrlParamsTest { +internal class MetadataGetFromUrlParamsTest { @Test fun create() { - MetadataFromUrlParams.builder().url("url").build() + MetadataGetFromUrlParams.builder().url("https://example.com").build() } @Test fun queryParams() { - val params = MetadataFromUrlParams.builder().url("url").build() + val params = MetadataGetFromUrlParams.builder().url("https://example.com").build() val queryParams = params._queryParams() - assertThat(queryParams).isEqualTo(QueryParams.builder().put("url", "url").build()) + 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/MetadataRetrieveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt similarity index 75% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt index a9013499..f889b1e1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt @@ -5,28 +5,23 @@ package com.imagekit.api.models.files.metadata 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.ExifDetails -import com.imagekit.api.models.files.ExifImage -import com.imagekit.api.models.files.Gps -import com.imagekit.api.models.files.Interoperability -import com.imagekit.api.models.files.Thumbnail import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class MetadataRetrieveResponseTest { +internal class MetadataGetFromUrlResponseTest { @Test fun create() { - val metadataRetrieveResponse = - MetadataRetrieveResponse.builder() + val metadataGetFromUrlResponse = + MetadataGetFromUrlResponse.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - MetadataRetrieveResponse.Exif.builder() + MetadataGetFromUrlResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetFromUrlResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -55,9 +50,13 @@ internal class MetadataRetrieveResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + MetadataGetFromUrlResponse.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + MetadataGetFromUrlResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -72,18 +71,18 @@ internal class MetadataRetrieveResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetFromUrlResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataRetrieveResponse.Exif.Makernote.builder() + MetadataGetFromUrlResponse.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetFromUrlResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -105,15 +104,15 @@ internal class MetadataRetrieveResponseTest { .width(0L) .build() - assertThat(metadataRetrieveResponse.audioCodec()).contains("audioCodec") - assertThat(metadataRetrieveResponse.bitRate()).contains(0L) - assertThat(metadataRetrieveResponse.density()).contains(0L) - assertThat(metadataRetrieveResponse.duration()).contains(0L) - assertThat(metadataRetrieveResponse.exif()) + assertThat(metadataGetFromUrlResponse.audioCodec()).contains("audioCodec") + assertThat(metadataGetFromUrlResponse.bitRate()).contains(0L) + assertThat(metadataGetFromUrlResponse.density()).contains(0L) + assertThat(metadataGetFromUrlResponse.duration()).contains(0L) + assertThat(metadataGetFromUrlResponse.exif()) .contains( - MetadataRetrieveResponse.Exif.builder() + MetadataGetFromUrlResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetFromUrlResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -142,9 +141,9 @@ internal class MetadataRetrieveResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps(MetadataGetFromUrlResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - ExifImage.builder() + MetadataGetFromUrlResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -159,18 +158,18 @@ internal class MetadataRetrieveResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetFromUrlResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataRetrieveResponse.Exif.Makernote.builder() + MetadataGetFromUrlResponse.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetFromUrlResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -181,30 +180,30 @@ internal class MetadataRetrieveResponseTest { ) .build() ) - assertThat(metadataRetrieveResponse.format()).contains("format") - assertThat(metadataRetrieveResponse.hasColorProfile()).contains(true) - assertThat(metadataRetrieveResponse.hasTransparency()).contains(true) - assertThat(metadataRetrieveResponse.height()).contains(0L) - assertThat(metadataRetrieveResponse.pHash()).contains("pHash") - assertThat(metadataRetrieveResponse.quality()).contains(0L) - assertThat(metadataRetrieveResponse.size()).contains(0L) - assertThat(metadataRetrieveResponse.videoCodec()).contains("videoCodec") - assertThat(metadataRetrieveResponse.width()).contains(0L) + assertThat(metadataGetFromUrlResponse.format()).contains("format") + assertThat(metadataGetFromUrlResponse.hasColorProfile()).contains(true) + assertThat(metadataGetFromUrlResponse.hasTransparency()).contains(true) + assertThat(metadataGetFromUrlResponse.height()).contains(0L) + assertThat(metadataGetFromUrlResponse.pHash()).contains("pHash") + assertThat(metadataGetFromUrlResponse.quality()).contains(0L) + assertThat(metadataGetFromUrlResponse.size()).contains(0L) + assertThat(metadataGetFromUrlResponse.videoCodec()).contains("videoCodec") + assertThat(metadataGetFromUrlResponse.width()).contains(0L) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val metadataRetrieveResponse = - MetadataRetrieveResponse.builder() + val metadataGetFromUrlResponse = + MetadataGetFromUrlResponse.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - MetadataRetrieveResponse.Exif.builder() + MetadataGetFromUrlResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetFromUrlResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -233,9 +232,13 @@ internal class MetadataRetrieveResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + MetadataGetFromUrlResponse.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + MetadataGetFromUrlResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -250,18 +253,18 @@ internal class MetadataRetrieveResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetFromUrlResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataRetrieveResponse.Exif.Makernote.builder() + MetadataGetFromUrlResponse.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetFromUrlResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -283,12 +286,12 @@ internal class MetadataRetrieveResponseTest { .width(0L) .build() - val roundtrippedMetadataRetrieveResponse = + val roundtrippedMetadataGetFromUrlResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(metadataRetrieveResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(metadataGetFromUrlResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedMetadataRetrieveResponse).isEqualTo(metadataRetrieveResponse) + assertThat(roundtrippedMetadataGetFromUrlResponse).isEqualTo(metadataGetFromUrlResponse) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt similarity index 68% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt index 239baeab..566257d5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataRetrieveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt @@ -5,16 +5,16 @@ package com.imagekit.api.models.files.metadata import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class MetadataRetrieveParamsTest { +internal class MetadataGetParamsTest { @Test fun create() { - MetadataRetrieveParams.builder().fileId("fileId").build() + MetadataGetParams.builder().fileId("fileId").build() } @Test fun pathParams() { - val params = MetadataRetrieveParams.builder().fileId("fileId").build() + val params = MetadataGetParams.builder().fileId("fileId").build() assertThat(params._pathParam(0)).isEqualTo("fileId") // out-of-bound path param diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt similarity index 78% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt index e808d3fa..28ff25c9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataFromUrlResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt @@ -5,28 +5,23 @@ package com.imagekit.api.models.files.metadata 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.ExifDetails -import com.imagekit.api.models.files.ExifImage -import com.imagekit.api.models.files.Gps -import com.imagekit.api.models.files.Interoperability -import com.imagekit.api.models.files.Thumbnail import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class MetadataFromUrlResponseTest { +internal class MetadataGetResponseTest { @Test fun create() { - val metadataFromUrlResponse = - MetadataFromUrlResponse.builder() + val metadataGetResponse = + MetadataGetResponse.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - MetadataFromUrlResponse.Exif.builder() + MetadataGetResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -55,9 +50,9 @@ internal class MetadataFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - ExifImage.builder() + MetadataGetResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -72,18 +67,18 @@ internal class MetadataFromUrlResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataFromUrlResponse.Exif.Makernote.builder() + MetadataGetResponse.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -105,15 +100,15 @@ internal class MetadataFromUrlResponseTest { .width(0L) .build() - assertThat(metadataFromUrlResponse.audioCodec()).contains("audioCodec") - assertThat(metadataFromUrlResponse.bitRate()).contains(0L) - assertThat(metadataFromUrlResponse.density()).contains(0L) - assertThat(metadataFromUrlResponse.duration()).contains(0L) - assertThat(metadataFromUrlResponse.exif()) + assertThat(metadataGetResponse.audioCodec()).contains("audioCodec") + assertThat(metadataGetResponse.bitRate()).contains(0L) + assertThat(metadataGetResponse.density()).contains(0L) + assertThat(metadataGetResponse.duration()).contains(0L) + assertThat(metadataGetResponse.exif()) .contains( - MetadataFromUrlResponse.Exif.builder() + MetadataGetResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -142,9 +137,9 @@ internal class MetadataFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - ExifImage.builder() + MetadataGetResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -159,18 +154,18 @@ internal class MetadataFromUrlResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataFromUrlResponse.Exif.Makernote.builder() + MetadataGetResponse.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -181,30 +176,30 @@ internal class MetadataFromUrlResponseTest { ) .build() ) - assertThat(metadataFromUrlResponse.format()).contains("format") - assertThat(metadataFromUrlResponse.hasColorProfile()).contains(true) - assertThat(metadataFromUrlResponse.hasTransparency()).contains(true) - assertThat(metadataFromUrlResponse.height()).contains(0L) - assertThat(metadataFromUrlResponse.pHash()).contains("pHash") - assertThat(metadataFromUrlResponse.quality()).contains(0L) - assertThat(metadataFromUrlResponse.size()).contains(0L) - assertThat(metadataFromUrlResponse.videoCodec()).contains("videoCodec") - assertThat(metadataFromUrlResponse.width()).contains(0L) + assertThat(metadataGetResponse.format()).contains("format") + assertThat(metadataGetResponse.hasColorProfile()).contains(true) + assertThat(metadataGetResponse.hasTransparency()).contains(true) + assertThat(metadataGetResponse.height()).contains(0L) + assertThat(metadataGetResponse.pHash()).contains("pHash") + assertThat(metadataGetResponse.quality()).contains(0L) + assertThat(metadataGetResponse.size()).contains(0L) + assertThat(metadataGetResponse.videoCodec()).contains("videoCodec") + assertThat(metadataGetResponse.width()).contains(0L) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val metadataFromUrlResponse = - MetadataFromUrlResponse.builder() + val metadataGetResponse = + MetadataGetResponse.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - MetadataFromUrlResponse.Exif.builder() + MetadataGetResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -233,9 +228,9 @@ internal class MetadataFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - ExifImage.builder() + MetadataGetResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -250,18 +245,18 @@ internal class MetadataFromUrlResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataFromUrlResponse.Exif.Makernote.builder() + MetadataGetResponse.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -283,12 +278,12 @@ internal class MetadataFromUrlResponseTest { .width(0L) .build() - val roundtrippedMetadataFromUrlResponse = + val roundtrippedMetadataGetResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(metadataFromUrlResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(metadataGetResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedMetadataFromUrlResponse).isEqualTo(metadataFromUrlResponse) + assertThat(roundtrippedMetadataGetResponse).isEqualTo(metadataGetResponse) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponseTest.kt deleted file mode 100644 index 37cce050..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeExecuteResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.purge - -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 PurgeExecuteResponseTest { - - @Test - fun create() { - val purgeExecuteResponse = PurgeExecuteResponse.builder().requestId("requestId").build() - - assertThat(purgeExecuteResponse.requestId()).contains("requestId") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val purgeExecuteResponse = PurgeExecuteResponse.builder().requestId("requestId").build() - - val roundtrippedPurgeExecuteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(purgeExecuteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPurgeExecuteResponse).isEqualTo(purgeExecuteResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponseTest.kt deleted file mode 100644 index 6c9c7f80..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/purge/PurgeStatusResponseTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.purge - -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 PurgeStatusResponseTest { - - @Test - fun create() { - val purgeStatusResponse = - PurgeStatusResponse.builder().status(PurgeStatusResponse.Status.COMPLETED).build() - - assertThat(purgeStatusResponse.status()).contains(PurgeStatusResponse.Status.COMPLETED) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val purgeStatusResponse = - PurgeStatusResponse.builder().status(PurgeStatusResponse.Status.COMPLETED).build() - - val roundtrippedPurgeStatusResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(purgeStatusResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPurgeStatusResponse).isEqualTo(purgeStatusResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt similarity index 67% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt index 8d352a30..223c3985 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt @@ -5,16 +5,16 @@ package com.imagekit.api.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VersionRetrieveParamsTest { +internal class VersionGetParamsTest { @Test fun create() { - VersionRetrieveParams.builder().fileId("fileId").versionId("versionId").build() + VersionGetParams.builder().fileId("fileId").versionId("versionId").build() } @Test fun pathParams() { - val params = VersionRetrieveParams.builder().fileId("fileId").versionId("versionId").build() + val params = VersionGetParams.builder().fileId("fileId").versionId("versionId").build() assertThat(params._pathParam(0)).isEqualTo("fileId") assertThat(params._pathParam(1)).isEqualTo("versionId") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt similarity index 50% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt index 4933bb17..23b54495 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRetrieveResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt @@ -9,14 +9,14 @@ import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VersionRetrieveResponseTest { +internal class VersionGetResponseTest { @Test fun create() { - val versionRetrieveResponse = - VersionRetrieveResponse.builder() + val versionGetResponse = + VersionGetResponse.builder() .addAiTag( - VersionRetrieveResponse.AiTag.builder() + VersionGetResponse.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -40,51 +40,49 @@ internal class VersionRetrieveResponseTest { .type("type") .updatedAt("updatedAt") .url("url") - .versionInfo( - VersionRetrieveResponse.VersionInfo.builder().id("id").name("name").build() - ) + .versionInfo(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() - assertThat(versionRetrieveResponse.aiTags().getOrNull()) + assertThat(versionGetResponse.aiTags().getOrNull()) .containsExactly( - VersionRetrieveResponse.AiTag.builder() + VersionGetResponse.AiTag.builder() .confidence(0.0) .name("name") .source("source") .build() ) - assertThat(versionRetrieveResponse.createdAt()).contains("createdAt") - assertThat(versionRetrieveResponse.customCoordinates()).contains("customCoordinates") - assertThat(versionRetrieveResponse._customMetadata()) + assertThat(versionGetResponse.createdAt()).contains("createdAt") + assertThat(versionGetResponse.customCoordinates()).contains("customCoordinates") + assertThat(versionGetResponse._customMetadata()) .isEqualTo(JsonValue.from(mapOf())) - assertThat(versionRetrieveResponse.fileId()).contains("fileId") - assertThat(versionRetrieveResponse.filePath()).contains("filePath") - assertThat(versionRetrieveResponse.fileType()).contains("fileType") - assertThat(versionRetrieveResponse.hasAlpha()).contains(true) - assertThat(versionRetrieveResponse.height()).contains(0.0) - assertThat(versionRetrieveResponse.isPrivateFile()).contains(true) - assertThat(versionRetrieveResponse.isPublished()).contains(true) - assertThat(versionRetrieveResponse.mime()).contains("mime") - assertThat(versionRetrieveResponse.name()).contains("name") - assertThat(versionRetrieveResponse.size()).contains(0.0) - assertThat(versionRetrieveResponse.tags().getOrNull()).containsExactly("string") - assertThat(versionRetrieveResponse.thumbnail()).contains("thumbnail") - assertThat(versionRetrieveResponse.type()).contains("type") - assertThat(versionRetrieveResponse.updatedAt()).contains("updatedAt") - assertThat(versionRetrieveResponse.url()).contains("url") - assertThat(versionRetrieveResponse.versionInfo()) - .contains(VersionRetrieveResponse.VersionInfo.builder().id("id").name("name").build()) - assertThat(versionRetrieveResponse.width()).contains(0.0) + assertThat(versionGetResponse.fileId()).contains("fileId") + assertThat(versionGetResponse.filePath()).contains("filePath") + assertThat(versionGetResponse.fileType()).contains("fileType") + assertThat(versionGetResponse.hasAlpha()).contains(true) + assertThat(versionGetResponse.height()).contains(0.0) + assertThat(versionGetResponse.isPrivateFile()).contains(true) + assertThat(versionGetResponse.isPublished()).contains(true) + assertThat(versionGetResponse.mime()).contains("mime") + assertThat(versionGetResponse.name()).contains("name") + assertThat(versionGetResponse.size()).contains(0.0) + assertThat(versionGetResponse.tags().getOrNull()).containsExactly("string") + assertThat(versionGetResponse.thumbnail()).contains("thumbnail") + assertThat(versionGetResponse.type()).contains("type") + assertThat(versionGetResponse.updatedAt()).contains("updatedAt") + assertThat(versionGetResponse.url()).contains("url") + assertThat(versionGetResponse.versionInfo()) + .contains(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(versionGetResponse.width()).contains(0.0) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val versionRetrieveResponse = - VersionRetrieveResponse.builder() + val versionGetResponse = + VersionGetResponse.builder() .addAiTag( - VersionRetrieveResponse.AiTag.builder() + VersionGetResponse.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -108,18 +106,16 @@ internal class VersionRetrieveResponseTest { .type("type") .updatedAt("updatedAt") .url("url") - .versionInfo( - VersionRetrieveResponse.VersionInfo.builder().id("id").name("name").build() - ) + .versionInfo(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() - val roundtrippedVersionRetrieveResponse = + val roundtrippedVersionGetResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(versionRetrieveResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(versionGetResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedVersionRetrieveResponse).isEqualTo(versionRetrieveResponse) + assertThat(roundtrippedVersionGetResponse).isEqualTo(versionGetResponse) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt similarity index 85% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt index 125e0d4a..2592d7ab 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobCopyFolderParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class BulkJobCopyFolderParamsTest { +internal class FolderCopyParamsTest { @Test fun create() { - BulkJobCopyFolderParams.builder() + FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") .sourceFolderPath("/path/of/source/folder") .includeVersions(true) @@ -19,7 +19,7 @@ internal class BulkJobCopyFolderParamsTest { @Test fun body() { val params = - BulkJobCopyFolderParams.builder() + FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") .sourceFolderPath("/path/of/source/folder") .includeVersions(true) @@ -35,7 +35,7 @@ internal class BulkJobCopyFolderParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - BulkJobCopyFolderParams.builder() + FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") .sourceFolderPath("/path/of/source/folder") .build() 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..e6784761 --- /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()).contains("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/folder/FolderCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt similarity index 94% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt index 7d25e9a6..7f8ba557 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folder +package com.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/com/imagekit/api/models/folder/FolderCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt index 0bca32b6..de873d35 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folder +package com.imagekit.api.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.jsonMapper diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt index b4ec8b25..7a1a4fca 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folder +package com.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/com/imagekit/api/models/folder/FolderDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt index 478b1ca1..332055e2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folder/FolderDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folder +package com.imagekit.api.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.jsonMapper diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt similarity index 80% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt index abfc5e5b..7df75c01 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobMoveFolderParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class BulkJobMoveFolderParamsTest { +internal class FolderMoveParamsTest { @Test fun create() { - BulkJobMoveFolderParams.builder() + FolderMoveParams.builder() .destinationPath("/path/of/destination/folder") .sourceFolderPath("/path/of/source/folder") .build() @@ -18,7 +18,7 @@ internal class BulkJobMoveFolderParamsTest { @Test fun body() { val params = - BulkJobMoveFolderParams.builder() + FolderMoveParams.builder() .destinationPath("/path/of/destination/folder") .sourceFolderPath("/path/of/source/folder") .build() 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..0edbc945 --- /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()).contains("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..07fdc5f6 --- /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()).contains("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/bulkjobs/BulkJobRetrieveStatusParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt similarity index 60% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParamsTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt index 487b192e..0128480f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/bulkjobs/BulkJobRetrieveStatusParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.bulkjobs +package com.imagekit.api.models.folders.job import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class BulkJobRetrieveStatusParamsTest { +internal class JobGetParamsTest { @Test fun create() { - BulkJobRetrieveStatusParams.builder().jobId("jobId").build() + JobGetParams.builder().jobId("jobId").build() } @Test fun pathParams() { - val params = BulkJobRetrieveStatusParams.builder().jobId("jobId").build() + val params = JobGetParams.builder().jobId("jobId").build() assertThat(params._pathParam(0)).isEqualTo("jobId") // out-of-bound path param 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..2482872f --- /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("Completed") + .type("COPY_FOLDER") + .build() + + assertThat(jobGetResponse.jobId()).contains("5d5b1a9b4c8c4c0001f3e4a2") + assertThat(jobGetResponse.purgeRequestId()).contains("purgeRequestId") + assertThat(jobGetResponse.status()).contains("Completed") + assertThat(jobGetResponse.type()).contains("COPY_FOLDER") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val jobGetResponse = + JobGetResponse.builder() + .jobId("5d5b1a9b4c8c4c0001f3e4a2") + .purgeRequestId("purgeRequestId") + .status("Completed") + .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/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 96c27b41..638f2e35 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.files.FileUploadV1Params +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 @@ -60,7 +60,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_400() { + fun filesUpload400() { val fileService = client.files() stubFor( post(anyUrl()) @@ -71,36 +71,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -111,7 +175,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_400WithRawResponse() { + fun filesUpload400WithRawResponse() { val fileService = client.files().withRawResponse() stubFor( post(anyUrl()) @@ -122,36 +186,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -162,7 +290,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_401() { + fun filesUpload401() { val fileService = client.files() stubFor( post(anyUrl()) @@ -173,36 +301,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -213,7 +405,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_401WithRawResponse() { + fun filesUpload401WithRawResponse() { val fileService = client.files().withRawResponse() stubFor( post(anyUrl()) @@ -224,36 +416,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -264,7 +520,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_403() { + fun filesUpload403() { val fileService = client.files() stubFor( post(anyUrl()) @@ -275,36 +531,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -315,7 +635,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_403WithRawResponse() { + fun filesUpload403WithRawResponse() { val fileService = client.files().withRawResponse() stubFor( post(anyUrl()) @@ -326,36 +646,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -366,7 +750,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_404() { + fun filesUpload404() { val fileService = client.files() stubFor( post(anyUrl()) @@ -377,36 +761,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -417,7 +865,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_404WithRawResponse() { + fun filesUpload404WithRawResponse() { val fileService = client.files().withRawResponse() stubFor( post(anyUrl()) @@ -428,36 +876,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -468,7 +980,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_422() { + fun filesUpload422() { val fileService = client.files() stubFor( post(anyUrl()) @@ -479,36 +991,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -519,7 +1095,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_422WithRawResponse() { + fun filesUpload422WithRawResponse() { val fileService = client.files().withRawResponse() stubFor( post(anyUrl()) @@ -530,36 +1106,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -570,7 +1210,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_429() { + fun filesUpload429() { val fileService = client.files() stubFor( post(anyUrl()) @@ -581,36 +1221,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -621,7 +1325,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_429WithRawResponse() { + fun filesUpload429WithRawResponse() { val fileService = client.files().withRawResponse() stubFor( post(anyUrl()) @@ -632,36 +1336,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -672,7 +1440,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_500() { + fun filesUpload500() { val fileService = client.files() stubFor( post(anyUrl()) @@ -683,36 +1451,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -723,7 +1555,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_500WithRawResponse() { + fun filesUpload500WithRawResponse() { val fileService = client.files().withRawResponse() stubFor( post(anyUrl()) @@ -734,36 +1566,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -774,7 +1670,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_999() { + fun filesUpload999() { val fileService = client.files() stubFor( post(anyUrl()) @@ -785,36 +1681,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -825,7 +1785,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1_999WithRawResponse() { + fun filesUpload999WithRawResponse() { val fileService = client.files().withRawResponse() stubFor( post(anyUrl()) @@ -836,36 +1796,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -876,7 +1900,7 @@ internal class ErrorHandlingTest { } @Test - fun filesUploadV1InvalidJsonBody() { + fun filesUploadInvalidJsonBody() { val fileService = client.files() stubFor( post(anyUrl()) @@ -885,36 +1909,100 @@ internal class ErrorHandlingTest { val e = assertThrows { - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail + .Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .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 648e4af9..4a8e74c3 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.files.FileUploadV1Params +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 @@ -39,40 +39,95 @@ internal class ServiceParamsTest { @Disabled("Prism tests are disabled") @Test - fun uploadV1() { + fun upload() { val fileService = client.files() stubFor(post(anyUrl()).willReturn(ok("{}"))) - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) .signature("signature") - .tags("t-shirt,round-neck,men") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() + .protocol( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("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/BulkJobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncTest.kt deleted file mode 100644 index 53282310..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/BulkJobServiceAsyncTest.kt +++ /dev/null @@ -1,79 +0,0 @@ -// 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.bulkjobs.BulkJobCopyFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class BulkJobServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun copyFolder() { - val client = - ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val bulkJobServiceAsync = client.bulkJobs() - - val responseFuture = - bulkJobServiceAsync.copyFolder( - BulkJobCopyFolderParams.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 moveFolder() { - val client = - ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val bulkJobServiceAsync = client.bulkJobs() - - val responseFuture = - bulkJobServiceAsync.moveFolder( - BulkJobMoveFolderParams.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 retrieveStatus() { - val client = - ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val bulkJobServiceAsync = client.bulkJobs() - - val responseFuture = bulkJobServiceAsync.retrieveStatus("jobId") - - val response = responseFuture.get() - response.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 index cc8b78d6..b1757d6c 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,15 +4,12 @@ package com.imagekit.api.services.async import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.files.FileAddTagsParams +import com.imagekit.api.core.JsonValue import com.imagekit.api.models.files.FileCopyParams -import com.imagekit.api.models.files.FileListParams import com.imagekit.api.models.files.FileMoveParams -import com.imagekit.api.models.files.FileRemoveAiTagsParams -import com.imagekit.api.models.files.FileRemoveTagsParams import com.imagekit.api.models.files.FileRenameParams -import com.imagekit.api.models.files.FileUploadV1Params -import com.imagekit.api.models.files.FileUploadV2Params +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 @@ -22,7 +19,7 @@ internal class FileServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun list() { + fun update() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -31,21 +28,97 @@ internal class FileServiceAsyncTest { .build() val fileServiceAsync = client.files() - val filesFuture = - fileServiceAsync.list( - FileListParams.builder() - .fileType("fileType") - .limit("limit") - .path("path") - .searchQuery("searchQuery") - .skip("skip") - .sort("sort") - .type(FileListParams.Type.FILE) + val fileFuture = + fileServiceAsync.update( + FileUpdateParams.builder() + .fileId("fileId") + .body( + FileUpdateParams.Body.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + JsonValue.from(mapOf("brand" to "Nike", "color" to "red")) + ) + .description("description") + .extensions( + listOf( + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension + .ofAutoDescription( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails + .Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) .build() ) - val files = filesFuture.get() - files.forEach { it.validate() } + val file = fileFuture.get() + file.validate() } @Disabled("Prism tests are disabled") @@ -64,30 +137,6 @@ internal class FileServiceAsyncTest { val response = future.get() } - @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 fileServiceAsync = client.files() - - val responseFuture = - fileServiceAsync.addTags( - FileAddTagsParams.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 copy() { @@ -114,30 +163,7 @@ internal class FileServiceAsyncTest { @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 removeAiTags() { + fun get() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -146,22 +172,15 @@ internal class FileServiceAsyncTest { .build() val fileServiceAsync = client.files() - val responseFuture = - fileServiceAsync.removeAiTags( - FileRemoveAiTagsParams.builder() - .aiTags(listOf("t-shirt", "round-neck", "sale2019")) - .addFileId("598821f949c0a938d57563bd") - .addFileId("598821f949c0a938d57563be") - .build() - ) + val fileFuture = fileServiceAsync.get("fileId") - val response = responseFuture.get() - response.validate() + val file = fileFuture.get() + file.validate() } @Disabled("Prism tests are disabled") @Test - fun removeTags() { + fun move() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -171,11 +190,10 @@ internal class FileServiceAsyncTest { val fileServiceAsync = client.files() val responseFuture = - fileServiceAsync.removeTags( - FileRemoveTagsParams.builder() - .addFileId("598821f949c0a938d57563bd") - .addFileId("598821f949c0a938d57563be") - .tags(listOf("t-shirt", "round-neck", "sale2019")) + fileServiceAsync.move( + FileMoveParams.builder() + .destinationPath("/folder/to/move/into/") + .sourceFilePath("/path/to/file.jpg") .build() ) @@ -209,7 +227,7 @@ internal class FileServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun uploadV1() { + fun upload() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -219,82 +237,95 @@ internal class FileServiceAsyncTest { val fileServiceAsync = client.files() val responseFuture = - fileServiceAsync.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileServiceAsync.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") - .signature("signature") - .tags("t-shirt,round-neck,men") - .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") - .build() - ) - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun uploadV2() { - val client = - ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val fileServiceAsync = client.files() - - val responseFuture = - fileServiceAsync.uploadV2( - FileUploadV2Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" - ) - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" - ) - .folder("folder") - .isPrivateFile(FileUploadV2Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV2Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV2Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV2Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV2Params.OverwriteTags.TRUE) - .responseFields("responseFields") - .tags("t-shirt,round-neck,men") + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV2Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .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 fd310639..175c051b 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 @@ -4,8 +4,11 @@ package com.imagekit.api.services.async import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.folder.FolderCreateParams -import com.imagekit.api.models.folder.FolderDeleteParams +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 @@ -22,7 +25,7 @@ internal class FolderServiceAsyncTest { .privateApiKey("My Private API Key") .password("My Password") .build() - val folderServiceAsync = client.folder() + val folderServiceAsync = client.folders() val folderFuture = folderServiceAsync.create( @@ -45,7 +48,7 @@ internal class FolderServiceAsyncTest { .privateApiKey("My Private API Key") .password("My Password") .build() - val folderServiceAsync = client.folder() + val folderServiceAsync = client.folders() val folderFuture = folderServiceAsync.delete( @@ -55,4 +58,75 @@ internal class FolderServiceAsyncTest { 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..b158789e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -0,0 +1,132 @@ +// 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.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 originFuture = + originServiceAsync.create( + OriginCreateParams.builder() + .body( + OriginCreateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginCreateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + ) + + val origin = originFuture.get() + origin.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 originFuture = + originServiceAsync.update( + OriginUpdateParams.builder() + .id("id") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginUpdateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + ) + + val origin = originFuture.get() + origin.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 originsFuture = originServiceAsync.list() + + val origins = originsFuture.get() + origins.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 originFuture = originServiceAsync.get("id") + + val origin = originFuture.get() + origin.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..d369a913 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -0,0 +1,132 @@ +// 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.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 urlEndpointFuture = + urlEndpointServiceAsync.create( + UrlEndpointCreateParams.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + + val urlEndpoint = urlEndpointFuture.get() + urlEndpoint.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 urlEndpointFuture = + urlEndpointServiceAsync.update( + UrlEndpointUpdateParams.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + + val urlEndpoint = urlEndpointFuture.get() + urlEndpoint.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 urlEndpointsFuture = urlEndpointServiceAsync.list() + + val urlEndpoints = urlEndpointsFuture.get() + urlEndpoints.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 urlEndpointFuture = urlEndpointServiceAsync.get("id") + + val urlEndpoint = urlEndpointFuture.get() + urlEndpoint.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AccountServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt similarity index 66% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AccountServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt index 447db8f3..08dd5a9e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AccountServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt @@ -1,38 +1,38 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +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.AccountGetUsageParams +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 AccountServiceAsyncTest { +internal class UsageServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun getUsage() { + fun get() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) .privateApiKey("My Private API Key") .password("My Password") .build() - val accountServiceAsync = client.accounts() + val usageServiceAsync = client.accounts().usage() - val responseFuture = - accountServiceAsync.getUsage( - AccountGetUsageParams.builder() + val usageFuture = + usageServiceAsync.get( + UsageGetParams.builder() .endDate(LocalDate.parse("2019-12-27")) .startDate(LocalDate.parse("2019-12-27")) .build() ) - val response = responseFuture.get() - response.validate() + 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..73140c41 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -0,0 +1,120 @@ +// 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") + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ) + .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.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .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/files/PurgeServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt similarity index 59% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt index 8204860a..547c8cab 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/PurgeServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt @@ -1,53 +1,53 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files +package com.imagekit.api.services.async.cache import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.files.purge.PurgeExecuteParams +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 PurgeServiceAsyncTest { +internal class InvalidationServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun execute() { + fun create() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) .privateApiKey("My Private API Key") .password("My Password") .build() - val purgeServiceAsync = client.files().purge() + val invalidationServiceAsync = client.cache().invalidation() - val responseFuture = - purgeServiceAsync.execute( - PurgeExecuteParams.builder() + val invalidationFuture = + invalidationServiceAsync.create( + InvalidationCreateParams.builder() .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") .build() ) - val response = responseFuture.get() - response.validate() + val invalidation = invalidationFuture.get() + invalidation.validate() } @Disabled("Prism tests are disabled") @Test - fun status() { + fun get() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) .privateApiKey("My Private API Key") .password("My Password") .build() - val purgeServiceAsync = client.files().purge() + val invalidationServiceAsync = client.cache().invalidation() - val responseFuture = purgeServiceAsync.status("requestId") + val invalidationFuture = invalidationServiceAsync.get("requestId") - val response = responseFuture.get() - response.validate() + 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/DetailServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncTest.kt deleted file mode 100644 index 5ffd2a18..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/DetailServiceAsyncTest.kt +++ /dev/null @@ -1,128 +0,0 @@ -// 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.core.JsonValue -import com.imagekit.api.models.files.details.DetailUpdateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class DetailServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val detailServiceAsync = client.files().details() - - val detailFuture = detailServiceAsync.retrieve("fileId") - - val detail = detailFuture.get() - detail.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 detailServiceAsync = client.files().details() - - val detailFuture = - detailServiceAsync.update( - DetailUpdateParams.builder() - .fileId("fileId") - .body( - DetailUpdateParams.Body.UpdateFileDetails.builder() - .customCoordinates("10,10,100,100") - .customMetadata( - JsonValue.from(mapOf("brand" to "Nike", "color" to "red")) - ) - .extensions( - listOf( - DetailUpdateParams.Body.UpdateFileDetails.Extension - .ofRemovedotBg( - DetailUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - DetailUpdateParams.Body.UpdateFileDetails - .Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) - .options( - DetailUpdateParams.Body.UpdateFileDetails - .Extension - .RemovedotBgExtension - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - DetailUpdateParams.Body.UpdateFileDetails.Extension - .ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - DetailUpdateParams.Body.UpdateFileDetails - .Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - DetailUpdateParams.Body.UpdateFileDetails.Extension - .ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - DetailUpdateParams.Body.UpdateFileDetails - .Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), - ) - ) - .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) - .addTag("tag1") - .addTag("tag2") - .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") - .build() - ) - .build() - ) - - val detail = detailFuture.get() - detail.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 index 1dd5de70..a2f9b677 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 @@ -4,7 +4,7 @@ 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.MetadataFromUrlParams +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 @@ -14,7 +14,7 @@ internal class MetadataServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun retrieve() { + fun get() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -23,7 +23,7 @@ internal class MetadataServiceAsyncTest { .build() val metadataServiceAsync = client.files().metadata() - val metadataFuture = metadataServiceAsync.retrieve("fileId") + val metadataFuture = metadataServiceAsync.get("fileId") val metadata = metadataFuture.get() metadata.validate() @@ -31,7 +31,7 @@ internal class MetadataServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun fromUrl() { + fun getFromUrl() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -41,7 +41,9 @@ internal class MetadataServiceAsyncTest { val metadataServiceAsync = client.files().metadata() val responseFuture = - metadataServiceAsync.fromUrl(MetadataFromUrlParams.builder().url("url").build()) + metadataServiceAsync.getFromUrl( + MetadataGetFromUrlParams.builder().url("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/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt index 89ee14cc..7e2882f8 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 @@ -5,8 +5,8 @@ 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 com.imagekit.api.models.files.versions.VersionRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -16,7 +16,7 @@ internal class VersionServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun retrieve() { + fun list() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -25,18 +25,15 @@ internal class VersionServiceAsyncTest { .build() val versionServiceAsync = client.files().versions() - val versionFuture = - versionServiceAsync.retrieve( - VersionRetrieveParams.builder().fileId("fileId").versionId("versionId").build() - ) + val versionsFuture = versionServiceAsync.list("fileId") - val version = versionFuture.get() - version.validate() + val versions = versionsFuture.get() + versions.forEach { it.validate() } } @Disabled("Prism tests are disabled") @Test - fun list() { + fun delete() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -45,15 +42,18 @@ internal class VersionServiceAsyncTest { .build() val versionServiceAsync = client.files().versions() - val versionsFuture = versionServiceAsync.list("fileId") + val versionFuture = + versionServiceAsync.delete( + VersionDeleteParams.builder().fileId("fileId").versionId("versionId").build() + ) - val versions = versionsFuture.get() - versions.forEach { it.validate() } + val version = versionFuture.get() + version.validate() } @Disabled("Prism tests are disabled") @Test - fun delete() { + fun get() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -63,8 +63,8 @@ internal class VersionServiceAsyncTest { val versionServiceAsync = client.files().versions() val versionFuture = - versionServiceAsync.delete( - VersionDeleteParams.builder().fileId("fileId").versionId("versionId").build() + versionServiceAsync.get( + VersionGetParams.builder().fileId("fileId").versionId("versionId").build() ) val version = versionFuture.get() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt similarity index 53% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt index bae3c702..db5b2d61 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BatchServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt @@ -1,37 +1,30 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files +package com.imagekit.api.services.async.folders import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.files.batch.BatchDeleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -internal class BatchServiceAsyncTest { +internal class JobServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun delete() { + fun get() { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) .privateApiKey("My Private API Key") .password("My Password") .build() - val batchServiceAsync = client.files().batch() + val jobServiceAsync = client.folders().job() - val batchFuture = - batchServiceAsync.delete( - BatchDeleteParams.builder() - .addFileId("598821f949c0a938d57563bd") - .addFileId("598821f949c0a938d57563be") - .build() - ) + val jobFuture = jobServiceAsync.get("jobId") - val batch = batchFuture.get() - batch.validate() + 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/BulkJobServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/BulkJobServiceTest.kt deleted file mode 100644 index 1415b6e0..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/BulkJobServiceTest.kt +++ /dev/null @@ -1,76 +0,0 @@ -// 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.bulkjobs.BulkJobCopyFolderParams -import com.imagekit.api.models.bulkjobs.BulkJobMoveFolderParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class BulkJobServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun copyFolder() { - val client = - ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val bulkJobService = client.bulkJobs() - - val response = - bulkJobService.copyFolder( - BulkJobCopyFolderParams.builder() - .destinationPath("/path/of/destination/folder") - .sourceFolderPath("/path/of/source/folder") - .includeVersions(true) - .build() - ) - - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun moveFolder() { - val client = - ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val bulkJobService = client.bulkJobs() - - val response = - bulkJobService.moveFolder( - BulkJobMoveFolderParams.builder() - .destinationPath("/path/of/destination/folder") - .sourceFolderPath("/path/of/source/folder") - .build() - ) - - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveStatus() { - val client = - ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val bulkJobService = client.bulkJobs() - - val response = bulkJobService.retrieveStatus("jobId") - - response.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 index ed90880e..5c10683f 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,15 +4,12 @@ package com.imagekit.api.services.blocking import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.files.FileAddTagsParams +import com.imagekit.api.core.JsonValue import com.imagekit.api.models.files.FileCopyParams -import com.imagekit.api.models.files.FileListParams import com.imagekit.api.models.files.FileMoveParams -import com.imagekit.api.models.files.FileRemoveAiTagsParams -import com.imagekit.api.models.files.FileRemoveTagsParams import com.imagekit.api.models.files.FileRenameParams -import com.imagekit.api.models.files.FileUploadV1Params -import com.imagekit.api.models.files.FileUploadV2Params +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 @@ -22,7 +19,7 @@ internal class FileServiceTest { @Disabled("Prism tests are disabled") @Test - fun list() { + fun update() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -31,20 +28,96 @@ internal class FileServiceTest { .build() val fileService = client.files() - val files = - fileService.list( - FileListParams.builder() - .fileType("fileType") - .limit("limit") - .path("path") - .searchQuery("searchQuery") - .skip("skip") - .sort("sort") - .type(FileListParams.Type.FILE) + val file = + fileService.update( + FileUpdateParams.builder() + .fileId("fileId") + .body( + FileUpdateParams.Body.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + JsonValue.from(mapOf("brand" to "Nike", "color" to "red")) + ) + .description("description") + .extensions( + listOf( + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension + .ofAutoDescription( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails + .Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) .build() ) - files.forEach { it.validate() } + file.validate() } @Disabled("Prism tests are disabled") @@ -61,29 +134,6 @@ internal class FileServiceTest { fileService.delete("fileId") } - @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 fileService = client.files() - - val response = - fileService.addTags( - FileAddTagsParams.builder() - .addFileId("598821f949c0a938d57563bd") - .addFileId("598821f949c0a938d57563be") - .tags(listOf("t-shirt", "round-neck", "sale2019")) - .build() - ) - - response.validate() - } - @Disabled("Prism tests are disabled") @Test fun copy() { @@ -109,29 +159,7 @@ internal class FileServiceTest { @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 removeAiTags() { + fun get() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -140,21 +168,14 @@ internal class FileServiceTest { .build() val fileService = client.files() - val response = - fileService.removeAiTags( - FileRemoveAiTagsParams.builder() - .aiTags(listOf("t-shirt", "round-neck", "sale2019")) - .addFileId("598821f949c0a938d57563bd") - .addFileId("598821f949c0a938d57563be") - .build() - ) + val file = fileService.get("fileId") - response.validate() + file.validate() } @Disabled("Prism tests are disabled") @Test - fun removeTags() { + fun move() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -164,11 +185,10 @@ internal class FileServiceTest { val fileService = client.files() val response = - fileService.removeTags( - FileRemoveTagsParams.builder() - .addFileId("598821f949c0a938d57563bd") - .addFileId("598821f949c0a938d57563be") - .tags(listOf("t-shirt", "round-neck", "sale2019")) + fileService.move( + FileMoveParams.builder() + .destinationPath("/folder/to/move/into/") + .sourceFilePath("/path/to/file.jpg") .build() ) @@ -200,7 +220,7 @@ internal class FileServiceTest { @Disabled("Prism tests are disabled") @Test - fun uploadV1() { + fun upload() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -210,81 +230,95 @@ internal class FileServiceTest { val fileService = client.files() val response = - fileService.uploadV1( - FileUploadV1Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") .customCoordinates("customCoordinates") .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) - .expire("expire") - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" + .description("Running shoes") + .expire(0L) + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() ) .folder("folder") - .isPrivateFile(FileUploadV1Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV1Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV1Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV1Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV1Params.OverwriteTags.TRUE) + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) .publicKey("publicKey") - .responseFields("responseFields") - .signature("signature") - .tags("t-shirt,round-neck,men") - .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) ) - .useUniqueFileName(FileUploadV1Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") - .build() - ) - - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun uploadV2() { - val client = - ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val fileService = client.files() - - val response = - fileService.uploadV2( - FileUploadV2Params.builder() - .file("https://www.example.com/rest-of-the-image-path.jpg") - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - "\"\n {\n \"brand\": \"Nike\",\n \"color\":\"red\"\n }\n\"\n" - ) - .extensions( - "\"\n[\n {\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_colour\":\"green\"}},\n {\"name\":\"google-auto-tagging\",\"maxTags\":5,\"minConfidence\":95}\n]\n\"\n" - ) - .folder("folder") - .isPrivateFile(FileUploadV2Params.IsPrivateFile.TRUE) - .isPublished(FileUploadV2Params.IsPublished.TRUE) - .overwriteAiTags(FileUploadV2Params.OverwriteAiTags.TRUE) - .overwriteCustomMetadata(FileUploadV2Params.OverwriteCustomMetadata.TRUE) - .overwriteFile("overwriteFile") - .overwriteTags(FileUploadV2Params.OverwriteTags.TRUE) - .responseFields("responseFields") - .tags("t-shirt,round-neck,men") + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - "'{\"pre\":\"width:300,height:300,quality:80\",\"post\":[{\"type\":\"thumbnail\",\"value\":\"width:100,height:100\"}]}'\n" + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .useUniqueFileName(FileUploadV2Params.UseUniqueFileName.TRUE) - .webhookUrl("webhookUrl") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .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 64b86567..13026e90 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 @@ -4,8 +4,11 @@ package com.imagekit.api.services.blocking import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.folder.FolderCreateParams -import com.imagekit.api.models.folder.FolderDeleteParams +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 @@ -22,7 +25,7 @@ internal class FolderServiceTest { .privateApiKey("My Private API Key") .password("My Password") .build() - val folderService = client.folder() + val folderService = client.folders() val folder = folderService.create( @@ -44,7 +47,7 @@ internal class FolderServiceTest { .privateApiKey("My Private API Key") .password("My Password") .build() - val folderService = client.folder() + val folderService = client.folders() val folder = folderService.delete( @@ -53,4 +56,72 @@ internal class FolderServiceTest { 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..618762e2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -0,0 +1,126 @@ +// 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.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 origin = + originService.create( + OriginCreateParams.builder() + .body( + OriginCreateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginCreateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + ) + + origin.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 origin = + originService.update( + OriginUpdateParams.builder() + .id("id") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .type(OriginUpdateParams.Body.S3.Type.S3) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + ) + + origin.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 origins = originService.list() + + origins.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 origin = originService.get("id") + + origin.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..be2df93b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -0,0 +1,126 @@ +// 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.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 urlEndpoint = + urlEndpointService.create( + UrlEndpointCreateParams.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type( + UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + + urlEndpoint.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 urlEndpoint = + urlEndpointService.update( + UrlEndpointUpdateParams.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() + .type( + UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type + .CLOUDINARY + ) + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + + urlEndpoint.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 urlEndpoints = urlEndpointService.list() + + urlEndpoints.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 urlEndpoint = urlEndpointService.get("id") + + urlEndpoint.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AccountServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt similarity index 70% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AccountServiceTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt index 6a2abd3c..b579bdf8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AccountServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt @@ -1,37 +1,37 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +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.AccountGetUsageParams +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 AccountServiceTest { +internal class UsageServiceTest { @Disabled("Prism tests are disabled") @Test - fun getUsage() { + fun get() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .privateApiKey("My Private API Key") .password("My Password") .build() - val accountService = client.accounts() + val usageService = client.accounts().usage() - val response = - accountService.getUsage( - AccountGetUsageParams.builder() + val usage = + usageService.get( + UsageGetParams.builder() .endDate(LocalDate.parse("2019-12-27")) .startDate(LocalDate.parse("2019-12-27")) .build() ) - response.validate() + 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..ea4d43ff --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -0,0 +1,119 @@ +// 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") + .addExtension( + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + .options( + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .addExtension( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ) + .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.GenerateAThumbnail.builder() + .type( + FileUploadParams.Transformation.Post.GenerateAThumbnail.Type + .THUMBNAIL + ) + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming + .builder() + .protocol( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Protocol + .DASH + ) + .type( + FileUploadParams.Transformation.Post + .AdaptiveBitrateStreaming + .Type + .ABS + ) + .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/files/PurgeServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt similarity index 64% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt index 7f2e4404..819af016 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/PurgeServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt @@ -1,51 +1,51 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package com.imagekit.api.services.blocking.cache import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.files.purge.PurgeExecuteParams +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 PurgeServiceTest { +internal class InvalidationServiceTest { @Disabled("Prism tests are disabled") @Test - fun execute() { + fun create() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .privateApiKey("My Private API Key") .password("My Password") .build() - val purgeService = client.files().purge() + val invalidationService = client.cache().invalidation() - val response = - purgeService.execute( - PurgeExecuteParams.builder() + val invalidation = + invalidationService.create( + InvalidationCreateParams.builder() .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") .build() ) - response.validate() + invalidation.validate() } @Disabled("Prism tests are disabled") @Test - fun status() { + fun get() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .privateApiKey("My Private API Key") .password("My Password") .build() - val purgeService = client.files().purge() + val invalidationService = client.cache().invalidation() - val response = purgeService.status("requestId") + val invalidation = invalidationService.get("requestId") - response.validate() + 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/DetailServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/DetailServiceTest.kt deleted file mode 100644 index 1952294b..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/DetailServiceTest.kt +++ /dev/null @@ -1,126 +0,0 @@ -// 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.core.JsonValue -import com.imagekit.api.models.files.details.DetailUpdateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class DetailServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") - .password("My Password") - .build() - val detailService = client.files().details() - - val detail = detailService.retrieve("fileId") - - detail.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 detailService = client.files().details() - - val detail = - detailService.update( - DetailUpdateParams.builder() - .fileId("fileId") - .body( - DetailUpdateParams.Body.UpdateFileDetails.builder() - .customCoordinates("10,10,100,100") - .customMetadata( - JsonValue.from(mapOf("brand" to "Nike", "color" to "red")) - ) - .extensions( - listOf( - DetailUpdateParams.Body.UpdateFileDetails.Extension - .ofRemovedotBg( - DetailUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - DetailUpdateParams.Body.UpdateFileDetails - .Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) - .options( - DetailUpdateParams.Body.UpdateFileDetails - .Extension - .RemovedotBgExtension - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - DetailUpdateParams.Body.UpdateFileDetails.Extension - .ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - DetailUpdateParams.Body.UpdateFileDetails - .Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - DetailUpdateParams.Body.UpdateFileDetails.Extension - .ofAutoTagging( - DetailUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - DetailUpdateParams.Body.UpdateFileDetails - .Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), - ) - ) - .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) - .addTag("tag1") - .addTag("tag2") - .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") - .build() - ) - .build() - ) - - detail.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 index cbf5e594..fc0abfd8 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 @@ -4,7 +4,7 @@ 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.MetadataFromUrlParams +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 @@ -14,7 +14,7 @@ internal class MetadataServiceTest { @Disabled("Prism tests are disabled") @Test - fun retrieve() { + fun get() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -23,14 +23,14 @@ internal class MetadataServiceTest { .build() val metadataService = client.files().metadata() - val metadata = metadataService.retrieve("fileId") + val metadata = metadataService.get("fileId") metadata.validate() } @Disabled("Prism tests are disabled") @Test - fun fromUrl() { + fun getFromUrl() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -39,7 +39,10 @@ internal class MetadataServiceTest { .build() val metadataService = client.files().metadata() - val response = metadataService.fromUrl(MetadataFromUrlParams.builder().url("url").build()) + val response = + metadataService.getFromUrl( + MetadataGetFromUrlParams.builder().url("https://example.com").build() + ) response.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 index 834b3d32..da360905 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 @@ -5,8 +5,8 @@ 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 com.imagekit.api.models.files.versions.VersionRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -16,7 +16,7 @@ internal class VersionServiceTest { @Disabled("Prism tests are disabled") @Test - fun retrieve() { + fun list() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -25,17 +25,14 @@ internal class VersionServiceTest { .build() val versionService = client.files().versions() - val version = - versionService.retrieve( - VersionRetrieveParams.builder().fileId("fileId").versionId("versionId").build() - ) + val versions = versionService.list("fileId") - version.validate() + versions.forEach { it.validate() } } @Disabled("Prism tests are disabled") @Test - fun list() { + fun delete() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -44,14 +41,17 @@ internal class VersionServiceTest { .build() val versionService = client.files().versions() - val versions = versionService.list("fileId") + val version = + versionService.delete( + VersionDeleteParams.builder().fileId("fileId").versionId("versionId").build() + ) - versions.forEach { it.validate() } + version.validate() } @Disabled("Prism tests are disabled") @Test - fun delete() { + fun get() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -61,8 +61,8 @@ internal class VersionServiceTest { val versionService = client.files().versions() val version = - versionService.delete( - VersionDeleteParams.builder().fileId("fileId").versionId("versionId").build() + versionService.get( + VersionGetParams.builder().fileId("fileId").versionId("versionId").build() ) version.validate() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BatchServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt similarity index 55% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BatchServiceTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt index 843205f0..63455dd0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BatchServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt @@ -1,36 +1,29 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package com.imagekit.api.services.blocking.folders import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.files.batch.BatchDeleteParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -internal class BatchServiceTest { +internal class JobServiceTest { @Disabled("Prism tests are disabled") @Test - fun delete() { + fun get() { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .privateApiKey("My Private API Key") .password("My Password") .build() - val batchService = client.files().batch() + val jobService = client.folders().job() - val batch = - batchService.delete( - BatchDeleteParams.builder() - .addFileId("598821f949c0a938d57563bd") - .addFileId("598821f949c0a938d57563be") - .build() - ) + val job = jobService.get("jobId") - batch.validate() + job.validate() } } 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 1e5ed845..b09243de 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 @@ -4,8 +4,10 @@ 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.files.ExifDetails +import com.imagekit.api.models.assets.AssetListResponse +import com.imagekit.api.models.files.FileUpdateResponse import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod import org.assertj.core.api.Assertions.assertThat @@ -53,50 +55,115 @@ internal class ProGuardCompatibilityTest { assertThat(client).isNotNull() assertThat(client.customMetadataFields()).isNotNull() assertThat(client.files()).isNotNull() - assertThat(client.folder()).isNotNull() - assertThat(client.bulkJobs()).isNotNull() + assertThat(client.assets()).isNotNull() + assertThat(client.cache()).isNotNull() + assertThat(client.folders()).isNotNull() assertThat(client.accounts()).isNotNull() + assertThat(client.beta()).isNotNull() } @Test - fun exifDetailsRoundtrip() { + fun fileUpdateResponseRoundtrip() { val jsonMapper = jsonMapper() - val exifDetails = - ExifDetails.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) + val fileUpdateResponse = + FileUpdateResponse.builder() + .addAiTag( + FileUpdateResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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() + ) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) .build() - val roundtrippedExifDetails = + val roundtrippedFileUpdateResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(exifDetails), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileUpdateResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedExifDetails).isEqualTo(exifDetails) + assertThat(roundtrippedFileUpdateResponse).isEqualTo(fileUpdateResponse) + } + + @Test + fun assetListResponseRoundtrip() { + val jsonMapper = jsonMapper() + val assetListResponse = + AssetListResponse.ofFileDetails( + AssetListResponse.FileDetails.builder() + .addAiTag( + AssetListResponse.FileDetails.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .createdAt("createdAt") + .customCoordinates("customCoordinates") + .customMetadata(JsonValue.from(mapOf())) + .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("thumbnail") + .type("type") + .updatedAt("updatedAt") + .url("url") + .versionInfo( + AssetListResponse.FileDetails.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .width(0.0) + .build() + ) + + val roundtrippedAssetListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assetListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssetListResponse).isEqualTo(assetListResponse) } } From 21f9ab70307ca00ac26efc6cae5d918606092bbf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 Aug 2025 06:21:44 +0000 Subject: [PATCH 005/125] feat(api): manual updates --- .stats.yml | 2 +- .../com/imagekit/api/models/ExifDetails.kt | 1142 ++++++++ .../com/imagekit/api/models/ExifImage.kt | 522 ++++ .../kotlin/com/imagekit/api/models/Gps.kt | 178 ++ .../imagekit/api/models/Interoperability.kt | 201 ++ .../com/imagekit/api/models/Thumbnail.kt | 359 +++ .../beta/v2/files/FileUploadResponse.kt | 2608 +---------------- .../api/models/files/FileUploadResponse.kt | 2608 +---------------- .../metadata/MetadataGetFromUrlResponse.kt | 2568 +--------------- .../files/metadata/MetadataGetResponse.kt | 2568 +--------------- .../imagekit/api/models/ExifDetailsTest.kt | 113 + .../com/imagekit/api/models/ExifImageTest.kt | 68 + .../kotlin/com/imagekit/api/models/GpsTest.kt | 30 + .../api/models/InteroperabilityTest.kt | 41 + .../com/imagekit/api/models/ThumbnailTest.kt | 53 + .../beta/v2/files/FileUploadResponseTest.kt | 47 +- .../models/files/FileUploadResponseTest.kt | 47 +- .../MetadataGetFromUrlResponseTest.kt | 43 +- .../files/metadata/MetadataGetResponseTest.kt | 35 +- 19 files changed, 3010 insertions(+), 10223 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifDetails.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifImage.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Gps.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Interoperability.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Thumbnail.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifDetailsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifImageTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GpsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/InteroperabilityTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ThumbnailTest.kt diff --git a/.stats.yml b/.stats.yml index ee7ab859..d25e9ed9 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-c01164d5dc8f8c9ab2b7c1a1c793ac522d565f96e569b0e56a4e9353e39bab85.yml openapi_spec_hash: ac7b3a2b968fe86bf7bb81192209123f -config_hash: 8a4138f8d02720b4736ab63effb7fa2d +config_hash: 963efe3c7e328464ca83ae352b29bbb4 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifDetails.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifDetails.kt new file mode 100644 index 00000000..956b2b5c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifDetails.kt @@ -0,0 +1,1142 @@ +// 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 + +/** Object containing Exif details. */ +class ExifDetails +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 [ExifDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExifDetails]. */ + 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(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) = 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 [ExifDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExifDetails = + ExifDetails( + 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(): ExifDetails = 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 ExifDetails && + 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() = + "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}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifImage.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifImage.kt new file mode 100644 index 00000000..eb6f007f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifImage.kt @@ -0,0 +1,522 @@ +// 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 + +/** Object containing EXIF image information. */ +class ExifImage +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 [ExifImage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExifImage]. */ + 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(exifImage: ExifImage) = apply { + exifOffset = exifImage.exifOffset + gpsInfo = exifImage.gpsInfo + make = exifImage.make + model = exifImage.model + modifyDate = exifImage.modifyDate + orientation = exifImage.orientation + resolutionUnit = exifImage.resolutionUnit + software = exifImage.software + xResolution = exifImage.xResolution + yCbCrPositioning = exifImage.yCbCrPositioning + yResolution = exifImage.yResolution + additionalProperties = exifImage.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 [ExifImage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExifImage = + ExifImage( + exifOffset, + gpsInfo, + make, + model, + modifyDate, + orientation, + resolutionUnit, + software, + xResolution, + yCbCrPositioning, + yResolution, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExifImage = 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 ExifImage && + 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() = + "ExifImage{exifOffset=$exifOffset, gpsInfo=$gpsInfo, make=$make, model=$model, modifyDate=$modifyDate, orientation=$orientation, resolutionUnit=$resolutionUnit, software=$software, xResolution=$xResolution, yCbCrPositioning=$yCbCrPositioning, yResolution=$yResolution, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Gps.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Gps.kt new file mode 100644 index 00000000..a602b722 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Gps.kt @@ -0,0 +1,178 @@ +// 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.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 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}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Interoperability.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Interoperability.kt new file mode 100644 index 00000000..36235c9b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Interoperability.kt @@ -0,0 +1,201 @@ +// 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 + +/** 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}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Thumbnail.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Thumbnail.kt new file mode 100644 index 00000000..ea242786 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Thumbnail.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.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** 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}" +} 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 f4565a2d..2af5e4bf 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.ExifDetails +import com.imagekit.api.models.ExifImage +import com.imagekit.api.models.Gps +import com.imagekit.api.models.Interoperability +import com.imagekit.api.models.Thumbnail import java.util.Collections import java.util.Objects import java.util.Optional @@ -2632,9 +2637,9 @@ private constructor( class Exif private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, - private val image: JsonField, + private val image: JsonField, private val interoperability: JsonField, private val makernote: JsonField, private val thumbnail: JsonField, @@ -2643,9 +2648,13 @@ 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("image") + @ExcludeMissing + image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @ExcludeMissing interoperability: JsonField = JsonMissing.of(), @@ -2663,7 +2672,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. @@ -2679,7 +2688,7 @@ private constructor( * @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") + fun image(): Optional = image.getOptional("image") /** * JSON object. @@ -2709,7 +2718,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]. @@ -2723,7 +2732,7 @@ private constructor( * * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image /** * Returns the raw JSON value of [interoperability]. @@ -2776,9 +2785,9 @@ 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 image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() private var makernote: JsonField = JsonMissing.of() private var thumbnail: JsonField = JsonMissing.of() @@ -2796,16 +2805,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 + * 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)) @@ -2820,16 +2829,16 @@ private constructor( fun gps(gps: JsonField) = apply { this.gps = gps } /** Object containing EXIF image information. */ - fun image(image: Image) = image(JsonField.of(image)) + fun image(image: ExifImage) = 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. + * You should usually call [Builder.image] with a well-typed [ExifImage] 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 } + fun image(image: JsonField) = apply { this.image = image } /** JSON object. */ fun interoperability(interoperability: Interoperability) = @@ -2951,2197 +2960,70 @@ private constructor( (makernote.asKnown().getOrNull()?.validity() ?: 0) + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) - /** Object containing Exif details. */ - class InnerExif + class Makernote + @JsonCreator 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, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @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 _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [InnerExif]. */ + /** Returns a mutable builder for constructing an instance of [Makernote]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InnerExif]. */ + /** A builder for [Makernote]. */ 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() + internal fun from(makernote: Makernote) = apply { + additionalProperties = makernote.additionalProperties.toMutableMap() } - fun apertureValue(apertureValue: Double) = - apertureValue(JsonField.of(apertureValue)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * 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 putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun colorSpace(colorSpace: Long) = colorSpace(JsonField.of(colorSpace)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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 removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun createDate(createDate: String) = createDate(JsonField.of(createDate)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.createDate] to an arbitrary JSON value. + * Returns an immutable instance of [Makernote]. * - * 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. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun createDate(createDate: JsonField) = apply { - this.createDate = createDate - } + fun build(): Makernote = Makernote(additionalProperties.toImmutable()) + } - fun customRendered(customRendered: Long) = - customRendered(JsonField.of(customRendered)) + private var validated: Boolean = false - /** - * 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 + fun validate(): Makernote = apply { + if (validated) { + return@apply } validated = true @@ -5182,378 +3064,6 @@ private constructor( 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 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 53422ce1..77267f46 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.ExifDetails +import com.imagekit.api.models.ExifImage +import com.imagekit.api.models.Gps +import com.imagekit.api.models.Interoperability +import com.imagekit.api.models.Thumbnail import java.util.Collections import java.util.Objects import java.util.Optional @@ -2632,9 +2637,9 @@ private constructor( class Exif private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, - private val image: JsonField, + private val image: JsonField, private val interoperability: JsonField, private val makernote: JsonField, private val thumbnail: JsonField, @@ -2643,9 +2648,13 @@ 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("image") + @ExcludeMissing + image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @ExcludeMissing interoperability: JsonField = JsonMissing.of(), @@ -2663,7 +2672,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. @@ -2679,7 +2688,7 @@ private constructor( * @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") + fun image(): Optional = image.getOptional("image") /** * JSON object. @@ -2709,7 +2718,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]. @@ -2723,7 +2732,7 @@ private constructor( * * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image /** * Returns the raw JSON value of [interoperability]. @@ -2776,9 +2785,9 @@ 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 image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() private var makernote: JsonField = JsonMissing.of() private var thumbnail: JsonField = JsonMissing.of() @@ -2796,16 +2805,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 + * 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)) @@ -2820,16 +2829,16 @@ private constructor( fun gps(gps: JsonField) = apply { this.gps = gps } /** Object containing EXIF image information. */ - fun image(image: Image) = image(JsonField.of(image)) + fun image(image: ExifImage) = 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. + * You should usually call [Builder.image] with a well-typed [ExifImage] 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 } + fun image(image: JsonField) = apply { this.image = image } /** JSON object. */ fun interoperability(interoperability: Interoperability) = @@ -2951,2197 +2960,70 @@ private constructor( (makernote.asKnown().getOrNull()?.validity() ?: 0) + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) - /** Object containing Exif details. */ - class InnerExif + class Makernote + @JsonCreator 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, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @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 _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [InnerExif]. */ + /** Returns a mutable builder for constructing an instance of [Makernote]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InnerExif]. */ + /** A builder for [Makernote]. */ 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() + internal fun from(makernote: Makernote) = apply { + additionalProperties = makernote.additionalProperties.toMutableMap() } - fun apertureValue(apertureValue: Double) = - apertureValue(JsonField.of(apertureValue)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * 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 putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - fun colorSpace(colorSpace: Long) = colorSpace(JsonField.of(colorSpace)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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 removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun createDate(createDate: String) = createDate(JsonField.of(createDate)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.createDate] to an arbitrary JSON value. + * Returns an immutable instance of [Makernote]. * - * 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. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun createDate(createDate: JsonField) = apply { - this.createDate = createDate - } + fun build(): Makernote = Makernote(additionalProperties.toImmutable()) + } - fun customRendered(customRendered: Long) = - customRendered(JsonField.of(customRendered)) + private var validated: Boolean = false - /** - * 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 + fun validate(): Makernote = apply { + if (validated) { + return@apply } validated = true @@ -5182,378 +3064,6 @@ private constructor( 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt index c88f4cbd..7c22afd7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt @@ -10,9 +10,13 @@ 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.ExifDetails +import com.imagekit.api.models.ExifImage +import com.imagekit.api.models.Gps +import com.imagekit.api.models.Interoperability +import com.imagekit.api.models.Thumbnail import java.util.Collections import java.util.Objects import java.util.Optional @@ -613,9 +617,9 @@ private constructor( class Exif private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, - private val image: JsonField, + private val image: JsonField, private val interoperability: JsonField, private val makernote: JsonField, private val thumbnail: JsonField, @@ -624,9 +628,9 @@ 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("image") @ExcludeMissing image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @ExcludeMissing interoperability: JsonField = JsonMissing.of(), @@ -644,7 +648,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. @@ -660,7 +664,7 @@ private constructor( * @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") + fun image(): Optional = image.getOptional("image") /** * JSON object. @@ -690,7 +694,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]. @@ -704,7 +708,7 @@ private constructor( * * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image /** * Returns the raw JSON value of [interoperability]. @@ -755,9 +759,9 @@ 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 image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() private var makernote: JsonField = JsonMissing.of() private var thumbnail: JsonField = JsonMissing.of() @@ -775,16 +779,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)) @@ -799,16 +803,16 @@ private constructor( fun gps(gps: JsonField) = apply { this.gps = gps } /** Object containing EXIF image information. */ - fun image(image: Image) = image(JsonField.of(image)) + fun image(image: ExifImage) = 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. + * You should usually call [Builder.image] with a well-typed [ExifImage] 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 } + fun image(image: JsonField) = apply { this.image = image } /** JSON object. */ fun interoperability(interoperability: Interoperability) = @@ -923,2164 +927,66 @@ private constructor( (makernote.asKnown().getOrNull()?.validity() ?: 0) + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) - /** Object containing Exif details. */ - class InnerExif + class Makernote + @JsonCreator 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, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @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 _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [InnerExif]. */ + /** Returns a mutable builder for constructing an instance of [Makernote]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InnerExif]. */ + /** A builder for [Makernote]. */ 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() + internal fun from(makernote: Makernote) = apply { + additionalProperties = makernote.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 additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - 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 putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun createDate(createDate: String) = createDate(JsonField.of(createDate)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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 removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun customRendered(customRendered: Long) = - customRendered(JsonField.of(customRendered)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.customRendered] to an arbitrary JSON value. + * Returns an immutable instance of [Makernote]. * - * 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. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun customRendered(customRendered: JsonField) = apply { - this.customRendered = customRendered - } + fun build(): Makernote = Makernote(additionalProperties.toImmutable()) + } - 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 + private var validated: Boolean = false fun validate(): Makernote = apply { if (validated) { @@ -3123,376 +1029,6 @@ private constructor( 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt index cca25a2a..7d990582 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt @@ -10,9 +10,13 @@ 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.ExifDetails +import com.imagekit.api.models.ExifImage +import com.imagekit.api.models.Gps +import com.imagekit.api.models.Interoperability +import com.imagekit.api.models.Thumbnail import java.util.Collections import java.util.Objects import java.util.Optional @@ -611,9 +615,9 @@ private constructor( class Exif private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, - private val image: JsonField, + private val image: JsonField, private val interoperability: JsonField, private val makernote: JsonField, private val thumbnail: JsonField, @@ -622,9 +626,9 @@ 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("image") @ExcludeMissing image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @ExcludeMissing interoperability: JsonField = JsonMissing.of(), @@ -642,7 +646,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. @@ -658,7 +662,7 @@ private constructor( * @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") + fun image(): Optional = image.getOptional("image") /** * JSON object. @@ -688,7 +692,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]. @@ -702,7 +706,7 @@ private constructor( * * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image /** * Returns the raw JSON value of [interoperability]. @@ -753,9 +757,9 @@ 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 image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() private var makernote: JsonField = JsonMissing.of() private var thumbnail: JsonField = JsonMissing.of() @@ -773,16 +777,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)) @@ -797,16 +801,16 @@ private constructor( fun gps(gps: JsonField) = apply { this.gps = gps } /** Object containing EXIF image information. */ - fun image(image: Image) = image(JsonField.of(image)) + fun image(image: ExifImage) = 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. + * You should usually call [Builder.image] with a well-typed [ExifImage] 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 } + fun image(image: JsonField) = apply { this.image = image } /** JSON object. */ fun interoperability(interoperability: Interoperability) = @@ -921,2164 +925,66 @@ private constructor( (makernote.asKnown().getOrNull()?.validity() ?: 0) + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) - /** Object containing Exif details. */ - class InnerExif + class Makernote + @JsonCreator 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, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @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 _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [InnerExif]. */ + /** Returns a mutable builder for constructing an instance of [Makernote]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InnerExif]. */ + /** A builder for [Makernote]. */ 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() + internal fun from(makernote: Makernote) = apply { + additionalProperties = makernote.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 additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - 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 putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun createDate(createDate: String) = createDate(JsonField.of(createDate)) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - /** - * 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 removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun customRendered(customRendered: Long) = - customRendered(JsonField.of(customRendered)) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.customRendered] to an arbitrary JSON value. + * Returns an immutable instance of [Makernote]. * - * 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. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun customRendered(customRendered: JsonField) = apply { - this.customRendered = customRendered - } + fun build(): Makernote = Makernote(additionalProperties.toImmutable()) + } - 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 + private var validated: Boolean = false fun validate(): Makernote = apply { if (validated) { @@ -3121,376 +1027,6 @@ private constructor( 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 diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifDetailsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifDetailsTest.kt new file mode 100644 index 00000000..d9751270 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifDetailsTest.kt @@ -0,0 +1,113 @@ +// 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 ExifDetailsTest { + + @Test + fun create() { + val exifDetails = + ExifDetails.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() + + assertThat(exifDetails.apertureValue()).contains(0.0) + assertThat(exifDetails.colorSpace()).contains(0L) + assertThat(exifDetails.createDate()).contains("CreateDate") + assertThat(exifDetails.customRendered()).contains(0L) + assertThat(exifDetails.dateTimeOriginal()).contains("DateTimeOriginal") + assertThat(exifDetails.exifImageHeight()).contains(0L) + assertThat(exifDetails.exifImageWidth()).contains(0L) + assertThat(exifDetails.exifVersion()).contains("ExifVersion") + assertThat(exifDetails.exposureCompensation()).contains(0.0) + assertThat(exifDetails.exposureMode()).contains(0L) + assertThat(exifDetails.exposureProgram()).contains(0L) + assertThat(exifDetails.exposureTime()).contains(0.0) + assertThat(exifDetails.flash()).contains(0L) + assertThat(exifDetails.flashpixVersion()).contains("FlashpixVersion") + assertThat(exifDetails.fNumber()).contains(0.0) + assertThat(exifDetails.focalLength()).contains(0L) + assertThat(exifDetails.focalPlaneResolutionUnit()).contains(0L) + assertThat(exifDetails.focalPlaneXResolution()).contains(0.0) + assertThat(exifDetails.focalPlaneYResolution()).contains(0.0) + assertThat(exifDetails.interopOffset()).contains(0L) + assertThat(exifDetails.iso()).contains(0L) + assertThat(exifDetails.meteringMode()).contains(0L) + assertThat(exifDetails.sceneCaptureType()).contains(0L) + assertThat(exifDetails.shutterSpeedValue()).contains(0.0) + assertThat(exifDetails.subSecTime()).contains("SubSecTime") + assertThat(exifDetails.whiteBalance()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exifDetails = + ExifDetails.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() + + val roundtrippedExifDetails = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exifDetails), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExifDetails).isEqualTo(exifDetails) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifImageTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifImageTest.kt new file mode 100644 index 00000000..ea48c88c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifImageTest.kt @@ -0,0 +1,68 @@ +// 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 ExifImageTest { + + @Test + fun create() { + val exifImage = + ExifImage.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + + assertThat(exifImage.exifOffset()).contains(0L) + assertThat(exifImage.gpsInfo()).contains(0L) + assertThat(exifImage.make()).contains("Make") + assertThat(exifImage.model()).contains("Model") + assertThat(exifImage.modifyDate()).contains("ModifyDate") + assertThat(exifImage.orientation()).contains(0L) + assertThat(exifImage.resolutionUnit()).contains(0L) + assertThat(exifImage.software()).contains("Software") + assertThat(exifImage.xResolution()).contains(0L) + assertThat(exifImage.yCbCrPositioning()).contains(0L) + assertThat(exifImage.yResolution()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val exifImage = + ExifImage.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + + val roundtrippedExifImage = + jsonMapper.readValue( + jsonMapper.writeValueAsString(exifImage), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExifImage).isEqualTo(exifImage) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GpsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GpsTest.kt new file mode 100644 index 00000000..c26091c2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GpsTest.kt @@ -0,0 +1,30 @@ +// 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 GpsTest { + + @Test + fun create() { + val gps = Gps.builder().addGpsVersionId(0L).build() + + assertThat(gps.gpsVersionId().getOrNull()).containsExactly(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val gps = Gps.builder().addGpsVersionId(0L).build() + + val roundtrippedGps = + jsonMapper.readValue(jsonMapper.writeValueAsString(gps), jacksonTypeRef()) + + assertThat(roundtrippedGps).isEqualTo(gps) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/InteroperabilityTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/InteroperabilityTest.kt new file mode 100644 index 00000000..369c5673 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/InteroperabilityTest.kt @@ -0,0 +1,41 @@ +// 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 InteroperabilityTest { + + @Test + fun create() { + val interoperability = + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + + assertThat(interoperability.interopIndex()).contains("InteropIndex") + assertThat(interoperability.interopVersion()).contains("InteropVersion") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val interoperability = + Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + + val roundtrippedInteroperability = + jsonMapper.readValue( + jsonMapper.writeValueAsString(interoperability), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInteroperability).isEqualTo(interoperability) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ThumbnailTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ThumbnailTest.kt new file mode 100644 index 00000000..ee8a2afe --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ThumbnailTest.kt @@ -0,0 +1,53 @@ +// 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 ThumbnailTest { + + @Test + fun create() { + val thumbnail = + Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + + assertThat(thumbnail.compression()).contains(0L) + assertThat(thumbnail.resolutionUnit()).contains(0L) + assertThat(thumbnail.thumbnailLength()).contains(0L) + assertThat(thumbnail.thumbnailOffset()).contains(0L) + assertThat(thumbnail.xResolution()).contains(0L) + assertThat(thumbnail.yResolution()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val thumbnail = + Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + + val roundtrippedThumbnail = + jsonMapper.readValue( + jsonMapper.writeValueAsString(thumbnail), + jacksonTypeRef(), + ) + + assertThat(roundtrippedThumbnail).isEqualTo(thumbnail) + } +} 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 8fa7013f..100d499b 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.ExifDetails +import com.imagekit.api.models.ExifImage +import com.imagekit.api.models.Gps +import com.imagekit.api.models.Interoperability +import com.imagekit.api.models.Thumbnail import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -56,7 +61,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -85,13 +90,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -106,7 +107,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -117,7 +118,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -193,7 +194,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -222,13 +223,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -243,7 +240,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -254,7 +251,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -333,7 +330,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -362,13 +359,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -383,7 +376,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -394,7 +387,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) 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 fa9f7de7..ecc9a890 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.ExifDetails +import com.imagekit.api.models.ExifImage +import com.imagekit.api.models.Gps +import com.imagekit.api.models.Interoperability +import com.imagekit.api.models.Thumbnail import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -56,7 +61,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -85,13 +90,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -106,7 +107,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -117,7 +118,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -193,7 +194,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -222,13 +223,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -243,7 +240,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -254,7 +251,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -333,7 +330,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -362,13 +359,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -383,7 +376,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -394,7 +387,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt index f889b1e1..cd09a583 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.files.metadata import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.ExifDetails +import com.imagekit.api.models.ExifImage +import com.imagekit.api.models.Gps +import com.imagekit.api.models.Interoperability +import com.imagekit.api.models.Thumbnail import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -21,7 +26,7 @@ internal class MetadataGetFromUrlResponseTest { .exif( MetadataGetFromUrlResponse.Exif.builder() .exif( - MetadataGetFromUrlResponse.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -50,13 +55,9 @@ internal class MetadataGetFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps( - MetadataGetFromUrlResponse.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetFromUrlResponse.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -71,7 +72,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .interoperability( - MetadataGetFromUrlResponse.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -82,7 +83,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .thumbnail( - MetadataGetFromUrlResponse.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -112,7 +113,7 @@ internal class MetadataGetFromUrlResponseTest { .contains( MetadataGetFromUrlResponse.Exif.builder() .exif( - MetadataGetFromUrlResponse.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -141,9 +142,9 @@ internal class MetadataGetFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps(MetadataGetFromUrlResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetFromUrlResponse.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -158,7 +159,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .interoperability( - MetadataGetFromUrlResponse.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -169,7 +170,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .thumbnail( - MetadataGetFromUrlResponse.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -203,7 +204,7 @@ internal class MetadataGetFromUrlResponseTest { .exif( MetadataGetFromUrlResponse.Exif.builder() .exif( - MetadataGetFromUrlResponse.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -232,13 +233,9 @@ internal class MetadataGetFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps( - MetadataGetFromUrlResponse.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetFromUrlResponse.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -253,7 +250,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .interoperability( - MetadataGetFromUrlResponse.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -264,7 +261,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .thumbnail( - MetadataGetFromUrlResponse.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt index 28ff25c9..f4d37a81 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.files.metadata import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.ExifDetails +import com.imagekit.api.models.ExifImage +import com.imagekit.api.models.Gps +import com.imagekit.api.models.Interoperability +import com.imagekit.api.models.Thumbnail import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -21,7 +26,7 @@ internal class MetadataGetResponseTest { .exif( MetadataGetResponse.Exif.builder() .exif( - MetadataGetResponse.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -50,9 +55,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetResponse.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -67,7 +72,7 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - MetadataGetResponse.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -78,7 +83,7 @@ internal class MetadataGetResponseTest { .build() ) .thumbnail( - MetadataGetResponse.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -108,7 +113,7 @@ internal class MetadataGetResponseTest { .contains( MetadataGetResponse.Exif.builder() .exif( - MetadataGetResponse.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -137,9 +142,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetResponse.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -154,7 +159,7 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - MetadataGetResponse.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -165,7 +170,7 @@ internal class MetadataGetResponseTest { .build() ) .thumbnail( - MetadataGetResponse.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -199,7 +204,7 @@ internal class MetadataGetResponseTest { .exif( MetadataGetResponse.Exif.builder() .exif( - MetadataGetResponse.Exif.InnerExif.builder() + ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -228,9 +233,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) + .gps(Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetResponse.Exif.Image.builder() + ExifImage.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -245,7 +250,7 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - MetadataGetResponse.Exif.Interoperability.builder() + Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -256,7 +261,7 @@ internal class MetadataGetResponseTest { .build() ) .thumbnail( - MetadataGetResponse.Exif.Thumbnail.builder() + Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) From 2a98d7661a901bd01e6cbe191a55b07931a649e2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 17 Aug 2025 06:55:57 +0000 Subject: [PATCH 006/125] feat(api): manual updates --- .stats.yml | 6 +- .../api/models/AutoDescriptionExtension.kt | 296 ++++ .../api/models/AutoTaggingExtension.kt | 385 +++++ .../api/models/RemovedotBgExtension.kt | 612 +++++++ .../api/models/assets/AssetListResponse.kt | 145 +- .../models/beta/v2/files/FileUploadParams.kt | 1241 +------------- .../beta/v2/files/FileUploadResponse.kt | 141 +- .../api/models/files/FileGetResponse.kt | 140 +- .../api/models/files/FileUpdateParams.kt | 1511 ++--------------- .../api/models/files/FileUpdateResponse.kt | 140 +- .../api/models/files/FileUploadParams.kt | 1241 +------------- .../api/models/files/FileUploadResponse.kt | 141 +- .../files/versions/VersionGetResponse.kt | 140 +- .../files/versions/VersionListResponse.kt | 140 +- .../files/versions/VersionRestoreResponse.kt | 140 +- .../models/AutoDescriptionExtensionTest.kt | 39 + .../api/models/AutoTaggingExtensionTest.kt | 45 + .../api/models/RemovedotBgExtensionTest.kt | 63 + .../models/assets/AssetListResponseTest.kt | 12 +- .../beta/v2/files/FileUploadParamsTest.kt | 42 +- .../beta/v2/files/FileUploadResponseTest.kt | 20 +- .../api/models/files/FileGetResponseTest.kt | 20 +- .../api/models/files/FileUpdateParamsTest.kt | 171 +- .../models/files/FileUpdateResponseTest.kt | 20 +- .../api/models/files/FileUploadParamsTest.kt | 42 +- .../models/files/FileUploadResponseTest.kt | 20 +- .../files/versions/VersionGetResponseTest.kt | 20 +- .../files/versions/VersionListResponseTest.kt | 20 +- .../versions/VersionRestoreResponseTest.kt | 23 +- .../api/services/ErrorHandlingTest.kt | 274 +-- .../api/services/ServiceParamsTest.kt | 14 +- .../services/async/FileServiceAsyncTest.kt | 68 +- .../async/beta/v2/FileServiceAsyncTest.kt | 15 +- .../api/services/blocking/FileServiceTest.kt | 68 +- .../blocking/beta/v2/FileServiceTest.kt | 15 +- .../api/proguard/ProGuardCompatibilityTest.kt | 12 +- 36 files changed, 3043 insertions(+), 4399 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoDescriptionExtension.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoTaggingExtension.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/RemovedotBgExtension.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoDescriptionExtensionTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoTaggingExtensionTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/RemovedotBgExtensionTest.kt diff --git a/.stats.yml b/.stats.yml index d25e9ed9..456c477f 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-c01164d5dc8f8c9ab2b7c1a1c793ac522d565f96e569b0e56a4e9353e39bab85.yml -openapi_spec_hash: ac7b3a2b968fe86bf7bb81192209123f -config_hash: 963efe3c7e328464ca83ae352b29bbb4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-584c2ccf3fc1a3ff3abf26b8d3dace2398d0f9ed6f20e4c411a13a81febb5e98.yml +openapi_spec_hash: 14d1614ea3903d6b53f26e135c9cae81 +config_hash: 7e5c039f375ccdba7cf3e61492a273f2 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoDescriptionExtension.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoDescriptionExtension.kt new file mode 100644 index 00000000..c301c765 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoDescriptionExtension.kt @@ -0,0 +1,296 @@ +// 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.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AutoDescriptionExtension +private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * Specifies the auto description 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(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value 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 [AutoDescriptionExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoDescriptionExtension]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { + name = autoDescriptionExtension.name + additionalProperties = autoDescriptionExtension.additionalProperties.toMutableMap() + } + + /** Specifies the auto description extension. */ + 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 [AutoDescriptionExtension]. + * + * 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(): AutoDescriptionExtension = + AutoDescriptionExtension( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoDescriptionExtension = apply { + if (validated) { + return@apply + } + + 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 = (name.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the auto description extension. */ + 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + AI_AUTO_DESCRIPTION + } + + /** + * 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 { + AI_AUTO_DESCRIPTION, + /** 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) { + AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION + 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 AutoDescriptionExtension && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoDescriptionExtension{name=$name, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoTaggingExtension.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoTaggingExtension.kt new file mode 100644 index 00000000..00cdf71d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoTaggingExtension.kt @@ -0,0 +1,385 @@ +// 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.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +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}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/RemovedotBgExtension.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/RemovedotBgExtension.kt new file mode 100644 index 00000000..1820eff7 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/RemovedotBgExtension.kt @@ -0,0 +1,612 @@ +// 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.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RemovedotBgExtension +private constructor( + private val name: JsonField, + private val options: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + + /** + * Specifies the background removal 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(): Name = name.getRequired("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 [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 [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 [RemovedotBgExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovedotBgExtension]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { + name = removedotBgExtension.name + options = removedotBgExtension.options + additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() + } + + /** Specifies the background removal extension. */ + 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 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 [RemovedotBgExtension]. + * + * 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(): RemovedotBgExtension = + RemovedotBgExtension( + checkRequired("name", name), + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovedotBgExtension = apply { + if (validated) { + return@apply + } + + name().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 = + (name.asKnown().getOrNull()?.validity() ?: 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the background removal extension. */ + 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 REMOVE_BG = of("remove-bg") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + REMOVE_BG + } + + /** + * 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 { + REMOVE_BG, + /** 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) { + REMOVE_BG -> Value.REMOVE_BG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + REMOVE_BG -> Known.REMOVE_BG + 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() + } + + 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 RemovedotBgExtension && + 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() = + "RemovedotBgExtension{name=$name, options=$options, additionalProperties=$additionalProperties}" +} 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 index 266e31e8..64fb5acf 100644 --- 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 @@ -218,7 +218,7 @@ private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -252,7 +252,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing @@ -336,10 +336,14 @@ private constructor( fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") - /** An object with custom metadata for the file. */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + /** + * 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") /** * Unique identifier of the asset. @@ -505,6 +509,16 @@ private constructor( @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 [fileId]. * @@ -655,7 +669,7 @@ private constructor( private var aiTags: JsonField>? = null private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -764,7 +778,17 @@ private constructor( } /** An object with custom metadata for the file. */ - fun customMetadata(customMetadata: JsonValue) = apply { + 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 } @@ -1067,6 +1091,7 @@ private constructor( aiTags().ifPresent { it.forEach { it.validate() } } createdAt() customCoordinates() + customMetadata().ifPresent { it.validate() } fileId() filePath() fileType() @@ -1106,6 +1131,7 @@ private constructor( (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 (fileId.asKnown().isPresent) 1 else 0) + (if (filePath.asKnown().isPresent) 1 else 0) + (if (fileType.asKnown().isPresent) 1 else 0) + @@ -1350,6 +1376,109 @@ private constructor( "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}" + } + /** An object with details of the file version. */ class VersionInfo private constructor( 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 06713175..3271d1a7 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,6 +29,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 com.imagekit.api.models.AutoDescriptionExtension +import com.imagekit.api.models.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -658,17 +661,17 @@ private constructor( fun addExtension(extension: Extension) = apply { body.addExtension(extension) } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = apply { + fun addExtension(removedotBg: RemovedotBgExtension) = apply { body.addExtension(removedotBg) } /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { + fun addExtension(autoTagging: AutoTaggingExtension) = apply { body.addExtension(autoTagging) } /** Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = apply { + fun addExtension(autoDescription: AutoDescriptionExtension) = apply { body.addExtension(autoDescription) } @@ -1772,17 +1775,17 @@ private constructor( } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = + fun addExtension(removedotBg: RemovedotBgExtension) = addExtension(Extension.ofRemovedotBg(removedotBg)) /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + fun addExtension(autoTagging: AutoTaggingExtension) = addExtension(Extension.ofAutoTagging(autoTagging)) /** * Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = + fun addExtension(autoDescription: AutoDescriptionExtension) = addExtension(Extension.ofAutoDescription(autoDescription)) /** @@ -2497,1232 +2500,6 @@ private constructor( } } } - - class RemovedotBgExtension - private constructor( - private val name: MultipartField, - private val options: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the background removal 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(): Name = name.value.getRequired("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 [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name - - /** - * 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 [RemovedotBgExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemovedotBgExtension]. */ - class Builder internal constructor() { - - private var name: MultipartField? = null - private var options: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { - name = removedotBgExtension.name - options = removedotBgExtension.options - additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() - } - - /** Specifies the background removal extension. */ - 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 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 [RemovedotBgExtension]. - * - * 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(): RemovedotBgExtension = - RemovedotBgExtension( - checkRequired("name", name), - options, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): RemovedotBgExtension = apply { - if (validated) { - return@apply - } - - name().validate() - options().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the background removal extension. */ - 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 REMOVE_BG = of("remove-bg") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - REMOVE_BG - } - - /** - * 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 { - REMOVE_BG, - /** - * 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) { - REMOVE_BG -> Value.REMOVE_BG - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - REMOVE_BG -> Known.REMOVE_BG - 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() - } - - 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 RemovedotBgExtension && - 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() = - "RemovedotBgExtension{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 AutoDescriptionExtension - private constructor( - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the auto description 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(): Name = name.value.getRequired("name") - - /** - * 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 - * [AutoDescriptionExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoDescriptionExtension]. */ - class Builder internal constructor() { - - private var name: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { - name = autoDescriptionExtension.name - additionalProperties = - autoDescriptionExtension.additionalProperties.toMutableMap() - } - - /** Specifies the auto description extension. */ - 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 [AutoDescriptionExtension]. - * - * 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(): AutoDescriptionExtension = - AutoDescriptionExtension( - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoDescriptionExtension = apply { - if (validated) { - return@apply - } - - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the auto description extension. */ - 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - AI_AUTO_DESCRIPTION - } - - /** - * 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 { - AI_AUTO_DESCRIPTION, - /** - * 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) { - AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION - 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 AutoDescriptionExtension && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoDescriptionExtension{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/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index 2af5e4bf..67a5e524 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 @@ -31,7 +31,7 @@ private constructor( private val audioCodec: JsonField, private val bitRate: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val duration: JsonField, private val embeddedMetadata: JsonField, private val extensionStatus: JsonField, @@ -65,7 +65,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("embeddedMetadata") @ExcludeMissing @@ -164,10 +164,11 @@ private constructor( * `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). */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + fun customMetadata(): Optional = customMetadata.getOptional("customMetadata") /** * The duration of the video in seconds (only for video). @@ -360,6 +361,15 @@ private constructor( @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 [duration]. * @@ -524,7 +534,7 @@ private constructor( private var audioCodec: JsonField = JsonMissing.of() private var bitRate: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var embeddedMetadata: JsonField = JsonMissing.of() private var extensionStatus: JsonField = JsonMissing.of() @@ -654,7 +664,17 @@ private constructor( * 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: JsonValue) = apply { + 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 } @@ -987,6 +1007,7 @@ private constructor( audioCodec() bitRate() customCoordinates() + customMetadata().ifPresent { it.validate() } duration() embeddedMetadata().ifPresent { it.validate() } extensionStatus().ifPresent { it.validate() } @@ -1027,6 +1048,7 @@ private constructor( (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 (duration.asKnown().isPresent) 1 else 0) + (embeddedMetadata.asKnown().getOrNull()?.validity() ?: 0) + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) + @@ -1268,6 +1290,111 @@ 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. + */ + 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt index 7fac5db3..55ef2d30 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt @@ -24,7 +24,7 @@ private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -54,7 +54,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), @@ -127,10 +127,13 @@ private constructor( */ fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") - /** An object with custom metadata for the file. */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + /** + * 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") /** * Unique identifier of the asset. @@ -295,6 +298,15 @@ private constructor( @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 [fileId]. * @@ -444,7 +456,7 @@ private constructor( private var aiTags: JsonField>? = null private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -551,7 +563,17 @@ private constructor( } /** An object with custom metadata for the file. */ - fun customMetadata(customMetadata: JsonValue) = apply { + 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 } @@ -838,6 +860,7 @@ private constructor( aiTags().ifPresent { it.forEach { it.validate() } } createdAt() customCoordinates() + customMetadata().ifPresent { it.validate() } fileId() filePath() fileType() @@ -876,6 +899,7 @@ private constructor( (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 (fileId.asKnown().isPresent) 1 else 0) + (if (filePath.asKnown().isPresent) 1 else 0) + (if (fileType.asKnown().isPresent) 1 else 0) + @@ -1113,6 +1137,106 @@ private constructor( "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}" + } + /** An object with details of the file version. */ class VersionInfo private constructor( 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 3e40a9a8..4326889d 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,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 com.imagekit.api.models.AutoDescriptionExtension +import com.imagekit.api.models.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import java.util.Collections import java.util.Objects import java.util.Optional @@ -413,7 +416,7 @@ private constructor( class UpdateFileDetails private constructor( private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val description: JsonField, private val extensions: JsonField>, private val removeAiTags: JsonField, @@ -429,7 +432,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), @@ -470,10 +473,12 @@ private constructor( * 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). */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + fun customMetadata(): Optional = + customMetadata.getOptional("customMetadata") /** * Optional text to describe the contents of the file. @@ -536,6 +541,16 @@ private constructor( @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]. * @@ -607,7 +622,7 @@ private constructor( class Builder internal constructor() { private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = 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() @@ -657,7 +672,17 @@ private constructor( * 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: JsonValue) = apply { + 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 } @@ -705,18 +730,18 @@ private constructor( } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = + fun addExtension(removedotBg: RemovedotBgExtension) = addExtension(Extension.ofRemovedotBg(removedotBg)) /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + fun addExtension(autoTagging: AutoTaggingExtension) = addExtension(Extension.ofAutoTagging(autoTagging)) /** * Alias for calling [addExtension] with * `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = + fun addExtension(autoDescription: AutoDescriptionExtension) = addExtension(Extension.ofAutoDescription(autoDescription)) /** @@ -852,6 +877,7 @@ private constructor( } customCoordinates() + customMetadata().ifPresent { it.validate() } description() extensions().ifPresent { it.forEach { it.validate() } } removeAiTags().ifPresent { it.validate() } @@ -877,12 +903,126 @@ private constructor( @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 @@ -1095,1357 +1235,6 @@ private constructor( } } } - - class RemovedotBgExtension - private constructor( - private val name: JsonField, - private val options: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - options: JsonField = JsonMissing.of(), - ) : this(name, options, mutableMapOf()) - - /** - * Specifies the background removal 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(): Name = name.getRequired("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 [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 [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 - * [RemovedotBgExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemovedotBgExtension]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var options: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { - name = removedotBgExtension.name - options = removedotBgExtension.options - additionalProperties = - removedotBgExtension.additionalProperties.toMutableMap() - } - - /** Specifies the background removal extension. */ - 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 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 [RemovedotBgExtension]. - * - * 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(): RemovedotBgExtension = - RemovedotBgExtension( - checkRequired("name", name), - options, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): RemovedotBgExtension = apply { - if (validated) { - return@apply - } - - name().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 = - (name.asKnown().getOrNull()?.validity() ?: 0) + - (options.asKnown().getOrNull()?.validity() ?: 0) - - /** Specifies the background removal extension. */ - 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 REMOVE_BG = of("remove-bg") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - REMOVE_BG - } - - /** - * 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 { - REMOVE_BG, - /** - * 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) { - REMOVE_BG -> Value.REMOVE_BG - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - REMOVE_BG -> Known.REMOVE_BG - 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() - } - - 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 RemovedotBgExtension && - 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() = - "RemovedotBgExtension{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}" - } - - class AutoDescriptionExtension - private constructor( - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of() - ) : this(name, mutableMapOf()) - - /** - * Specifies the auto description 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(): Name = name.getRequired("name") - - /** - * Returns the raw JSON value 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 - * [AutoDescriptionExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoDescriptionExtension]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = - apply { - name = autoDescriptionExtension.name - additionalProperties = - autoDescriptionExtension.additionalProperties.toMutableMap() - } - - /** Specifies the auto description extension. */ - 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 [AutoDescriptionExtension]. - * - * 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(): AutoDescriptionExtension = - AutoDescriptionExtension( - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoDescriptionExtension = apply { - if (validated) { - return@apply - } - - 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 = (name.asKnown().getOrNull()?.validity() ?: 0) - - /** Specifies the auto description extension. */ - 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - AI_AUTO_DESCRIPTION - } - - /** - * 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 { - AI_AUTO_DESCRIPTION, - /** - * 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) { - AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION - 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 AutoDescriptionExtension && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoDescriptionExtension{name=$name, 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 8b730e52..cbe3e5df 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 @@ -24,7 +24,7 @@ private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val extensionStatus: JsonField, private val fileId: JsonField, private val filePath: JsonField, @@ -55,7 +55,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("extensionStatus") @ExcludeMissing extensionStatus: JsonField = JsonMissing.of(), @@ -132,10 +132,13 @@ private constructor( */ fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") - /** An object with custom metadata for the file. */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -307,6 +310,15 @@ private constructor( @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 [extensionStatus]. * @@ -465,7 +477,7 @@ private constructor( private var aiTags: JsonField>? = null private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var extensionStatus: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() @@ -574,7 +586,17 @@ private constructor( } /** An object with custom metadata for the file. */ - fun customMetadata(customMetadata: JsonValue) = apply { + 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 } @@ -876,6 +898,7 @@ private constructor( aiTags().ifPresent { it.forEach { it.validate() } } createdAt() customCoordinates() + customMetadata().ifPresent { it.validate() } extensionStatus().ifPresent { it.validate() } fileId() filePath() @@ -915,6 +938,7 @@ private constructor( (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) + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) + (if (fileId.asKnown().isPresent) 1 else 0) + (if (filePath.asKnown().isPresent) 1 else 0) + @@ -1153,6 +1177,106 @@ private constructor( "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}" + } + class ExtensionStatus private constructor( private val aiAutoDescription: JsonField, 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 2227724a..548fce67 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,6 +29,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 com.imagekit.api.models.AutoDescriptionExtension +import com.imagekit.api.models.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -738,17 +741,17 @@ private constructor( fun addExtension(extension: Extension) = apply { body.addExtension(extension) } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = apply { + fun addExtension(removedotBg: RemovedotBgExtension) = apply { body.addExtension(removedotBg) } /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { + fun addExtension(autoTagging: AutoTaggingExtension) = apply { body.addExtension(autoTagging) } /** Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = apply { + fun addExtension(autoDescription: AutoDescriptionExtension) = apply { body.addExtension(autoDescription) } @@ -1987,17 +1990,17 @@ private constructor( } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = + fun addExtension(removedotBg: RemovedotBgExtension) = addExtension(Extension.ofRemovedotBg(removedotBg)) /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + fun addExtension(autoTagging: AutoTaggingExtension) = addExtension(Extension.ofAutoTagging(autoTagging)) /** * Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = + fun addExtension(autoDescription: AutoDescriptionExtension) = addExtension(Extension.ofAutoDescription(autoDescription)) /** @@ -2763,1232 +2766,6 @@ private constructor( } } } - - class RemovedotBgExtension - private constructor( - private val name: MultipartField, - private val options: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the background removal 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(): Name = name.value.getRequired("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 [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name - - /** - * 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 [RemovedotBgExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemovedotBgExtension]. */ - class Builder internal constructor() { - - private var name: MultipartField? = null - private var options: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { - name = removedotBgExtension.name - options = removedotBgExtension.options - additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() - } - - /** Specifies the background removal extension. */ - 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 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 [RemovedotBgExtension]. - * - * 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(): RemovedotBgExtension = - RemovedotBgExtension( - checkRequired("name", name), - options, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): RemovedotBgExtension = apply { - if (validated) { - return@apply - } - - name().validate() - options().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the background removal extension. */ - 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 REMOVE_BG = of("remove-bg") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - REMOVE_BG - } - - /** - * 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 { - REMOVE_BG, - /** - * 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) { - REMOVE_BG -> Value.REMOVE_BG - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - REMOVE_BG -> Known.REMOVE_BG - 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() - } - - 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 RemovedotBgExtension && - 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() = - "RemovedotBgExtension{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 AutoDescriptionExtension - private constructor( - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the auto description 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(): Name = name.value.getRequired("name") - - /** - * 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 - * [AutoDescriptionExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoDescriptionExtension]. */ - class Builder internal constructor() { - - private var name: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { - name = autoDescriptionExtension.name - additionalProperties = - autoDescriptionExtension.additionalProperties.toMutableMap() - } - - /** Specifies the auto description extension. */ - 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 [AutoDescriptionExtension]. - * - * 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(): AutoDescriptionExtension = - AutoDescriptionExtension( - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoDescriptionExtension = apply { - if (validated) { - return@apply - } - - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the auto description extension. */ - 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - AI_AUTO_DESCRIPTION - } - - /** - * 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 { - AI_AUTO_DESCRIPTION, - /** - * 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) { - AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION - 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 AutoDescriptionExtension && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoDescriptionExtension{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/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index 77267f46..f39e6fec 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 @@ -31,7 +31,7 @@ private constructor( private val audioCodec: JsonField, private val bitRate: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val duration: JsonField, private val embeddedMetadata: JsonField, private val extensionStatus: JsonField, @@ -65,7 +65,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("embeddedMetadata") @ExcludeMissing @@ -164,10 +164,11 @@ private constructor( * `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). */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + fun customMetadata(): Optional = customMetadata.getOptional("customMetadata") /** * The duration of the video in seconds (only for video). @@ -360,6 +361,15 @@ private constructor( @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 [duration]. * @@ -524,7 +534,7 @@ private constructor( private var audioCodec: JsonField = JsonMissing.of() private var bitRate: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var embeddedMetadata: JsonField = JsonMissing.of() private var extensionStatus: JsonField = JsonMissing.of() @@ -654,7 +664,17 @@ private constructor( * 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: JsonValue) = apply { + 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 } @@ -987,6 +1007,7 @@ private constructor( audioCodec() bitRate() customCoordinates() + customMetadata().ifPresent { it.validate() } duration() embeddedMetadata().ifPresent { it.validate() } extensionStatus().ifPresent { it.validate() } @@ -1027,6 +1048,7 @@ private constructor( (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 (duration.asKnown().isPresent) 1 else 0) + (embeddedMetadata.asKnown().getOrNull()?.validity() ?: 0) + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) + @@ -1268,6 +1290,111 @@ 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. + */ + 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt index 83ea86e0..324fdcc4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt @@ -24,7 +24,7 @@ private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -54,7 +54,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), @@ -127,10 +127,13 @@ private constructor( */ fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") - /** An object with custom metadata for the file. */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + /** + * 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") /** * Unique identifier of the asset. @@ -295,6 +298,15 @@ private constructor( @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 [fileId]. * @@ -444,7 +456,7 @@ private constructor( private var aiTags: JsonField>? = null private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -551,7 +563,17 @@ private constructor( } /** An object with custom metadata for the file. */ - fun customMetadata(customMetadata: JsonValue) = apply { + 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 } @@ -838,6 +860,7 @@ private constructor( aiTags().ifPresent { it.forEach { it.validate() } } createdAt() customCoordinates() + customMetadata().ifPresent { it.validate() } fileId() filePath() fileType() @@ -876,6 +899,7 @@ private constructor( (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 (fileId.asKnown().isPresent) 1 else 0) + (if (filePath.asKnown().isPresent) 1 else 0) + (if (fileType.asKnown().isPresent) 1 else 0) + @@ -1113,6 +1137,106 @@ private constructor( "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}" + } + /** An object with details of the file version. */ class VersionInfo private constructor( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt index 9b231d38..843cb6e7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt @@ -24,7 +24,7 @@ private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -54,7 +54,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), @@ -127,10 +127,13 @@ private constructor( */ fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") - /** An object with custom metadata for the file. */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + /** + * 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") /** * Unique identifier of the asset. @@ -295,6 +298,15 @@ private constructor( @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 [fileId]. * @@ -444,7 +456,7 @@ private constructor( private var aiTags: JsonField>? = null private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -551,7 +563,17 @@ private constructor( } /** An object with custom metadata for the file. */ - fun customMetadata(customMetadata: JsonValue) = apply { + 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 } @@ -838,6 +860,7 @@ private constructor( aiTags().ifPresent { it.forEach { it.validate() } } createdAt() customCoordinates() + customMetadata().ifPresent { it.validate() } fileId() filePath() fileType() @@ -876,6 +899,7 @@ private constructor( (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 (fileId.asKnown().isPresent) 1 else 0) + (if (filePath.asKnown().isPresent) 1 else 0) + (if (fileType.asKnown().isPresent) 1 else 0) + @@ -1113,6 +1137,106 @@ private constructor( "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}" + } + /** An object with details of the file version. */ class VersionInfo private constructor( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt index 56355d25..0b67d818 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt @@ -24,7 +24,7 @@ private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonValue, + private val customMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -54,7 +54,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonValue = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), @@ -127,10 +127,13 @@ private constructor( */ fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") - /** An object with custom metadata for the file. */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonValue = customMetadata + /** + * 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") /** * Unique identifier of the asset. @@ -295,6 +298,15 @@ private constructor( @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 [fileId]. * @@ -444,7 +456,7 @@ private constructor( private var aiTags: JsonField>? = null private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonValue = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -551,7 +563,17 @@ private constructor( } /** An object with custom metadata for the file. */ - fun customMetadata(customMetadata: JsonValue) = apply { + 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 } @@ -838,6 +860,7 @@ private constructor( aiTags().ifPresent { it.forEach { it.validate() } } createdAt() customCoordinates() + customMetadata().ifPresent { it.validate() } fileId() filePath() fileType() @@ -876,6 +899,7 @@ private constructor( (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 (fileId.asKnown().isPresent) 1 else 0) + (if (filePath.asKnown().isPresent) 1 else 0) + (if (fileType.asKnown().isPresent) 1 else 0) + @@ -1113,6 +1137,106 @@ private constructor( "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}" + } + /** An object with details of the file version. */ class VersionInfo private constructor( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoDescriptionExtensionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoDescriptionExtensionTest.kt new file mode 100644 index 00000000..2d9a9c6b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoDescriptionExtensionTest.kt @@ -0,0 +1,39 @@ +// 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 AutoDescriptionExtensionTest { + + @Test + fun create() { + val autoDescriptionExtension = + AutoDescriptionExtension.builder() + .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) + .build() + + assertThat(autoDescriptionExtension.name()) + .isEqualTo(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val autoDescriptionExtension = + AutoDescriptionExtension.builder() + .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) + .build() + + val roundtrippedAutoDescriptionExtension = + jsonMapper.readValue( + jsonMapper.writeValueAsString(autoDescriptionExtension), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAutoDescriptionExtension).isEqualTo(autoDescriptionExtension) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoTaggingExtensionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoTaggingExtensionTest.kt new file mode 100644 index 00000000..35db3ae6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoTaggingExtensionTest.kt @@ -0,0 +1,45 @@ +// 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 AutoTaggingExtensionTest { + + @Test + fun create() { + val autoTaggingExtension = + AutoTaggingExtension.builder() + .maxTags(0L) + .minConfidence(0L) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .build() + + assertThat(autoTaggingExtension.maxTags()).isEqualTo(0L) + assertThat(autoTaggingExtension.minConfidence()).isEqualTo(0L) + assertThat(autoTaggingExtension.name()) + .isEqualTo(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val autoTaggingExtension = + AutoTaggingExtension.builder() + .maxTags(0L) + .minConfidence(0L) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .build() + + val roundtrippedAutoTaggingExtension = + jsonMapper.readValue( + jsonMapper.writeValueAsString(autoTaggingExtension), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAutoTaggingExtension).isEqualTo(autoTaggingExtension) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/RemovedotBgExtensionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/RemovedotBgExtensionTest.kt new file mode 100644 index 00000000..6f2e6cfa --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/RemovedotBgExtensionTest.kt @@ -0,0 +1,63 @@ +// 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 RemovedotBgExtensionTest { + + @Test + fun create() { + val removedotBgExtension = + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) + .options( + RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + + assertThat(removedotBgExtension.name()).isEqualTo(RemovedotBgExtension.Name.REMOVE_BG) + assertThat(removedotBgExtension.options()) + .contains( + RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val removedotBgExtension = + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) + .options( + RemovedotBgExtension.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + + val roundtrippedRemovedotBgExtension = + jsonMapper.readValue( + jsonMapper.writeValueAsString(removedotBgExtension), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRemovedotBgExtension).isEqualTo(removedotBgExtension) + } +} 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 b54b0df8..19ffd071 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 @@ -27,7 +27,11 @@ internal class AssetListResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + AssetListResponse.FileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -73,7 +77,11 @@ internal class AssetListResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + AssetListResponse.FileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") 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 f34d18bc..dd31a8ad 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,8 @@ 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.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -26,10 +28,10 @@ internal class FileUploadParamsTest { ) .description("Running shoes") .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -39,10 +41,10 @@ internal class FileUploadParamsTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -110,10 +112,10 @@ internal class FileUploadParamsTest { ) .description("Running shoes") .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -123,12 +125,10 @@ internal class FileUploadParamsTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -208,15 +208,10 @@ internal class FileUploadParamsTest { MultipartField.of( listOf( FileUploadParams.Extension.ofRemovedotBg( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name - .REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension - .Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -226,13 +221,10 @@ internal class FileUploadParamsTest { .build() ), FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), ) 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 100d499b..6462d1a1 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 @@ -30,7 +30,11 @@ internal class FileUploadResponseTest { .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .duration(0L) .embeddedMetadata( FileUploadResponse.EmbeddedMetadata.builder() @@ -161,8 +165,12 @@ internal class FileUploadResponseTest { assertThat(fileUploadResponse.audioCodec()).contains("audioCodec") assertThat(fileUploadResponse.bitRate()).contains(0L) assertThat(fileUploadResponse.customCoordinates()).contains("customCoordinates") - assertThat(fileUploadResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(fileUploadResponse.customMetadata()) + .contains( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(fileUploadResponse.duration()).contains(0L) assertThat(fileUploadResponse.embeddedMetadata()) .contains( @@ -299,7 +307,11 @@ internal class FileUploadResponseTest { .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .duration(0L) .embeddedMetadata( FileUploadResponse.EmbeddedMetadata.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt index 956cdfb6..8376130c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt @@ -24,7 +24,11 @@ internal class FileGetResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileGetResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -54,8 +58,12 @@ internal class FileGetResponseTest { ) assertThat(fileGetResponse.createdAt()).contains("createdAt") assertThat(fileGetResponse.customCoordinates()).contains("customCoordinates") - assertThat(fileGetResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(fileGetResponse.customMetadata()) + .contains( + FileGetResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(fileGetResponse.fileId()).contains("fileId") assertThat(fileGetResponse.filePath()).contains("filePath") assertThat(fileGetResponse.fileType()).contains("fileType") @@ -90,7 +98,11 @@ internal class FileGetResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileGetResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") 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 34db684e..ea0e2fcd 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,9 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.AutoDescriptionExtension +import com.imagekit.api.models.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -16,25 +19,20 @@ internal class FileUpdateParamsTest { .body( FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") - .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .customMetadata( + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) .description("description") .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -44,43 +42,22 @@ internal class FileUpdateParamsTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) + AutoDescriptionExtension.builder() + .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) .build() ), ) @@ -111,25 +88,20 @@ internal class FileUpdateParamsTest { .body( FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") - .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .customMetadata( + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) .description("description") .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -139,43 +111,22 @@ internal class FileUpdateParamsTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) + AutoDescriptionExtension.builder() + .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) .build() ), ) @@ -195,25 +146,20 @@ internal class FileUpdateParamsTest { FileUpdateParams.Body.ofUpdateFileDetails( FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") - .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .customMetadata( + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) .description("description") .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -223,43 +169,22 @@ internal class FileUpdateParamsTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) + AutoDescriptionExtension.builder() + .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) .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 0ffc1b09..2c53ad8d 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 @@ -24,7 +24,11 @@ internal class FileUpdateResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileUpdateResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .extensionStatus( FileUpdateResponse.ExtensionStatus.builder() .aiAutoDescription( @@ -66,8 +70,12 @@ internal class FileUpdateResponseTest { ) assertThat(fileUpdateResponse.createdAt()).contains("createdAt") assertThat(fileUpdateResponse.customCoordinates()).contains("customCoordinates") - assertThat(fileUpdateResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(fileUpdateResponse.customMetadata()) + .contains( + FileUpdateResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(fileUpdateResponse.extensionStatus()) .contains( FileUpdateResponse.ExtensionStatus.builder() @@ -111,7 +119,11 @@ internal class FileUpdateResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileUpdateResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .extensionStatus( FileUpdateResponse.ExtensionStatus.builder() .aiAutoDescription( 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 212f5dfc..035c3a7e 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,8 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField +import com.imagekit.api.models.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -27,10 +29,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -40,10 +42,10 @@ internal class FileUploadParamsTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -114,10 +116,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -127,12 +129,10 @@ internal class FileUploadParamsTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -215,15 +215,10 @@ internal class FileUploadParamsTest { MultipartField.of( listOf( FileUploadParams.Extension.ofRemovedotBg( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name - .REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension - .Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -233,13 +228,10 @@ internal class FileUploadParamsTest { .build() ), FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), ) 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 ecc9a890..f387763f 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 @@ -30,7 +30,11 @@ internal class FileUploadResponseTest { .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .duration(0L) .embeddedMetadata( FileUploadResponse.EmbeddedMetadata.builder() @@ -161,8 +165,12 @@ internal class FileUploadResponseTest { assertThat(fileUploadResponse.audioCodec()).contains("audioCodec") assertThat(fileUploadResponse.bitRate()).contains(0L) assertThat(fileUploadResponse.customCoordinates()).contains("customCoordinates") - assertThat(fileUploadResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(fileUploadResponse.customMetadata()) + .contains( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(fileUploadResponse.duration()).contains(0L) assertThat(fileUploadResponse.embeddedMetadata()) .contains( @@ -299,7 +307,11 @@ internal class FileUploadResponseTest { .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .duration(0L) .embeddedMetadata( FileUploadResponse.EmbeddedMetadata.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt index 23b54495..edb57d5d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt @@ -24,7 +24,11 @@ internal class VersionGetResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + VersionGetResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -54,8 +58,12 @@ internal class VersionGetResponseTest { ) assertThat(versionGetResponse.createdAt()).contains("createdAt") assertThat(versionGetResponse.customCoordinates()).contains("customCoordinates") - assertThat(versionGetResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(versionGetResponse.customMetadata()) + .contains( + VersionGetResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(versionGetResponse.fileId()).contains("fileId") assertThat(versionGetResponse.filePath()).contains("filePath") assertThat(versionGetResponse.fileType()).contains("fileType") @@ -90,7 +98,11 @@ internal class VersionGetResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + VersionGetResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt index fcbaa63f..5391afdb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt @@ -24,7 +24,11 @@ internal class VersionListResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + VersionListResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -56,8 +60,12 @@ internal class VersionListResponseTest { ) assertThat(versionListResponse.createdAt()).contains("createdAt") assertThat(versionListResponse.customCoordinates()).contains("customCoordinates") - assertThat(versionListResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(versionListResponse.customMetadata()) + .contains( + VersionListResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(versionListResponse.fileId()).contains("fileId") assertThat(versionListResponse.filePath()).contains("filePath") assertThat(versionListResponse.fileType()).contains("fileType") @@ -92,7 +100,11 @@ internal class VersionListResponseTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + VersionListResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt index 2d330753..69214d98 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt @@ -31,7 +31,12 @@ internal class VersionRestoreResponseTest { ) .createdAt("2019-08-24T06:14:41.313Z") .customCoordinates(null) - .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .customMetadata( + VersionRestoreResponse.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) .fileId("598821f949c0a938d57563bd") .filePath("/images/products/file.jpg") .fileType("image") @@ -75,8 +80,13 @@ internal class VersionRestoreResponseTest { ) assertThat(versionRestoreResponse.createdAt()).contains("2019-08-24T06:14:41.313Z") assertThat(versionRestoreResponse.customCoordinates()).isEmpty - assertThat(versionRestoreResponse._customMetadata()) - .isEqualTo(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + assertThat(versionRestoreResponse.customMetadata()) + .contains( + VersionRestoreResponse.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) assertThat(versionRestoreResponse.fileId()).contains("598821f949c0a938d57563bd") assertThat(versionRestoreResponse.filePath()).contains("/images/products/file.jpg") assertThat(versionRestoreResponse.fileType()).contains("image") @@ -130,7 +140,12 @@ internal class VersionRestoreResponseTest { ) .createdAt("2019-08-24T06:14:41.313Z") .customCoordinates(null) - .customMetadata(JsonValue.from(mapOf("brand" to "Nike", "color" to "red"))) + .customMetadata( + VersionRestoreResponse.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) .fileId("598821f949c0a938d57563bd") .filePath("/images/products/file.jpg") .fileType("image") 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 638f2e35..fb415d48 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,8 @@ 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.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry @@ -87,13 +89,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -103,13 +102,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -202,13 +198,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -218,13 +211,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -317,13 +307,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -333,13 +320,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -432,13 +416,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -448,13 +429,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -547,13 +525,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -563,13 +538,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -662,13 +634,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -678,13 +647,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -777,13 +743,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -793,13 +756,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -892,13 +852,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -908,13 +865,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1007,13 +961,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1023,13 +974,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1122,13 +1070,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1138,13 +1083,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1237,13 +1179,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1253,13 +1192,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1352,13 +1288,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1368,13 +1301,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1467,13 +1397,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1483,13 +1410,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1582,13 +1506,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1598,13 +1519,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1697,13 +1615,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1713,13 +1628,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1812,13 +1724,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1828,13 +1737,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -1925,13 +1831,10 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1941,13 +1844,10 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .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 4a8e74c3..5379b6f9 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,8 @@ 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.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled @@ -59,10 +61,10 @@ internal class ServiceParamsTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -72,12 +74,10 @@ internal class ServiceParamsTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .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 b1757d6c..bba8af8f 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,9 @@ 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.AutoDescriptionExtension +import com.imagekit.api.models.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -36,26 +39,19 @@ internal class FileServiceAsyncTest { FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - JsonValue.from(mapOf("brand" to "Nike", "color" to "red")) + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) .description("description") .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -65,43 +61,24 @@ internal class FileServiceAsyncTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension .ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() + AutoDescriptionExtension.builder() .name( - FileUpdateParams.Body.UpdateFileDetails - .Extension - .AutoDescriptionExtension - .Name + AutoDescriptionExtension.Name .AI_AUTO_DESCRIPTION ) .build() @@ -253,10 +230,10 @@ internal class FileServiceAsyncTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -266,13 +243,10 @@ internal class FileServiceAsyncTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .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 73140c41..25e01ec5 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,8 @@ 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.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -40,10 +42,10 @@ internal class FileServiceAsyncTest { ) .description("Running shoes") .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -53,13 +55,10 @@ internal class FileServiceAsyncTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .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 5c10683f..b2a540ce 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,9 @@ 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.AutoDescriptionExtension +import com.imagekit.api.models.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -36,26 +39,19 @@ internal class FileServiceTest { FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - JsonValue.from(mapOf("brand" to "Nike", "color" to "red")) + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() ) .description("description") .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Options - .builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -65,43 +61,24 @@ internal class FileServiceTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension .ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() + AutoDescriptionExtension.builder() .name( - FileUpdateParams.Body.UpdateFileDetails - .Extension - .AutoDescriptionExtension - .Name + AutoDescriptionExtension.Name .AI_AUTO_DESCRIPTION ) .build() @@ -246,10 +223,10 @@ internal class FileServiceTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -259,13 +236,10 @@ internal class FileServiceTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .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 ea4d43ff..f738079e 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,8 @@ 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.AutoTaggingExtension +import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -40,10 +42,10 @@ internal class FileServiceTest { ) .description("Running shoes") .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + RemovedotBgExtension.builder() + .name(RemovedotBgExtension.Name.REMOVE_BG) .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -53,13 +55,10 @@ internal class FileServiceTest { .build() ) .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() + AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .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 b09243de..c463aee3 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 @@ -76,7 +76,11 @@ internal class ProGuardCompatibilityTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + FileUpdateResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .extensionStatus( FileUpdateResponse.ExtensionStatus.builder() .aiAutoDescription( @@ -132,7 +136,11 @@ internal class ProGuardCompatibilityTest { ) .createdAt("createdAt") .customCoordinates("customCoordinates") - .customMetadata(JsonValue.from(mapOf())) + .customMetadata( + AssetListResponse.FileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") From 2c4c9aaf02408ce577980c2802e630faf1d63b56 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 03:30:47 +0000 Subject: [PATCH 007/125] fix(client): ensure correct binary content type chore(client): rename parameter --- .../imagekit/api/models/beta/v2/files/FileUploadParams.kt | 8 ++++---- .../com/imagekit/api/models/files/FileUploadParams.kt | 8 ++++---- 2 files changed, 8 insertions(+), 8 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 3271d1a7..3bfdf4e6 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 @@ -529,7 +529,7 @@ 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: Path) = apply { body.file(file) } + 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) } @@ -1629,11 +1629,11 @@ 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: Path) = + fun file(path: Path) = file( MultipartField.builder() - .value(file.inputStream()) - .filename(file.name) + .value(path.inputStream()) + .filename(path.name) .build() ) 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 548fce67..188c484d 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 @@ -590,7 +590,7 @@ 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: Path) = 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: @@ -1826,11 +1826,11 @@ 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: Path) = + fun file(path: Path) = file( MultipartField.builder() - .value(file.inputStream()) - .filename(file.name) + .value(path.inputStream()) + .filename(path.name) .build() ) From 4236a1113b1b01548bb889370e6ab2b4454ea035 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 03:43:11 +0000 Subject: [PATCH 008/125] chore(client): refactor closing / shutdown --- .../api/client/ImageKitClientAsyncImpl.kt | 2 +- .../imagekit/api/client/ImageKitClientImpl.kt | 2 +- .../com/imagekit/api/core/ClientOptions.kt | 18 ++++++ .../core/PhantomReachableExecutorService.kt | 58 +++++++++++++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableExecutorService.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/com/imagekit/api/client/ImageKitClientAsyncImpl.kt index 2552b193..bf151103 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 @@ -82,7 +82,7 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun beta(): BetaServiceAsync = beta - override fun close() = clientOptions.httpClient.close() + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ImageKitClientAsync.WithRawResponse { 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 62a932af..0ae5e53a 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 @@ -74,7 +74,7 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun beta(): BetaService = beta - override fun close() = clientOptions.httpClient.close() + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ImageKitClient.WithRawResponse { 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 a9c2b13a..140608eb 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 @@ -22,6 +22,8 @@ private constructor( * 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, /** @@ -170,6 +172,8 @@ private constructor( * 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) @@ -437,4 +441,18 @@ private constructor( ) } } + + /** + * 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/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) +} From eab46b8a22ab6a89195ff30b9c777f8e52167c52 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 21 Aug 2025 04:17:55 +0000 Subject: [PATCH 009/125] chore(internal): support running formatters directly --- scripts/format | 17 +++++++++++++++-- scripts/java-format | 7 +++++++ scripts/kotlin-format | 7 +++++++ scripts/lint | 17 ++++++++++++++++- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100755 scripts/java-format create mode 100755 scripts/kotlin-format diff --git a/scripts/format b/scripts/format index 7c0be4d5..65db1769 100755 --- a/scripts/format +++ b/scripts/format @@ -4,5 +4,18 @@ set -e cd "$(dirname "$0")/.." -echo "==> Running formatters" -./gradlew format +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 index aea8af71..dbc8f776 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,4 +5,19 @@ set -e cd "$(dirname "$0")/.." echo "==> Running lints" -./gradlew lint + +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 From 1120405d15de8bf911e95b00efdb7f53025dcbdd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 04:45:47 +0000 Subject: [PATCH 010/125] chore(ci): reduce log noise --- image-kit-java-proguard-test/build.gradle.kts | 2 -- image-kit-java-proguard-test/test.pro | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/image-kit-java-proguard-test/build.gradle.kts b/image-kit-java-proguard-test/build.gradle.kts index 11db2fec..c541ddc4 100644 --- a/image-kit-java-proguard-test/build.gradle.kts +++ b/image-kit-java-proguard-test/build.gradle.kts @@ -37,8 +37,6 @@ val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { outjars(proguardJarPath) printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") - dontwarn() - 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. diff --git a/image-kit-java-proguard-test/test.pro b/image-kit-java-proguard-test/test.pro index 4dff75bf..64d7928e 100644 --- a/image-kit-java-proguard-test/test.pro +++ b/image-kit-java-proguard-test/test.pro @@ -5,4 +5,5 @@ -keep class org.junit.** { *; } # Many warnings don't apply for our testing purposes. +-dontnote -dontwarn \ No newline at end of file From a0dcf5d74a1af71dd4a7ad0a405819127b33963f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 06:55:37 +0000 Subject: [PATCH 011/125] feat(api): manual updates --- .stats.yml | 2 +- .../com/imagekit/api/client/ImageKitClient.kt | 5 + .../api/client/ImageKitClientAsync.kt | 5 + .../api/client/ImageKitClientAsyncImpl.kt | 14 + .../imagekit/api/client/ImageKitClientImpl.kt | 12 + .../api/models/webhooks/UnwrapWebhookEvent.kt | 270 ++ ...VideoTransformationAcceptedWebhookEvent.kt | 2348 +++++++++++++ .../VideoTransformationErrorWebhookEvent.kt | 2682 ++++++++++++++ .../VideoTransformationReadyWebhookEvent.kt | 3100 +++++++++++++++++ .../api/services/async/WebhookServiceAsync.kt | 45 + .../services/async/WebhookServiceAsyncImpl.kt | 41 + .../api/services/blocking/WebhookService.kt | 41 + .../services/blocking/WebhookServiceImpl.kt | 45 + .../models/webhooks/UnwrapWebhookEventTest.kt | 584 ++++ ...oTransformationAcceptedWebhookEventTest.kt | 228 ++ ...ideoTransformationErrorWebhookEventTest.kt | 251 ++ ...ideoTransformationReadyWebhookEventTest.kt | 288 ++ .../api/proguard/ProGuardCompatibilityTest.kt | 1 + 18 files changed, 9961 insertions(+), 1 deletion(-) 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/VideoTransformationAcceptedWebhookEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.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/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/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt diff --git a/.stats.yml b/.stats.yml index 456c477f..94f1f4d5 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-584c2ccf3fc1a3ff3abf26b8d3dace2398d0f9ed6f20e4c411a13a81febb5e98.yml openapi_spec_hash: 14d1614ea3903d6b53f26e135c9cae81 -config_hash: 7e5c039f375ccdba7cf3e61492a273f2 +config_hash: 984f0887e4e3ebc749cd79d0512fea75 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 9467c831..ff5e2276 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.WebhookService import java.util.function.Consumer /** @@ -62,6 +63,8 @@ interface ImageKitClient { fun beta(): BetaService + fun webhooks(): WebhookService + /** * Closes this client, relinquishing any underlying resources. * @@ -98,5 +101,7 @@ interface ImageKitClient { 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 index fdef9561..22131527 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.WebhookServiceAsync import java.util.function.Consumer /** @@ -62,6 +63,8 @@ interface ImageKitClientAsync { fun beta(): BetaServiceAsync + fun webhooks(): WebhookServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -102,5 +105,7 @@ interface ImageKitClientAsync { 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 index bf151103..4ddc0590 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.WebhookServiceAsync +import com.imagekit.api.services.async.WebhookServiceAsyncImpl import java.util.function.Consumer class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageKitClientAsync { @@ -61,6 +63,10 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK 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 @@ -82,6 +88,8 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun beta(): BetaServiceAsync = beta + override fun webhooks(): WebhookServiceAsync = webhooks + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -115,6 +123,10 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK BetaServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val webhooks: WebhookServiceAsync.WithRawResponse by lazy { + WebhookServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): ImageKitClientAsync.WithRawResponse = @@ -136,5 +148,7 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK 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 index 0ae5e53a..433b100c 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.WebhookService +import com.imagekit.api.services.blocking.WebhookServiceImpl import java.util.function.Consumer class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitClient { @@ -53,6 +55,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli 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 @@ -74,6 +78,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun beta(): BetaService = beta + override fun webhooks(): WebhookService = webhooks + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -107,6 +113,10 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli BetaServiceImpl.WithRawResponseImpl(clientOptions) } + private val webhooks: WebhookService.WithRawResponse by lazy { + WebhookServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): ImageKitClient.WithRawResponse = @@ -128,5 +138,7 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli 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/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..20867724 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -0,0 +1,270 @@ +// 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 + +@JsonDeserialize(using = UnwrapWebhookEvent.Deserializer::class) +@JsonSerialize(using = UnwrapWebhookEvent.Serializer::class) +class UnwrapWebhookEvent +private constructor( + private val videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent? = null, + private val videoTransformationReady: VideoTransformationReadyWebhookEvent? = null, + private val videoTransformationError: VideoTransformationErrorWebhookEvent? = null, + private val _json: JsonValue? = null, +) { + + fun videoTransformationAccepted(): Optional = + Optional.ofNullable(videoTransformationAccepted) + + fun videoTransformationReady(): Optional = + Optional.ofNullable(videoTransformationReady) + + fun videoTransformationError(): Optional = + Optional.ofNullable(videoTransformationError) + + fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null + + fun isVideoTransformationReady(): Boolean = videoTransformationReady != null + + fun isVideoTransformationError(): Boolean = videoTransformationError != null + + fun asVideoTransformationAccepted(): VideoTransformationAcceptedWebhookEvent = + videoTransformationAccepted.getOrThrow("videoTransformationAccepted") + + fun asVideoTransformationReady(): VideoTransformationReadyWebhookEvent = + videoTransformationReady.getOrThrow("videoTransformationReady") + + fun asVideoTransformationError(): VideoTransformationErrorWebhookEvent = + videoTransformationError.getOrThrow("videoTransformationError") + + 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) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnwrapWebhookEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + ) { + videoTransformationAccepted.validate() + } + + override fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ) { + videoTransformationReady.validate() + } + + override fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ) { + videoTransformationError.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: VideoTransformationAcceptedWebhookEvent + ) = videoTransformationAccepted.validity() + + override fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ) = videoTransformationReady.validity() + + override fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ) = videoTransformationError.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 + } + + override fun hashCode(): Int = + Objects.hash( + videoTransformationAccepted, + videoTransformationReady, + videoTransformationError, + ) + + override fun toString(): String = + when { + videoTransformationAccepted != null -> + "UnwrapWebhookEvent{videoTransformationAccepted=$videoTransformationAccepted}" + videoTransformationReady != null -> + "UnwrapWebhookEvent{videoTransformationReady=$videoTransformationReady}" + videoTransformationError != null -> + "UnwrapWebhookEvent{videoTransformationError=$videoTransformationError}" + _json != null -> "UnwrapWebhookEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") + } + + companion object { + + @JvmStatic + fun ofVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + ) = UnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) + + @JvmStatic + fun ofVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ) = UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + + @JvmStatic + fun ofVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ) = UnwrapWebhookEvent(videoTransformationError = videoTransformationError) + } + + /** + * An interface that defines how to map each variant of [UnwrapWebhookEvent] to a value of type + * [T]. + */ + interface Visitor { + + fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + ): T + + fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ): T + + fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ): 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) + }, + ) + .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._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/VideoTransformationAcceptedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt new file mode 100644 index 00000000..8fc09857 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt @@ -0,0 +1,2348 @@ +// 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 + +class VideoTransformationAcceptedWebhookEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [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 [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 + * [VideoTransformationAcceptedWebhookEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoTransformationAcceptedWebhookEvent]. */ + 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: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + videoTransformationAcceptedWebhookEvent: VideoTransformationAcceptedWebhookEvent + ) = apply { + id = videoTransformationAcceptedWebhookEvent.id + createdAt = videoTransformationAcceptedWebhookEvent.createdAt + data = videoTransformationAcceptedWebhookEvent.data + request = videoTransformationAcceptedWebhookEvent.request + type = videoTransformationAcceptedWebhookEvent.type + additionalProperties = + videoTransformationAcceptedWebhookEvent.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 } + + 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 } + + 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 [VideoTransformationAcceptedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoTransformationAcceptedWebhookEvent = + VideoTransformationAcceptedWebhookEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VideoTransformationAcceptedWebhookEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + type().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.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()) + + /** + * @throws ImageKitInvalidDataException if 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() + } + + 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) + + 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()) + + /** + * Source asset 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 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() + } + + /** Source asset URL. */ + 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 additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(type, options, 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 type(): Type = type.getRequired("type") + + /** + * @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() + } + + 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 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) + + 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() + } + + 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(), + ) + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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() + } + + 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 + } + + 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 + } + + 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 } + + 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 } + + 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 + } + + 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) + } + } + + 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) + + 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() + } + + 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() + } + + 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() + } + + 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") + + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) + } + + /** An enum containing [VideoCodec]'s known values. */ + enum class Known { + H264, + VP9, + } + + /** + * 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, + /** + * 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 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + 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}" + } + + 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()) + + /** + * URL of the submitted 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 url(): String = url.getRequired("url") + + /** + * Unique ID 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") + + /** + * User-Agent header of the originating request. + * + * @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() + } + + /** URL of the submitted request. */ + 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 ID 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 } + + /** User-Agent header of the originating request. */ + 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}" + } + + 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_ACCEPTED = of("video.transformation.accepted") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VIDEO_TRANSFORMATION_ACCEPTED + } + + /** + * 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_ACCEPTED, + /** 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_ACCEPTED -> Value.VIDEO_TRANSFORMATION_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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_ACCEPTED -> Known.VIDEO_TRANSFORMATION_ACCEPTED + 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 VideoTransformationAcceptedWebhookEvent && + 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() = + "VideoTransformationAcceptedWebhookEvent{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/VideoTransformationErrorWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt new file mode 100644 index 00000000..aaf7c834 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt @@ -0,0 +1,2682 @@ +// 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 + +class VideoTransformationErrorWebhookEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [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 [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 + * [VideoTransformationErrorWebhookEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoTransformationErrorWebhookEvent]. */ + 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: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + videoTransformationErrorWebhookEvent: VideoTransformationErrorWebhookEvent + ) = apply { + id = videoTransformationErrorWebhookEvent.id + createdAt = videoTransformationErrorWebhookEvent.createdAt + data = videoTransformationErrorWebhookEvent.data + request = videoTransformationErrorWebhookEvent.request + type = videoTransformationErrorWebhookEvent.type + additionalProperties = + videoTransformationErrorWebhookEvent.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 } + + 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 } + + 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 [VideoTransformationErrorWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoTransformationErrorWebhookEvent = + VideoTransformationErrorWebhookEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VideoTransformationErrorWebhookEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + type().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.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()) + + /** + * @throws ImageKitInvalidDataException if 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() + } + + 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) + + 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()) + + /** + * Source asset 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 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() + } + + /** Source asset URL. */ + 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()) + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @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") + + /** + * @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() + } + + 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 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 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) + + 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() + } + + 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()) + + /** + * @throws ImageKitInvalidDataException if 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() + } + + 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) + + 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}" + } + + 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(), + ) + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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() + } + + 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 + } + + 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 + } + + 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 } + + 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 } + + 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 + } + + 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) + } + } + + 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) + + 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() + } + + 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() + } + + 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() + } + + 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") + + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) + } + + /** An enum containing [VideoCodec]'s known values. */ + enum class Known { + H264, + VP9, + } + + /** + * 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, + /** + * 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 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + 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}" + } + + 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()) + + /** + * URL of the submitted 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 url(): String = url.getRequired("url") + + /** + * Unique ID 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") + + /** + * User-Agent header of the originating request. + * + * @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() + } + + /** URL of the submitted request. */ + 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 ID 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 } + + /** User-Agent header of the originating request. */ + 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}" + } + + 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_ERROR = of("video.transformation.error") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VIDEO_TRANSFORMATION_ERROR + } + + /** + * 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_ERROR, + /** 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_ERROR -> Value.VIDEO_TRANSFORMATION_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) { + VIDEO_TRANSFORMATION_ERROR -> Known.VIDEO_TRANSFORMATION_ERROR + 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 VideoTransformationErrorWebhookEvent && + 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() = + "VideoTransformationErrorWebhookEvent{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/VideoTransformationReadyWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt new file mode 100644 index 00000000..fe77db61 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt @@ -0,0 +1,3100 @@ +// 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 + +class VideoTransformationReadyWebhookEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @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 [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 [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 + * [VideoTransformationReadyWebhookEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoTransformationReadyWebhookEvent]. */ + 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: JsonField? = null + private var timings: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + videoTransformationReadyWebhookEvent: VideoTransformationReadyWebhookEvent + ) = apply { + id = videoTransformationReadyWebhookEvent.id + createdAt = videoTransformationReadyWebhookEvent.createdAt + data = videoTransformationReadyWebhookEvent.data + request = videoTransformationReadyWebhookEvent.request + type = videoTransformationReadyWebhookEvent.type + timings = videoTransformationReadyWebhookEvent.timings + additionalProperties = + videoTransformationReadyWebhookEvent.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 } + + 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 } + + 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 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 [VideoTransformationReadyWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoTransformationReadyWebhookEvent = + VideoTransformationReadyWebhookEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + checkRequired("type", type), + timings, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VideoTransformationReadyWebhookEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + type().validate() + 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.asKnown().getOrNull()?.validity() ?: 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()) + + /** + * @throws ImageKitInvalidDataException if 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() + } + + 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) + + 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()) + + /** + * Source asset 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 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() + } + + /** Source asset URL. */ + 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()) + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @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") + + /** + * @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() + } + + 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 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 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) + + 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() + } + + 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(), + ) + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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") + + /** + * @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() + } + + 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 + } + + 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 + } + + 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 } + + 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 } + + 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 + } + + 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) + } + } + + 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) + + 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() + } + + 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() + } + + 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() + } + + 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") + + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) + } + + /** An enum containing [VideoCodec]'s known values. */ + enum class Known { + H264, + VP9, + } + + /** + * 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, + /** + * 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 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + 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}" + } + + 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()) + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @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() + } + + 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 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) + + 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()) + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * @throws ImageKitInvalidDataException if 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() + } + + 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 } + + 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 + } + + 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 } + + 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}" + } + + 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()) + + /** + * URL of the submitted 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 url(): String = url.getRequired("url") + + /** + * Unique ID 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") + + /** + * User-Agent header of the originating request. + * + * @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() + } + + /** URL of the submitted request. */ + 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 ID 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 } + + /** User-Agent header of the originating request. */ + 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}" + } + + 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_READY = of("video.transformation.ready") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VIDEO_TRANSFORMATION_READY + } + + /** + * 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_READY, + /** 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_READY -> Value.VIDEO_TRANSFORMATION_READY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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_READY -> Known.VIDEO_TRANSFORMATION_READY + 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() + } + + 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()) + + /** + * Milliseconds spent downloading the source. + * + * @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") + + /** + * Milliseconds spent encoding. + * + * @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() + } + + /** Milliseconds spent downloading the source. */ + 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 + } + + /** Milliseconds spent encoding. */ + 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 VideoTransformationReadyWebhookEvent && + 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() = + "VideoTransformationReadyWebhookEvent{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/WebhookServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt new file mode 100644 index 00000000..e31cab51 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt @@ -0,0 +1,45 @@ +// 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.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 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..50d5ac3e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt @@ -0,0 +1,41 @@ +// 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.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 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/blocking/WebhookService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt new file mode 100644 index 00000000..1469ec78 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.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.errors.ImageKitInvalidDataException +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 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..0eea343f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt @@ -0,0 +1,45 @@ +// 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.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 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/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..522d81d3 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -0,0 +1,584 @@ +// 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 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 = + VideoTransformationAcceptedWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedWebhookEvent.Data.builder() + .asset( + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationAccepted(videoTransformationAccepted) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()) + .contains(videoTransformationAccepted) + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + } + + @Test + fun ofVideoTransformationAcceptedRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationAccepted( + VideoTransformationAcceptedWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedWebhookEvent.Data.builder() + .asset( + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .builder() + .type( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type( + VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofVideoTransformationReady() { + val videoTransformationReady = + VideoTransformationReadyWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyWebhookEvent.Data.builder() + .asset( + VideoTransformationReadyWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyWebhookEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) + .timings( + VideoTransformationReadyWebhookEvent.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 + } + + @Test + fun ofVideoTransformationReadyRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationReady( + VideoTransformationReadyWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyWebhookEvent.Data.builder() + .asset( + VideoTransformationReadyWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) + .timings( + VideoTransformationReadyWebhookEvent.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 = + VideoTransformationErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorWebhookEvent.Data.builder() + .asset( + VideoTransformationErrorWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationError(videoTransformationError) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).contains(videoTransformationError) + } + + @Test + fun ofVideoTransformationErrorRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationError( + VideoTransformationErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorWebhookEvent.Data.builder() + .asset( + VideoTransformationErrorWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error + .builder() + .reason( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) + .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/VideoTransformationAcceptedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt new file mode 100644 index 00000000..32268b9b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt @@ -0,0 +1,228 @@ +// 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 VideoTransformationAcceptedWebhookEventTest { + + @Test + fun create() { + val videoTransformationAcceptedWebhookEvent = + VideoTransformationAcceptedWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedWebhookEvent.Data.builder() + .asset( + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) + .build() + + assertThat(videoTransformationAcceptedWebhookEvent.id()).isEqualTo("id") + assertThat(videoTransformationAcceptedWebhookEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(videoTransformationAcceptedWebhookEvent.data()) + .isEqualTo( + VideoTransformationAcceptedWebhookEvent.Data.builder() + .asset( + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(videoTransformationAcceptedWebhookEvent.request()) + .isEqualTo( + VideoTransformationAcceptedWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + assertThat(videoTransformationAcceptedWebhookEvent.type()) + .isEqualTo(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val videoTransformationAcceptedWebhookEvent = + VideoTransformationAcceptedWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedWebhookEvent.Data.builder() + .asset( + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) + .build() + + val roundtrippedVideoTransformationAcceptedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(videoTransformationAcceptedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVideoTransformationAcceptedWebhookEvent) + .isEqualTo(videoTransformationAcceptedWebhookEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt new file mode 100644 index 00000000..f900a174 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt @@ -0,0 +1,251 @@ +// 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 VideoTransformationErrorWebhookEventTest { + + @Test + fun create() { + val videoTransformationErrorWebhookEvent = + VideoTransformationErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorWebhookEvent.Data.builder() + .asset( + VideoTransformationErrorWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) + .build() + + assertThat(videoTransformationErrorWebhookEvent.id()).isEqualTo("id") + assertThat(videoTransformationErrorWebhookEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(videoTransformationErrorWebhookEvent.data()) + .isEqualTo( + VideoTransformationErrorWebhookEvent.Data.builder() + .asset( + VideoTransformationErrorWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(videoTransformationErrorWebhookEvent.request()) + .isEqualTo( + VideoTransformationErrorWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + assertThat(videoTransformationErrorWebhookEvent.type()) + .isEqualTo(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val videoTransformationErrorWebhookEvent = + VideoTransformationErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorWebhookEvent.Data.builder() + .asset( + VideoTransformationErrorWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) + .build() + + val roundtrippedVideoTransformationErrorWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(videoTransformationErrorWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVideoTransformationErrorWebhookEvent) + .isEqualTo(videoTransformationErrorWebhookEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt new file mode 100644 index 00000000..5c942b86 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt @@ -0,0 +1,288 @@ +// 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 VideoTransformationReadyWebhookEventTest { + + @Test + fun create() { + val videoTransformationReadyWebhookEvent = + VideoTransformationReadyWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyWebhookEvent.Data.builder() + .asset( + VideoTransformationReadyWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyWebhookEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) + .timings( + VideoTransformationReadyWebhookEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + .build() + + assertThat(videoTransformationReadyWebhookEvent.id()).isEqualTo("id") + assertThat(videoTransformationReadyWebhookEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(videoTransformationReadyWebhookEvent.data()) + .isEqualTo( + VideoTransformationReadyWebhookEvent.Data.builder() + .asset( + VideoTransformationReadyWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyWebhookEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(videoTransformationReadyWebhookEvent.request()) + .isEqualTo( + VideoTransformationReadyWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + assertThat(videoTransformationReadyWebhookEvent.type()) + .isEqualTo(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) + assertThat(videoTransformationReadyWebhookEvent.timings()) + .contains( + VideoTransformationReadyWebhookEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val videoTransformationReadyWebhookEvent = + VideoTransformationReadyWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyWebhookEvent.Data.builder() + .asset( + VideoTransformationReadyWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyWebhookEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) + .timings( + VideoTransformationReadyWebhookEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + .build() + + val roundtrippedVideoTransformationReadyWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(videoTransformationReadyWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVideoTransformationReadyWebhookEvent) + .isEqualTo(videoTransformationReadyWebhookEvent) + } +} 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 c463aee3..f394e5b0 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 @@ -60,6 +60,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.folders()).isNotNull() assertThat(client.accounts()).isNotNull() assertThat(client.beta()).isNotNull() + assertThat(client.webhooks()).isNotNull() } @Test From c443e2c2d7b765470e8867e3b93eaf21b147938f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 07:48:25 +0000 Subject: [PATCH 012/125] feat(api): manual updates --- .stats.yml | 2 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 281 +++++++++ .../api/services/async/WebhookServiceAsync.kt | 8 + .../services/async/WebhookServiceAsyncImpl.kt | 9 + .../api/services/blocking/WebhookService.kt | 8 + .../services/blocking/WebhookServiceImpl.kt | 13 + .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 586 ++++++++++++++++++ 7 files changed, 906 insertions(+), 1 deletion(-) 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/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt diff --git a/.stats.yml b/.stats.yml index 94f1f4d5..ede64f59 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-584c2ccf3fc1a3ff3abf26b8d3dace2398d0f9ed6f20e4c411a13a81febb5e98.yml openapi_spec_hash: 14d1614ea3903d6b53f26e135c9cae81 -config_hash: 984f0887e4e3ebc749cd79d0512fea75 +config_hash: 9f3c729a01b07940df835ef5ec13119a 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..3d9637ee --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -0,0 +1,281 @@ +// 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 + +@JsonDeserialize(using = UnsafeUnwrapWebhookEvent.Deserializer::class) +@JsonSerialize(using = UnsafeUnwrapWebhookEvent.Serializer::class) +class UnsafeUnwrapWebhookEvent +private constructor( + private val videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent? = null, + private val videoTransformationReady: VideoTransformationReadyWebhookEvent? = null, + private val videoTransformationError: VideoTransformationErrorWebhookEvent? = null, + private val _json: JsonValue? = null, +) { + + fun videoTransformationAccepted(): Optional = + Optional.ofNullable(videoTransformationAccepted) + + fun videoTransformationReady(): Optional = + Optional.ofNullable(videoTransformationReady) + + fun videoTransformationError(): Optional = + Optional.ofNullable(videoTransformationError) + + fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null + + fun isVideoTransformationReady(): Boolean = videoTransformationReady != null + + fun isVideoTransformationError(): Boolean = videoTransformationError != null + + fun asVideoTransformationAccepted(): VideoTransformationAcceptedWebhookEvent = + videoTransformationAccepted.getOrThrow("videoTransformationAccepted") + + fun asVideoTransformationReady(): VideoTransformationReadyWebhookEvent = + videoTransformationReady.getOrThrow("videoTransformationReady") + + fun asVideoTransformationError(): VideoTransformationErrorWebhookEvent = + videoTransformationError.getOrThrow("videoTransformationError") + + 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) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnsafeUnwrapWebhookEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + ) { + videoTransformationAccepted.validate() + } + + override fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ) { + videoTransformationReady.validate() + } + + override fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ) { + videoTransformationError.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: VideoTransformationAcceptedWebhookEvent + ) = videoTransformationAccepted.validity() + + override fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ) = videoTransformationReady.validity() + + override fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ) = videoTransformationError.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 + } + + override fun hashCode(): Int = + Objects.hash( + videoTransformationAccepted, + videoTransformationReady, + videoTransformationError, + ) + + override fun toString(): String = + when { + videoTransformationAccepted != null -> + "UnsafeUnwrapWebhookEvent{videoTransformationAccepted=$videoTransformationAccepted}" + videoTransformationReady != null -> + "UnsafeUnwrapWebhookEvent{videoTransformationReady=$videoTransformationReady}" + videoTransformationError != null -> + "UnsafeUnwrapWebhookEvent{videoTransformationError=$videoTransformationError}" + _json != null -> "UnsafeUnwrapWebhookEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") + } + + companion object { + + @JvmStatic + fun ofVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + ) = UnsafeUnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) + + @JvmStatic + fun ofVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ) = UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + + @JvmStatic + fun ofVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ) = UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) + } + + /** + * An interface that defines how to map each variant of [UnsafeUnwrapWebhookEvent] to a value of + * type [T]. + */ + interface Visitor { + + fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + ): T + + fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ): T + + fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ): 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, + ) + }, + ) + .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._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") + } + } + } +} 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 e31cab51..68d16414 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 @@ -4,6 +4,7 @@ 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 @@ -21,6 +22,13 @@ interface WebhookServiceAsync { */ 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. * 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 50d5ac3e..b2c9b205 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 @@ -4,6 +4,7 @@ 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 @@ -20,6 +21,14 @@ 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. * 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 1469ec78..953d9d20 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 @@ -4,6 +4,7 @@ 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 @@ -21,6 +22,13 @@ interface WebhookService { */ 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. * 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 0eea343f..7e81f403 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 @@ -5,6 +5,7 @@ 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 @@ -20,6 +21,18 @@ 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()) + } catch (e: Exception) { + throw ImageKitInvalidDataException("Error parsing body", e) + } + /** * Unwraps a webhook event from its JSON representation. * 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..c5719432 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -0,0 +1,586 @@ +// 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 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 = + VideoTransformationAcceptedWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedWebhookEvent.Data.builder() + .asset( + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationAccepted(videoTransformationAccepted) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()) + .contains(videoTransformationAccepted) + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + } + + @Test + fun ofVideoTransformationAcceptedRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationAccepted( + VideoTransformationAcceptedWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedWebhookEvent.Data.builder() + .asset( + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .builder() + .type( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type( + VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofVideoTransformationReady() { + val videoTransformationReady = + VideoTransformationReadyWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyWebhookEvent.Data.builder() + .asset( + VideoTransformationReadyWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyWebhookEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) + .timings( + VideoTransformationReadyWebhookEvent.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 + } + + @Test + fun ofVideoTransformationReadyRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationReady( + VideoTransformationReadyWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyWebhookEvent.Data.builder() + .asset( + VideoTransformationReadyWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyWebhookEvent.Data + .Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) + .timings( + VideoTransformationReadyWebhookEvent.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 = + VideoTransformationErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorWebhookEvent.Data.builder() + .asset( + VideoTransformationErrorWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorWebhookEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorWebhookEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationError(videoTransformationError) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()) + .contains(videoTransformationError) + } + + @Test + fun ofVideoTransformationErrorRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationError( + VideoTransformationErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorWebhookEvent.Data.builder() + .asset( + VideoTransformationErrorWebhookEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error + .builder() + .reason( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options + .builder() + .audioCodec( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorWebhookEvent.Data + .Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorWebhookEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) + .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 ") + } +} From 50e8ca8f0bf0cd239ddef3c87254547ef621d67d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:01:32 +0000 Subject: [PATCH 013/125] feat(api): manual updates --- .stats.yml | 2 +- README.md | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index ede64f59..980c9061 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-584c2ccf3fc1a3ff3abf26b8d3dace2398d0f9ed6f20e4c411a13a81febb5e98.yml openapi_spec_hash: 14d1614ea3903d6b53f26e135c9cae81 -config_hash: 9f3c729a01b07940df835ef5ec13119a +config_hash: 91beba074bbcedbfda383cf006796fa1 diff --git a/README.md b/README.md index cb3ea8a9..0ca8bdd9 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() .file(ByteArrayInputStream("some content".getBytes())) - .fileName("fileName") + .fileName("file-name.jpg") .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -151,7 +151,7 @@ ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() .file(ByteArrayInputStream("some content".getBytes())) - .fileName("fileName") + .fileName("file-name.jpg") .build(); CompletableFuture response = client.async().files().upload(params); ``` @@ -172,7 +172,7 @@ ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() .file(ByteArrayInputStream("some content".getBytes())) - .fileName("fileName") + .fileName("file-name.jpg") .build(); CompletableFuture response = client.files().upload(params); ``` @@ -258,7 +258,7 @@ import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() .file(ByteArrayInputStream("some content".getBytes())) - .fileName("fileName") + .fileName("file-name.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); @@ -505,11 +505,10 @@ To set a documented parameter or property to an undocumented or not yet supporte ```java import com.imagekit.api.core.JsonValue; import com.imagekit.api.models.files.FileUploadParams; -import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("some content".getBytes())) - .fileName(JsonValue.from(42)) + .file(JsonValue.from(42)) + .fileName("file-name.jpg") .build(); ``` From 8340dc72cf7eeac9e1861702ab4c68079fd33f31 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:03:56 +0000 Subject: [PATCH 014/125] feat(api): manual updates --- .stats.yml | 2 +- README.md | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.stats.yml b/.stats.yml index 980c9061..ede64f59 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-584c2ccf3fc1a3ff3abf26b8d3dace2398d0f9ed6f20e4c411a13a81febb5e98.yml openapi_spec_hash: 14d1614ea3903d6b53f26e135c9cae81 -config_hash: 91beba074bbcedbfda383cf006796fa1 +config_hash: 9f3c729a01b07940df835ef5ec13119a diff --git a/README.md b/README.md index 0ca8bdd9..cb3ea8a9 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() .file(ByteArrayInputStream("some content".getBytes())) - .fileName("file-name.jpg") + .fileName("fileName") .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -151,7 +151,7 @@ ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() .file(ByteArrayInputStream("some content".getBytes())) - .fileName("file-name.jpg") + .fileName("fileName") .build(); CompletableFuture response = client.async().files().upload(params); ``` @@ -172,7 +172,7 @@ ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() .file(ByteArrayInputStream("some content".getBytes())) - .fileName("file-name.jpg") + .fileName("fileName") .build(); CompletableFuture response = client.files().upload(params); ``` @@ -258,7 +258,7 @@ import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() .file(ByteArrayInputStream("some content".getBytes())) - .fileName("file-name.jpg") + .fileName("fileName") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); @@ -505,10 +505,11 @@ To set a documented parameter or property to an undocumented or not yet supporte ```java import com.imagekit.api.core.JsonValue; import com.imagekit.api.models.files.FileUploadParams; +import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file(JsonValue.from(42)) - .fileName("file-name.jpg") + .file(ByteArrayInputStream("some content".getBytes())) + .fileName(JsonValue.from(42)) .build(); ``` From 063a86ecce37856bef3651c278ebd22e9801c08f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:06:23 +0000 Subject: [PATCH 015/125] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/AutoDescriptionExtension.kt | 296 -- .../api/models/AutoTaggingExtension.kt | 385 --- .../com/imagekit/api/models/ExifDetails.kt | 1142 -------- .../com/imagekit/api/models/ExifImage.kt | 522 ---- .../kotlin/com/imagekit/api/models/Gps.kt | 178 -- .../imagekit/api/models/Interoperability.kt | 201 -- .../api/models/RemovedotBgExtension.kt | 612 ---- .../com/imagekit/api/models/Thumbnail.kt | 359 --- .../models/beta/v2/files/FileUploadParams.kt | 1241 +++++++- .../beta/v2/files/FileUploadResponse.kt | 2608 ++++++++++++++++- .../api/models/files/FileUpdateParams.kt | 1360 ++++++++- .../api/models/files/FileUploadParams.kt | 1241 +++++++- .../api/models/files/FileUploadResponse.kt | 2608 ++++++++++++++++- .../metadata/MetadataGetFromUrlResponse.kt | 2570 +++++++++++++++- .../files/metadata/MetadataGetResponse.kt | 2570 +++++++++++++++- .../models/AutoDescriptionExtensionTest.kt | 39 - .../api/models/AutoTaggingExtensionTest.kt | 45 - .../imagekit/api/models/ExifDetailsTest.kt | 113 - .../com/imagekit/api/models/ExifImageTest.kt | 68 - .../kotlin/com/imagekit/api/models/GpsTest.kt | 30 - .../api/models/InteroperabilityTest.kt | 41 - .../api/models/RemovedotBgExtensionTest.kt | 63 - .../com/imagekit/api/models/ThumbnailTest.kt | 53 - .../beta/v2/files/FileUploadParamsTest.kt | 42 +- .../beta/v2/files/FileUploadResponseTest.kt | 47 +- .../api/models/files/FileUpdateParamsTest.kt | 150 +- .../api/models/files/FileUploadParamsTest.kt | 42 +- .../models/files/FileUploadResponseTest.kt | 47 +- .../MetadataGetFromUrlResponseTest.kt | 43 +- .../files/metadata/MetadataGetResponseTest.kt | 35 +- .../api/services/ErrorHandlingTest.kt | 274 +- .../api/services/ServiceParamsTest.kt | 14 +- .../services/async/FileServiceAsyncTest.kt | 63 +- .../async/beta/v2/FileServiceAsyncTest.kt | 15 +- .../api/services/blocking/FileServiceTest.kt | 63 +- .../blocking/beta/v2/FileServiceTest.kt | 15 +- 37 files changed, 14515 insertions(+), 4682 deletions(-) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoDescriptionExtension.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoTaggingExtension.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifDetails.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifImage.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Gps.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Interoperability.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/RemovedotBgExtension.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Thumbnail.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoDescriptionExtensionTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoTaggingExtensionTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifDetailsTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifImageTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GpsTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/InteroperabilityTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/RemovedotBgExtensionTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ThumbnailTest.kt diff --git a/.stats.yml b/.stats.yml index ede64f59..254a6c30 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-584c2ccf3fc1a3ff3abf26b8d3dace2398d0f9ed6f20e4c411a13a81febb5e98.yml openapi_spec_hash: 14d1614ea3903d6b53f26e135c9cae81 -config_hash: 9f3c729a01b07940df835ef5ec13119a +config_hash: e2f52106d0ea435659ba3ff7074406f5 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoDescriptionExtension.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoDescriptionExtension.kt deleted file mode 100644 index c301c765..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoDescriptionExtension.kt +++ /dev/null @@ -1,296 +0,0 @@ -// 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.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class AutoDescriptionExtension -private constructor( - private val name: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() - ) : this(name, mutableMapOf()) - - /** - * Specifies the auto description 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(): Name = name.getRequired("name") - - /** - * Returns the raw JSON value 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 [AutoDescriptionExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoDescriptionExtension]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { - name = autoDescriptionExtension.name - additionalProperties = autoDescriptionExtension.additionalProperties.toMutableMap() - } - - /** Specifies the auto description extension. */ - 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 [AutoDescriptionExtension]. - * - * 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(): AutoDescriptionExtension = - AutoDescriptionExtension( - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoDescriptionExtension = apply { - if (validated) { - return@apply - } - - 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 = (name.asKnown().getOrNull()?.validity() ?: 0) - - /** Specifies the auto description extension. */ - 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - AI_AUTO_DESCRIPTION - } - - /** - * 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 { - AI_AUTO_DESCRIPTION, - /** 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) { - AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION - 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 AutoDescriptionExtension && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoDescriptionExtension{name=$name, additionalProperties=$additionalProperties}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoTaggingExtension.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoTaggingExtension.kt deleted file mode 100644 index 00cdf71d..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AutoTaggingExtension.kt +++ /dev/null @@ -1,385 +0,0 @@ -// 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.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -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}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifDetails.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifDetails.kt deleted file mode 100644 index 956b2b5c..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifDetails.kt +++ /dev/null @@ -1,1142 +0,0 @@ -// 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 - -/** Object containing Exif details. */ -class ExifDetails -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 [ExifDetails]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExifDetails]. */ - 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(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) = 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 [ExifDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ExifDetails = - ExifDetails( - 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(): ExifDetails = 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 ExifDetails && - 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() = - "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}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifImage.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifImage.kt deleted file mode 100644 index eb6f007f..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExifImage.kt +++ /dev/null @@ -1,522 +0,0 @@ -// 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 - -/** Object containing EXIF image information. */ -class ExifImage -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 [ExifImage]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExifImage]. */ - 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(exifImage: ExifImage) = apply { - exifOffset = exifImage.exifOffset - gpsInfo = exifImage.gpsInfo - make = exifImage.make - model = exifImage.model - modifyDate = exifImage.modifyDate - orientation = exifImage.orientation - resolutionUnit = exifImage.resolutionUnit - software = exifImage.software - xResolution = exifImage.xResolution - yCbCrPositioning = exifImage.yCbCrPositioning - yResolution = exifImage.yResolution - additionalProperties = exifImage.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 [ExifImage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ExifImage = - ExifImage( - exifOffset, - gpsInfo, - make, - model, - modifyDate, - orientation, - resolutionUnit, - software, - xResolution, - yCbCrPositioning, - yResolution, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ExifImage = 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 ExifImage && - 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() = - "ExifImage{exifOffset=$exifOffset, gpsInfo=$gpsInfo, make=$make, model=$model, modifyDate=$modifyDate, orientation=$orientation, resolutionUnit=$resolutionUnit, software=$software, xResolution=$xResolution, yCbCrPositioning=$yCbCrPositioning, yResolution=$yResolution, additionalProperties=$additionalProperties}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Gps.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Gps.kt deleted file mode 100644 index a602b722..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Gps.kt +++ /dev/null @@ -1,178 +0,0 @@ -// 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.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 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}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Interoperability.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Interoperability.kt deleted file mode 100644 index 36235c9b..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Interoperability.kt +++ /dev/null @@ -1,201 +0,0 @@ -// 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 - -/** 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}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/RemovedotBgExtension.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/RemovedotBgExtension.kt deleted file mode 100644 index 1820eff7..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/RemovedotBgExtension.kt +++ /dev/null @@ -1,612 +0,0 @@ -// 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.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class RemovedotBgExtension -private constructor( - private val name: JsonField, - private val options: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("options") @ExcludeMissing options: JsonField = JsonMissing.of(), - ) : this(name, options, mutableMapOf()) - - /** - * Specifies the background removal 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(): Name = name.getRequired("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 [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 [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 [RemovedotBgExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemovedotBgExtension]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var options: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { - name = removedotBgExtension.name - options = removedotBgExtension.options - additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() - } - - /** Specifies the background removal extension. */ - 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 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 [RemovedotBgExtension]. - * - * 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(): RemovedotBgExtension = - RemovedotBgExtension( - checkRequired("name", name), - options, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): RemovedotBgExtension = apply { - if (validated) { - return@apply - } - - name().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 = - (name.asKnown().getOrNull()?.validity() ?: 0) + - (options.asKnown().getOrNull()?.validity() ?: 0) - - /** Specifies the background removal extension. */ - 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 REMOVE_BG = of("remove-bg") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - REMOVE_BG - } - - /** - * 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 { - REMOVE_BG, - /** 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) { - REMOVE_BG -> Value.REMOVE_BG - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - REMOVE_BG -> Known.REMOVE_BG - 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() - } - - 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 RemovedotBgExtension && - 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() = - "RemovedotBgExtension{name=$name, options=$options, additionalProperties=$additionalProperties}" -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Thumbnail.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Thumbnail.kt deleted file mode 100644 index ea242786..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Thumbnail.kt +++ /dev/null @@ -1,359 +0,0 @@ -// 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 - -/** 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}" -} 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 3bfdf4e6..bf154ec8 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,9 +29,6 @@ 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.AutoDescriptionExtension -import com.imagekit.api.models.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -661,17 +658,17 @@ private constructor( fun addExtension(extension: Extension) = apply { body.addExtension(extension) } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: RemovedotBgExtension) = apply { + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = apply { body.addExtension(removedotBg) } /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: AutoTaggingExtension) = apply { + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { body.addExtension(autoTagging) } /** Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: AutoDescriptionExtension) = apply { + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = apply { body.addExtension(autoDescription) } @@ -1775,17 +1772,17 @@ private constructor( } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: RemovedotBgExtension) = + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = addExtension(Extension.ofRemovedotBg(removedotBg)) /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: AutoTaggingExtension) = + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = addExtension(Extension.ofAutoTagging(autoTagging)) /** * Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: AutoDescriptionExtension) = + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = addExtension(Extension.ofAutoDescription(autoDescription)) /** @@ -2500,6 +2497,1232 @@ private constructor( } } } + + class RemovedotBgExtension + private constructor( + private val name: MultipartField, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the background removal 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(): Name = name.value.getRequired("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 [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + /** + * 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 [RemovedotBgExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovedotBgExtension]. */ + class Builder internal constructor() { + + private var name: MultipartField? = null + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { + name = removedotBgExtension.name + options = removedotBgExtension.options + additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() + } + + /** Specifies the background removal extension. */ + 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 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 [RemovedotBgExtension]. + * + * 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(): RemovedotBgExtension = + RemovedotBgExtension( + checkRequired("name", name), + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovedotBgExtension = apply { + if (validated) { + return@apply + } + + name().validate() + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the background removal extension. */ + 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 REMOVE_BG = of("remove-bg") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + REMOVE_BG + } + + /** + * 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 { + REMOVE_BG, + /** + * 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) { + REMOVE_BG -> Value.REMOVE_BG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + REMOVE_BG -> Known.REMOVE_BG + 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() + } + + 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 RemovedotBgExtension && + 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() = + "RemovedotBgExtension{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 AutoDescriptionExtension + private constructor( + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the auto description 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(): Name = name.value.getRequired("name") + + /** + * 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 + * [AutoDescriptionExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoDescriptionExtension]. */ + class Builder internal constructor() { + + private var name: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { + name = autoDescriptionExtension.name + additionalProperties = + autoDescriptionExtension.additionalProperties.toMutableMap() + } + + /** Specifies the auto description extension. */ + 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 [AutoDescriptionExtension]. + * + * 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(): AutoDescriptionExtension = + AutoDescriptionExtension( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoDescriptionExtension = apply { + if (validated) { + return@apply + } + + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the auto description extension. */ + 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + AI_AUTO_DESCRIPTION + } + + /** + * 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 { + AI_AUTO_DESCRIPTION, + /** + * 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) { + AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION + 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 AutoDescriptionExtension && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoDescriptionExtension{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/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index 67a5e524..72fb5e91 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,11 +14,6 @@ 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.ExifDetails -import com.imagekit.api.models.ExifImage -import com.imagekit.api.models.Gps -import com.imagekit.api.models.Interoperability -import com.imagekit.api.models.Thumbnail import java.util.Collections import java.util.Objects import java.util.Optional @@ -2764,9 +2759,9 @@ private constructor( class Exif private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, - private val image: JsonField, + private val image: JsonField, private val interoperability: JsonField, private val makernote: JsonField, private val thumbnail: JsonField, @@ -2775,13 +2770,9 @@ 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("image") @ExcludeMissing image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @ExcludeMissing interoperability: JsonField = JsonMissing.of(), @@ -2799,7 +2790,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. @@ -2815,7 +2806,7 @@ private constructor( * @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") + fun image(): Optional = image.getOptional("image") /** * JSON object. @@ -2845,7 +2836,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]. @@ -2859,7 +2850,7 @@ private constructor( * * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image /** * Returns the raw JSON value of [interoperability]. @@ -2912,9 +2903,9 @@ 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 image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() private var makernote: JsonField = JsonMissing.of() private var thumbnail: JsonField = JsonMissing.of() @@ -2932,16 +2923,16 @@ private constructor( } /** Object containing Exif details. */ - fun exif(exif: ExifDetails) = exif(JsonField.of(exif)) + 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 [ExifDetails] 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 } + fun exif(exif: JsonField) = apply { this.exif = exif } /** Object containing GPS information. */ fun gps(gps: Gps) = gps(JsonField.of(gps)) @@ -2956,16 +2947,16 @@ private constructor( fun gps(gps: JsonField) = apply { this.gps = gps } /** Object containing EXIF image information. */ - fun image(image: ExifImage) = image(JsonField.of(image)) + 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 [ExifImage] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported 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 } + fun image(image: JsonField) = apply { this.image = image } /** JSON object. */ fun interoperability(interoperability: Interoperability) = @@ -3087,70 +3078,2197 @@ private constructor( (makernote.asKnown().getOrNull()?.validity() ?: 0) + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) - class Makernote - @JsonCreator + /** Object containing Exif details. */ + class InnerExif private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + 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 = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Makernote]. */ + /** Returns a mutable builder for constructing an instance of [InnerExif]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Makernote]. */ + /** 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(makernote: Makernote) = apply { - additionalProperties = makernote.additionalProperties.toMutableMap() + 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 additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun apertureValue(apertureValue: Double) = + apertureValue(JsonField.of(apertureValue)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * 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 putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun colorSpace(colorSpace: Long) = colorSpace(JsonField.of(colorSpace)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun createDate(createDate: String) = createDate(JsonField.of(createDate)) /** - * Returns an immutable instance of [Makernote]. + * Sets [Builder.createDate] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * 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 build(): Makernote = Makernote(additionalProperties.toImmutable()) - } + fun createDate(createDate: JsonField) = apply { + this.createDate = createDate + } - private var validated: Boolean = false + fun customRendered(customRendered: Long) = + customRendered(JsonField.of(customRendered)) - fun validate(): Makernote = apply { - if (validated) { - return@apply + /** + * 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 @@ -3191,6 +5309,378 @@ private constructor( 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 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 4326889d..49b6961e 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,9 +29,6 @@ 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.AutoDescriptionExtension -import com.imagekit.api.models.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import java.util.Collections import java.util.Objects import java.util.Optional @@ -730,18 +727,18 @@ private constructor( } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: RemovedotBgExtension) = + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = addExtension(Extension.ofRemovedotBg(removedotBg)) /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: AutoTaggingExtension) = + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = addExtension(Extension.ofAutoTagging(autoTagging)) /** * Alias for calling [addExtension] with * `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: AutoDescriptionExtension) = + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = addExtension(Extension.ofAutoDescription(autoDescription)) /** @@ -1235,6 +1232,1357 @@ private constructor( } } } + + class RemovedotBgExtension + private constructor( + private val name: JsonField, + private val options: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + + /** + * Specifies the background removal 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(): Name = name.getRequired("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 [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 [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 + * [RemovedotBgExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovedotBgExtension]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { + name = removedotBgExtension.name + options = removedotBgExtension.options + additionalProperties = + removedotBgExtension.additionalProperties.toMutableMap() + } + + /** Specifies the background removal extension. */ + 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 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 [RemovedotBgExtension]. + * + * 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(): RemovedotBgExtension = + RemovedotBgExtension( + checkRequired("name", name), + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovedotBgExtension = apply { + if (validated) { + return@apply + } + + name().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 = + (name.asKnown().getOrNull()?.validity() ?: 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the background removal extension. */ + 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 REMOVE_BG = of("remove-bg") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + REMOVE_BG + } + + /** + * 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 { + REMOVE_BG, + /** + * 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) { + REMOVE_BG -> Value.REMOVE_BG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + REMOVE_BG -> Known.REMOVE_BG + 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() + } + + 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 RemovedotBgExtension && + 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() = + "RemovedotBgExtension{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}" + } + + class AutoDescriptionExtension + private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * Specifies the auto description 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(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value 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 + * [AutoDescriptionExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoDescriptionExtension]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = + apply { + name = autoDescriptionExtension.name + additionalProperties = + autoDescriptionExtension.additionalProperties.toMutableMap() + } + + /** Specifies the auto description extension. */ + 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 [AutoDescriptionExtension]. + * + * 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(): AutoDescriptionExtension = + AutoDescriptionExtension( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoDescriptionExtension = apply { + if (validated) { + return@apply + } + + 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 = (name.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the auto description extension. */ + 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + AI_AUTO_DESCRIPTION + } + + /** + * 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 { + AI_AUTO_DESCRIPTION, + /** + * 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) { + AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION + 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 AutoDescriptionExtension && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoDescriptionExtension{name=$name, 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 188c484d..41a1122c 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,9 +29,6 @@ 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.AutoDescriptionExtension -import com.imagekit.api.models.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -741,17 +738,17 @@ private constructor( fun addExtension(extension: Extension) = apply { body.addExtension(extension) } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: RemovedotBgExtension) = apply { + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = apply { body.addExtension(removedotBg) } /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: AutoTaggingExtension) = apply { + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { body.addExtension(autoTagging) } /** Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: AutoDescriptionExtension) = apply { + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = apply { body.addExtension(autoDescription) } @@ -1990,17 +1987,17 @@ private constructor( } /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: RemovedotBgExtension) = + fun addExtension(removedotBg: Extension.RemovedotBgExtension) = addExtension(Extension.ofRemovedotBg(removedotBg)) /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: AutoTaggingExtension) = + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = addExtension(Extension.ofAutoTagging(autoTagging)) /** * Alias for calling [addExtension] with `Extension.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: AutoDescriptionExtension) = + fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = addExtension(Extension.ofAutoDescription(autoDescription)) /** @@ -2766,6 +2763,1232 @@ private constructor( } } } + + class RemovedotBgExtension + private constructor( + private val name: MultipartField, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the background removal 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(): Name = name.value.getRequired("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 [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + /** + * 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 [RemovedotBgExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemovedotBgExtension]. */ + class Builder internal constructor() { + + private var name: MultipartField? = null + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { + name = removedotBgExtension.name + options = removedotBgExtension.options + additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() + } + + /** Specifies the background removal extension. */ + 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 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 [RemovedotBgExtension]. + * + * 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(): RemovedotBgExtension = + RemovedotBgExtension( + checkRequired("name", name), + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RemovedotBgExtension = apply { + if (validated) { + return@apply + } + + name().validate() + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the background removal extension. */ + 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 REMOVE_BG = of("remove-bg") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + REMOVE_BG + } + + /** + * 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 { + REMOVE_BG, + /** + * 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) { + REMOVE_BG -> Value.REMOVE_BG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + REMOVE_BG -> Known.REMOVE_BG + 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() + } + + 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 RemovedotBgExtension && + 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() = + "RemovedotBgExtension{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 AutoDescriptionExtension + private constructor( + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the auto description 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(): Name = name.value.getRequired("name") + + /** + * 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 + * [AutoDescriptionExtension]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoDescriptionExtension]. */ + class Builder internal constructor() { + + private var name: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { + name = autoDescriptionExtension.name + additionalProperties = + autoDescriptionExtension.additionalProperties.toMutableMap() + } + + /** Specifies the auto description extension. */ + 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 [AutoDescriptionExtension]. + * + * 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(): AutoDescriptionExtension = + AutoDescriptionExtension( + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoDescriptionExtension = apply { + if (validated) { + return@apply + } + + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the auto description extension. */ + 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + AI_AUTO_DESCRIPTION + } + + /** + * 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 { + AI_AUTO_DESCRIPTION, + /** + * 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) { + AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION + 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 AutoDescriptionExtension && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoDescriptionExtension{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/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index f39e6fec..fa6f9d79 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,11 +14,6 @@ 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.ExifDetails -import com.imagekit.api.models.ExifImage -import com.imagekit.api.models.Gps -import com.imagekit.api.models.Interoperability -import com.imagekit.api.models.Thumbnail import java.util.Collections import java.util.Objects import java.util.Optional @@ -2764,9 +2759,9 @@ private constructor( class Exif private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, - private val image: JsonField, + private val image: JsonField, private val interoperability: JsonField, private val makernote: JsonField, private val thumbnail: JsonField, @@ -2775,13 +2770,9 @@ 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("image") @ExcludeMissing image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @ExcludeMissing interoperability: JsonField = JsonMissing.of(), @@ -2799,7 +2790,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. @@ -2815,7 +2806,7 @@ private constructor( * @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") + fun image(): Optional = image.getOptional("image") /** * JSON object. @@ -2845,7 +2836,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]. @@ -2859,7 +2850,7 @@ private constructor( * * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image /** * Returns the raw JSON value of [interoperability]. @@ -2912,9 +2903,9 @@ 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 image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() private var makernote: JsonField = JsonMissing.of() private var thumbnail: JsonField = JsonMissing.of() @@ -2932,16 +2923,16 @@ private constructor( } /** Object containing Exif details. */ - fun exif(exif: ExifDetails) = exif(JsonField.of(exif)) + 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 [ExifDetails] 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 } + fun exif(exif: JsonField) = apply { this.exif = exif } /** Object containing GPS information. */ fun gps(gps: Gps) = gps(JsonField.of(gps)) @@ -2956,16 +2947,16 @@ private constructor( fun gps(gps: JsonField) = apply { this.gps = gps } /** Object containing EXIF image information. */ - fun image(image: ExifImage) = image(JsonField.of(image)) + 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 [ExifImage] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported 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 } + fun image(image: JsonField) = apply { this.image = image } /** JSON object. */ fun interoperability(interoperability: Interoperability) = @@ -3087,70 +3078,2197 @@ private constructor( (makernote.asKnown().getOrNull()?.validity() ?: 0) + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) - class Makernote - @JsonCreator + /** Object containing Exif details. */ + class InnerExif private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + 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 = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Makernote]. */ + /** Returns a mutable builder for constructing an instance of [InnerExif]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Makernote]. */ + /** 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(makernote: Makernote) = apply { - additionalProperties = makernote.additionalProperties.toMutableMap() + 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 additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun apertureValue(apertureValue: Double) = + apertureValue(JsonField.of(apertureValue)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * 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 putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun colorSpace(colorSpace: Long) = colorSpace(JsonField.of(colorSpace)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun createDate(createDate: String) = createDate(JsonField.of(createDate)) /** - * Returns an immutable instance of [Makernote]. + * Sets [Builder.createDate] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * 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 build(): Makernote = Makernote(additionalProperties.toImmutable()) - } + fun createDate(createDate: JsonField) = apply { + this.createDate = createDate + } - private var validated: Boolean = false + fun customRendered(customRendered: Long) = + customRendered(JsonField.of(customRendered)) - fun validate(): Makernote = apply { - if (validated) { - return@apply + /** + * 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 @@ -3191,6 +5309,378 @@ private constructor( 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt index 7c22afd7..c88f4cbd 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt @@ -10,13 +10,9 @@ 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.ExifDetails -import com.imagekit.api.models.ExifImage -import com.imagekit.api.models.Gps -import com.imagekit.api.models.Interoperability -import com.imagekit.api.models.Thumbnail import java.util.Collections import java.util.Objects import java.util.Optional @@ -617,9 +613,9 @@ private constructor( class Exif private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, - private val image: JsonField, + private val image: JsonField, private val interoperability: JsonField, private val makernote: JsonField, private val thumbnail: JsonField, @@ -628,9 +624,9 @@ 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("image") @ExcludeMissing image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @ExcludeMissing interoperability: JsonField = JsonMissing.of(), @@ -648,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. @@ -664,7 +660,7 @@ private constructor( * @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") + fun image(): Optional = image.getOptional("image") /** * JSON object. @@ -694,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]. @@ -708,7 +704,7 @@ private constructor( * * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image /** * Returns the raw JSON value of [interoperability]. @@ -759,9 +755,9 @@ 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 image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() private var makernote: JsonField = JsonMissing.of() private var thumbnail: JsonField = JsonMissing.of() @@ -779,16 +775,16 @@ private constructor( } /** Object containing Exif details. */ - fun exif(exif: ExifDetails) = exif(JsonField.of(exif)) + 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 [ExifDetails] value instead. + * 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 } + fun exif(exif: JsonField) = apply { this.exif = exif } /** Object containing GPS information. */ fun gps(gps: Gps) = gps(JsonField.of(gps)) @@ -803,16 +799,16 @@ private constructor( fun gps(gps: JsonField) = apply { this.gps = gps } /** Object containing EXIF image information. */ - fun image(image: ExifImage) = image(JsonField.of(image)) + 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 [ExifImage] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported 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 } + fun image(image: JsonField) = apply { this.image = image } /** JSON object. */ fun interoperability(interoperability: Interoperability) = @@ -927,68 +923,2166 @@ private constructor( (makernote.asKnown().getOrNull()?.validity() ?: 0) + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) - class Makernote - @JsonCreator + /** Object containing Exif details. */ + class InnerExif private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + 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 = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Makernote]. */ + /** Returns a mutable builder for constructing an instance of [InnerExif]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Makernote]. */ + /** 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(makernote: Makernote) = apply { - additionalProperties = makernote.additionalProperties.toMutableMap() + 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 additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun apertureValue(apertureValue: Double) = + apertureValue(JsonField.of(apertureValue)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * 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 putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun colorSpace(colorSpace: Long) = colorSpace(JsonField.of(colorSpace)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + 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)) + /** - * Returns an immutable instance of [Makernote]. + * Sets [Builder.customRendered] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * 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 build(): Makernote = Makernote(additionalProperties.toImmutable()) - } + fun customRendered(customRendered: JsonField) = apply { + this.customRendered = customRendered + } - private var validated: Boolean = false + fun dateTimeOriginal(dateTimeOriginal: String) = + dateTimeOriginal(JsonField.of(dateTimeOriginal)) - fun validate(): Makernote = apply { + /** + * 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 } @@ -1029,6 +3123,376 @@ private constructor( 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt index 7d990582..cca25a2a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt @@ -10,13 +10,9 @@ 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.ExifDetails -import com.imagekit.api.models.ExifImage -import com.imagekit.api.models.Gps -import com.imagekit.api.models.Interoperability -import com.imagekit.api.models.Thumbnail import java.util.Collections import java.util.Objects import java.util.Optional @@ -615,9 +611,9 @@ private constructor( class Exif private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, - private val image: JsonField, + private val image: JsonField, private val interoperability: JsonField, private val makernote: JsonField, private val thumbnail: JsonField, @@ -626,9 +622,9 @@ 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("image") @ExcludeMissing image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @ExcludeMissing interoperability: JsonField = JsonMissing.of(), @@ -646,7 +642,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. @@ -662,7 +658,7 @@ private constructor( * @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") + fun image(): Optional = image.getOptional("image") /** * JSON object. @@ -692,7 +688,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]. @@ -706,7 +702,7 @@ private constructor( * * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image /** * Returns the raw JSON value of [interoperability]. @@ -757,9 +753,9 @@ 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 image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() private var makernote: JsonField = JsonMissing.of() private var thumbnail: JsonField = JsonMissing.of() @@ -777,16 +773,16 @@ private constructor( } /** Object containing Exif details. */ - fun exif(exif: ExifDetails) = exif(JsonField.of(exif)) + 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 [ExifDetails] value instead. + * 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 } + fun exif(exif: JsonField) = apply { this.exif = exif } /** Object containing GPS information. */ fun gps(gps: Gps) = gps(JsonField.of(gps)) @@ -801,16 +797,16 @@ private constructor( fun gps(gps: JsonField) = apply { this.gps = gps } /** Object containing EXIF image information. */ - fun image(image: ExifImage) = image(JsonField.of(image)) + 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 [ExifImage] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported 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 } + fun image(image: JsonField) = apply { this.image = image } /** JSON object. */ fun interoperability(interoperability: Interoperability) = @@ -925,68 +921,2166 @@ private constructor( (makernote.asKnown().getOrNull()?.validity() ?: 0) + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) - class Makernote - @JsonCreator + /** Object containing Exif details. */ + class InnerExif private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + 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 = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Makernote]. */ + /** Returns a mutable builder for constructing an instance of [InnerExif]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Makernote]. */ + /** 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(makernote: Makernote) = apply { - additionalProperties = makernote.additionalProperties.toMutableMap() + 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 additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun apertureValue(apertureValue: Double) = + apertureValue(JsonField.of(apertureValue)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * 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 putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun colorSpace(colorSpace: Long) = colorSpace(JsonField.of(colorSpace)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + 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)) + /** - * Returns an immutable instance of [Makernote]. + * Sets [Builder.customRendered] to an arbitrary JSON value. * - * Further updates to this [Builder] will not mutate the returned instance. + * 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 build(): Makernote = Makernote(additionalProperties.toImmutable()) - } + fun customRendered(customRendered: JsonField) = apply { + this.customRendered = customRendered + } - private var validated: Boolean = false + fun dateTimeOriginal(dateTimeOriginal: String) = + dateTimeOriginal(JsonField.of(dateTimeOriginal)) - fun validate(): Makernote = apply { + /** + * 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 } @@ -1027,6 +3121,376 @@ private constructor( 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 diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoDescriptionExtensionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoDescriptionExtensionTest.kt deleted file mode 100644 index 2d9a9c6b..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoDescriptionExtensionTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -// 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 AutoDescriptionExtensionTest { - - @Test - fun create() { - val autoDescriptionExtension = - AutoDescriptionExtension.builder() - .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) - .build() - - assertThat(autoDescriptionExtension.name()) - .isEqualTo(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val autoDescriptionExtension = - AutoDescriptionExtension.builder() - .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) - .build() - - val roundtrippedAutoDescriptionExtension = - jsonMapper.readValue( - jsonMapper.writeValueAsString(autoDescriptionExtension), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAutoDescriptionExtension).isEqualTo(autoDescriptionExtension) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoTaggingExtensionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoTaggingExtensionTest.kt deleted file mode 100644 index 35db3ae6..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AutoTaggingExtensionTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -// 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 AutoTaggingExtensionTest { - - @Test - fun create() { - val autoTaggingExtension = - AutoTaggingExtension.builder() - .maxTags(0L) - .minConfidence(0L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) - .build() - - assertThat(autoTaggingExtension.maxTags()).isEqualTo(0L) - assertThat(autoTaggingExtension.minConfidence()).isEqualTo(0L) - assertThat(autoTaggingExtension.name()) - .isEqualTo(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val autoTaggingExtension = - AutoTaggingExtension.builder() - .maxTags(0L) - .minConfidence(0L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) - .build() - - val roundtrippedAutoTaggingExtension = - jsonMapper.readValue( - jsonMapper.writeValueAsString(autoTaggingExtension), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAutoTaggingExtension).isEqualTo(autoTaggingExtension) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifDetailsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifDetailsTest.kt deleted file mode 100644 index d9751270..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifDetailsTest.kt +++ /dev/null @@ -1,113 +0,0 @@ -// 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 ExifDetailsTest { - - @Test - fun create() { - val exifDetails = - ExifDetails.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() - - assertThat(exifDetails.apertureValue()).contains(0.0) - assertThat(exifDetails.colorSpace()).contains(0L) - assertThat(exifDetails.createDate()).contains("CreateDate") - assertThat(exifDetails.customRendered()).contains(0L) - assertThat(exifDetails.dateTimeOriginal()).contains("DateTimeOriginal") - assertThat(exifDetails.exifImageHeight()).contains(0L) - assertThat(exifDetails.exifImageWidth()).contains(0L) - assertThat(exifDetails.exifVersion()).contains("ExifVersion") - assertThat(exifDetails.exposureCompensation()).contains(0.0) - assertThat(exifDetails.exposureMode()).contains(0L) - assertThat(exifDetails.exposureProgram()).contains(0L) - assertThat(exifDetails.exposureTime()).contains(0.0) - assertThat(exifDetails.flash()).contains(0L) - assertThat(exifDetails.flashpixVersion()).contains("FlashpixVersion") - assertThat(exifDetails.fNumber()).contains(0.0) - assertThat(exifDetails.focalLength()).contains(0L) - assertThat(exifDetails.focalPlaneResolutionUnit()).contains(0L) - assertThat(exifDetails.focalPlaneXResolution()).contains(0.0) - assertThat(exifDetails.focalPlaneYResolution()).contains(0.0) - assertThat(exifDetails.interopOffset()).contains(0L) - assertThat(exifDetails.iso()).contains(0L) - assertThat(exifDetails.meteringMode()).contains(0L) - assertThat(exifDetails.sceneCaptureType()).contains(0L) - assertThat(exifDetails.shutterSpeedValue()).contains(0.0) - assertThat(exifDetails.subSecTime()).contains("SubSecTime") - assertThat(exifDetails.whiteBalance()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val exifDetails = - ExifDetails.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() - - val roundtrippedExifDetails = - jsonMapper.readValue( - jsonMapper.writeValueAsString(exifDetails), - jacksonTypeRef(), - ) - - assertThat(roundtrippedExifDetails).isEqualTo(exifDetails) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifImageTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifImageTest.kt deleted file mode 100644 index ea48c88c..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExifImageTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -// 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 ExifImageTest { - - @Test - fun create() { - val exifImage = - ExifImage.builder() - .exifOffset(0L) - .gpsInfo(0L) - .make("Make") - .model("Model") - .modifyDate("ModifyDate") - .orientation(0L) - .resolutionUnit(0L) - .software("Software") - .xResolution(0L) - .yCbCrPositioning(0L) - .yResolution(0L) - .build() - - assertThat(exifImage.exifOffset()).contains(0L) - assertThat(exifImage.gpsInfo()).contains(0L) - assertThat(exifImage.make()).contains("Make") - assertThat(exifImage.model()).contains("Model") - assertThat(exifImage.modifyDate()).contains("ModifyDate") - assertThat(exifImage.orientation()).contains(0L) - assertThat(exifImage.resolutionUnit()).contains(0L) - assertThat(exifImage.software()).contains("Software") - assertThat(exifImage.xResolution()).contains(0L) - assertThat(exifImage.yCbCrPositioning()).contains(0L) - assertThat(exifImage.yResolution()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val exifImage = - ExifImage.builder() - .exifOffset(0L) - .gpsInfo(0L) - .make("Make") - .model("Model") - .modifyDate("ModifyDate") - .orientation(0L) - .resolutionUnit(0L) - .software("Software") - .xResolution(0L) - .yCbCrPositioning(0L) - .yResolution(0L) - .build() - - val roundtrippedExifImage = - jsonMapper.readValue( - jsonMapper.writeValueAsString(exifImage), - jacksonTypeRef(), - ) - - assertThat(roundtrippedExifImage).isEqualTo(exifImage) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GpsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GpsTest.kt deleted file mode 100644 index c26091c2..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GpsTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// 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 GpsTest { - - @Test - fun create() { - val gps = Gps.builder().addGpsVersionId(0L).build() - - assertThat(gps.gpsVersionId().getOrNull()).containsExactly(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val gps = Gps.builder().addGpsVersionId(0L).build() - - val roundtrippedGps = - jsonMapper.readValue(jsonMapper.writeValueAsString(gps), jacksonTypeRef()) - - assertThat(roundtrippedGps).isEqualTo(gps) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/InteroperabilityTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/InteroperabilityTest.kt deleted file mode 100644 index 369c5673..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/InteroperabilityTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -// 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 InteroperabilityTest { - - @Test - fun create() { - val interoperability = - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - - assertThat(interoperability.interopIndex()).contains("InteropIndex") - assertThat(interoperability.interopVersion()).contains("InteropVersion") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val interoperability = - Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - - val roundtrippedInteroperability = - jsonMapper.readValue( - jsonMapper.writeValueAsString(interoperability), - jacksonTypeRef(), - ) - - assertThat(roundtrippedInteroperability).isEqualTo(interoperability) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/RemovedotBgExtensionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/RemovedotBgExtensionTest.kt deleted file mode 100644 index 6f2e6cfa..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/RemovedotBgExtensionTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -// 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 RemovedotBgExtensionTest { - - @Test - fun create() { - val removedotBgExtension = - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) - .options( - RemovedotBgExtension.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - - assertThat(removedotBgExtension.name()).isEqualTo(RemovedotBgExtension.Name.REMOVE_BG) - assertThat(removedotBgExtension.options()) - .contains( - RemovedotBgExtension.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val removedotBgExtension = - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) - .options( - RemovedotBgExtension.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - - val roundtrippedRemovedotBgExtension = - jsonMapper.readValue( - jsonMapper.writeValueAsString(removedotBgExtension), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRemovedotBgExtension).isEqualTo(removedotBgExtension) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ThumbnailTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ThumbnailTest.kt deleted file mode 100644 index ee8a2afe..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ThumbnailTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -// 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 ThumbnailTest { - - @Test - fun create() { - val thumbnail = - Thumbnail.builder() - .compression(0L) - .resolutionUnit(0L) - .thumbnailLength(0L) - .thumbnailOffset(0L) - .xResolution(0L) - .yResolution(0L) - .build() - - assertThat(thumbnail.compression()).contains(0L) - assertThat(thumbnail.resolutionUnit()).contains(0L) - assertThat(thumbnail.thumbnailLength()).contains(0L) - assertThat(thumbnail.thumbnailOffset()).contains(0L) - assertThat(thumbnail.xResolution()).contains(0L) - assertThat(thumbnail.yResolution()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val thumbnail = - Thumbnail.builder() - .compression(0L) - .resolutionUnit(0L) - .thumbnailLength(0L) - .thumbnailOffset(0L) - .xResolution(0L) - .yResolution(0L) - .build() - - val roundtrippedThumbnail = - jsonMapper.readValue( - jsonMapper.writeValueAsString(thumbnail), - jacksonTypeRef(), - ) - - assertThat(roundtrippedThumbnail).isEqualTo(thumbnail) - } -} 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 dd31a8ad..f34d18bc 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,8 +4,6 @@ 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.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -28,10 +26,10 @@ internal class FileUploadParamsTest { ) .description("Running shoes") .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -41,10 +39,10 @@ internal class FileUploadParamsTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name(FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -112,10 +110,10 @@ internal class FileUploadParamsTest { ) .description("Running shoes") .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -125,10 +123,12 @@ internal class FileUploadParamsTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -208,10 +208,15 @@ internal class FileUploadParamsTest { MultipartField.of( listOf( FileUploadParams.Extension.ofRemovedotBg( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name + .REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension + .Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -221,10 +226,13 @@ internal class FileUploadParamsTest { .build() ), FileUploadParams.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ), ) 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 6462d1a1..99591ed1 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,11 +5,6 @@ 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.ExifDetails -import com.imagekit.api.models.ExifImage -import com.imagekit.api.models.Gps -import com.imagekit.api.models.Interoperability -import com.imagekit.api.models.Thumbnail import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -65,7 +60,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - ExifDetails.builder() + FileUploadResponse.Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -94,9 +89,13 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + FileUploadResponse.Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -111,7 +110,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - Interoperability.builder() + FileUploadResponse.Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -122,7 +121,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + FileUploadResponse.Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -202,7 +201,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - ExifDetails.builder() + FileUploadResponse.Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -231,9 +230,13 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + FileUploadResponse.Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -248,7 +251,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - Interoperability.builder() + FileUploadResponse.Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -259,7 +262,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + FileUploadResponse.Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -342,7 +345,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - ExifDetails.builder() + FileUploadResponse.Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -371,9 +374,13 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + FileUploadResponse.Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -388,7 +395,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - Interoperability.builder() + FileUploadResponse.Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -399,7 +406,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + FileUploadResponse.Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) 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 ea0e2fcd..7a30086a 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,9 +3,6 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.AutoDescriptionExtension -import com.imagekit.api.models.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,10 +26,20 @@ internal class FileUpdateParamsTest { .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -42,22 +49,43 @@ internal class FileUpdateParamsTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - AutoDescriptionExtension.builder() - .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) .build() ), ) @@ -98,10 +126,20 @@ internal class FileUpdateParamsTest { .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -111,22 +149,43 @@ internal class FileUpdateParamsTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - AutoDescriptionExtension.builder() - .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) .build() ), ) @@ -156,10 +215,20 @@ internal class FileUpdateParamsTest { .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -169,22 +238,43 @@ internal class FileUpdateParamsTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - AutoDescriptionExtension.builder() - .name(AutoDescriptionExtension.Name.AI_AUTO_DESCRIPTION) + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) .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 035c3a7e..212f5dfc 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,8 +4,6 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,10 +27,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -42,10 +40,10 @@ internal class FileUploadParamsTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name(FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ) .folder("folder") @@ -116,10 +114,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -129,10 +127,12 @@ internal class FileUploadParamsTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -215,10 +215,15 @@ internal class FileUploadParamsTest { MultipartField.of( listOf( FileUploadParams.Extension.ofRemovedotBg( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name + .REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension + .Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -228,10 +233,13 @@ internal class FileUploadParamsTest { .build() ), FileUploadParams.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ), ) 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 f387763f..c8335d97 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,11 +5,6 @@ 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.ExifDetails -import com.imagekit.api.models.ExifImage -import com.imagekit.api.models.Gps -import com.imagekit.api.models.Interoperability -import com.imagekit.api.models.Thumbnail import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -65,7 +60,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - ExifDetails.builder() + FileUploadResponse.Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -94,9 +89,13 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + FileUploadResponse.Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -111,7 +110,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - Interoperability.builder() + FileUploadResponse.Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -122,7 +121,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + FileUploadResponse.Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -202,7 +201,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - ExifDetails.builder() + FileUploadResponse.Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -231,9 +230,13 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + FileUploadResponse.Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -248,7 +251,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - Interoperability.builder() + FileUploadResponse.Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -259,7 +262,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + FileUploadResponse.Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -342,7 +345,7 @@ internal class FileUploadResponseTest { .exif( FileUploadResponse.Metadata.Exif.builder() .exif( - ExifDetails.builder() + FileUploadResponse.Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -371,9 +374,13 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + FileUploadResponse.Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + FileUploadResponse.Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -388,7 +395,7 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - Interoperability.builder() + FileUploadResponse.Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -399,7 +406,7 @@ internal class FileUploadResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + FileUploadResponse.Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt index cd09a583..f889b1e1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt @@ -5,11 +5,6 @@ package com.imagekit.api.models.files.metadata import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.ExifDetails -import com.imagekit.api.models.ExifImage -import com.imagekit.api.models.Gps -import com.imagekit.api.models.Interoperability -import com.imagekit.api.models.Thumbnail import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -26,7 +21,7 @@ internal class MetadataGetFromUrlResponseTest { .exif( MetadataGetFromUrlResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetFromUrlResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -55,9 +50,13 @@ internal class MetadataGetFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + MetadataGetFromUrlResponse.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + MetadataGetFromUrlResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -72,7 +71,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetFromUrlResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -83,7 +82,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetFromUrlResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -113,7 +112,7 @@ internal class MetadataGetFromUrlResponseTest { .contains( MetadataGetFromUrlResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetFromUrlResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -142,9 +141,9 @@ internal class MetadataGetFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps(MetadataGetFromUrlResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - ExifImage.builder() + MetadataGetFromUrlResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -159,7 +158,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetFromUrlResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -170,7 +169,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetFromUrlResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -204,7 +203,7 @@ internal class MetadataGetFromUrlResponseTest { .exif( MetadataGetFromUrlResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetFromUrlResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -233,9 +232,13 @@ internal class MetadataGetFromUrlResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps( + MetadataGetFromUrlResponse.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) .image( - ExifImage.builder() + MetadataGetFromUrlResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -250,7 +253,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetFromUrlResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -261,7 +264,7 @@ internal class MetadataGetFromUrlResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetFromUrlResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt index f4d37a81..28ff25c9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt @@ -5,11 +5,6 @@ package com.imagekit.api.models.files.metadata import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.ExifDetails -import com.imagekit.api.models.ExifImage -import com.imagekit.api.models.Gps -import com.imagekit.api.models.Interoperability -import com.imagekit.api.models.Thumbnail import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -26,7 +21,7 @@ internal class MetadataGetResponseTest { .exif( MetadataGetResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -55,9 +50,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - ExifImage.builder() + MetadataGetResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -72,7 +67,7 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -83,7 +78,7 @@ internal class MetadataGetResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -113,7 +108,7 @@ internal class MetadataGetResponseTest { .contains( MetadataGetResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -142,9 +137,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - ExifImage.builder() + MetadataGetResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -159,7 +154,7 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -170,7 +165,7 @@ internal class MetadataGetResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -204,7 +199,7 @@ internal class MetadataGetResponseTest { .exif( MetadataGetResponse.Exif.builder() .exif( - ExifDetails.builder() + MetadataGetResponse.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -233,9 +228,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(Gps.builder().addGpsVersionId(0L).build()) + .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - ExifImage.builder() + MetadataGetResponse.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -250,7 +245,7 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - Interoperability.builder() + MetadataGetResponse.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() @@ -261,7 +256,7 @@ internal class MetadataGetResponseTest { .build() ) .thumbnail( - Thumbnail.builder() + MetadataGetResponse.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) 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 fb415d48..638f2e35 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,8 +22,6 @@ 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.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry @@ -89,10 +87,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -102,10 +103,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -198,10 +202,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -211,10 +218,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -307,10 +317,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -320,10 +333,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -416,10 +432,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -429,10 +448,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -525,10 +547,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -538,10 +563,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -634,10 +662,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -647,10 +678,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -743,10 +777,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -756,10 +793,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -852,10 +892,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -865,10 +908,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -961,10 +1007,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -974,10 +1023,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -1070,10 +1122,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1083,10 +1138,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -1179,10 +1237,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1192,10 +1253,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -1288,10 +1352,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1301,10 +1368,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -1397,10 +1467,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1410,10 +1483,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -1506,10 +1582,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1519,10 +1598,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -1615,10 +1697,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1628,10 +1713,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -1724,10 +1812,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1737,10 +1828,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") @@ -1831,10 +1925,13 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name( + FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1844,10 +1941,13 @@ internal class ErrorHandlingTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .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 5379b6f9..4a8e74c3 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,8 +15,6 @@ 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.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled @@ -61,10 +59,10 @@ internal class ServiceParamsTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -74,10 +72,12 @@ internal class ServiceParamsTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING + ) .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 bba8af8f..a1b5dc1e 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,9 +5,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.AutoDescriptionExtension -import com.imagekit.api.models.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -48,10 +45,20 @@ internal class FileServiceAsyncTest { .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -61,24 +68,43 @@ internal class FileServiceAsyncTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension .ofAutoDescription( - AutoDescriptionExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() .name( - AutoDescriptionExtension.Name + FileUpdateParams.Body.UpdateFileDetails + .Extension + .AutoDescriptionExtension + .Name .AI_AUTO_DESCRIPTION ) .build() @@ -230,10 +256,10 @@ internal class FileServiceAsyncTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -243,10 +269,13 @@ internal class FileServiceAsyncTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .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 25e01ec5..73140c41 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,8 +5,6 @@ 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.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -42,10 +40,10 @@ internal class FileServiceAsyncTest { ) .description("Running shoes") .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -55,10 +53,13 @@ internal class FileServiceAsyncTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .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 b2a540ce..8f70775a 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,9 +5,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.AutoDescriptionExtension -import com.imagekit.api.models.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -48,10 +45,20 @@ internal class FileServiceTest { .extensions( listOf( FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) .options( - RemovedotBgExtension.Options.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -61,24 +68,43 @@ internal class FileServiceTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - AutoTaggingExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() .maxTags(10L) .minConfidence(80L) - .name(AutoTaggingExtension.Name.AWS_AUTO_TAGGING) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension .ofAutoDescription( - AutoDescriptionExtension.builder() + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() .name( - AutoDescriptionExtension.Name + FileUpdateParams.Body.UpdateFileDetails + .Extension + .AutoDescriptionExtension + .Name .AI_AUTO_DESCRIPTION ) .build() @@ -223,10 +249,10 @@ internal class FileServiceTest { .description("Running shoes") .expire(0L) .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -236,10 +262,13 @@ internal class FileServiceTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .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 f738079e..ea4d43ff 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,8 +5,6 @@ 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.AutoTaggingExtension -import com.imagekit.api.models.RemovedotBgExtension import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -42,10 +40,10 @@ internal class FileServiceTest { ) .description("Running shoes") .addExtension( - RemovedotBgExtension.builder() - .name(RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemovedotBgExtension.builder() + .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) .options( - RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemovedotBgExtension.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -55,10 +53,13 @@ internal class FileServiceTest { .build() ) .addExtension( - AutoTaggingExtension.builder() + FileUploadParams.Extension.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name(AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) .build() ) .folder("folder") From 984d490c51cc382093fa3c5151cf158fbf1eee8e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:14:36 +0000 Subject: [PATCH 016/125] feat(api): manual updates --- .stats.yml | 6 +- .../accounts/origins/OriginCreateResponse.kt | 239 +++++++++++++++--- .../accounts/origins/OriginGetResponse.kt | 239 +++++++++++++++--- .../accounts/origins/OriginListResponse.kt | 239 +++++++++++++++--- .../accounts/origins/OriginUpdateResponse.kt | 239 +++++++++++++++--- .../origins/OriginCreateResponseTest.kt | 28 +- .../accounts/origins/OriginGetResponseTest.kt | 28 +- .../origins/OriginListResponseTest.kt | 28 +- .../origins/OriginUpdateResponseTest.kt | 28 +- 9 files changed, 855 insertions(+), 219 deletions(-) diff --git a/.stats.yml b/.stats.yml index 254a6c30..91f8d8ce 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-584c2ccf3fc1a3ff3abf26b8d3dace2398d0f9ed6f20e4c411a13a81febb5e98.yml -openapi_spec_hash: 14d1614ea3903d6b53f26e135c9cae81 -config_hash: e2f52106d0ea435659ba3ff7074406f5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-a1cf25a2c075ef11eea56c771578a9c36aa5f37677389988c9fb0c776399bc1b.yml +openapi_spec_hash: 8fed9fded4a79267764133be71b296e6 +config_hash: e212bc0b32d2d9fe583f77bccfae0375 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt index 5155af8b..d9c5a23b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt @@ -385,7 +385,7 @@ private constructor( private val bucket: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -399,7 +399,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -449,8 +449,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -498,6 +503,13 @@ private constructor( */ @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 [type]. * @@ -552,7 +564,7 @@ private constructor( private var bucket: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -624,7 +636,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -712,6 +733,7 @@ private constructor( bucket() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -737,6 +759,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -903,7 +926,7 @@ private constructor( private val endpoint: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val s3ForcePathStyle: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, @@ -921,7 +944,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("s3ForcePathStyle") @ExcludeMissing s3ForcePathStyle: JsonField = JsonMissing.of(), @@ -984,8 +1007,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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? @@ -1048,6 +1076,13 @@ private constructor( */ @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]. * @@ -1115,7 +1150,7 @@ private constructor( private var endpoint: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var s3ForcePathStyle: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() @@ -1202,7 +1237,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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) = @@ -1310,6 +1354,7 @@ private constructor( endpoint() includeCanonicalHeader() name() + prefix() s3ForcePathStyle() type().validate() baseUrlForCanonicalHeader() @@ -1337,6 +1382,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -1507,7 +1553,7 @@ private constructor( private val bucket: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -1521,7 +1567,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -1571,8 +1617,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -1620,6 +1671,13 @@ private constructor( */ @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 [type]. * @@ -1674,7 +1732,7 @@ private constructor( private var bucket: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1746,7 +1804,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -1834,6 +1901,7 @@ private constructor( bucket() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -1859,6 +1927,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -2021,7 +2090,7 @@ private constructor( class WebFolder private constructor( private val id: JsonField, - private val baseUrl: JsonValue, + private val baseUrl: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, @@ -2033,7 +2102,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("forwardHostHeaderToOrigin") @ExcludeMissing forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), @@ -2065,8 +2134,13 @@ private constructor( */ fun id(): String = id.getRequired("id") - /** Root URL for the web folder origin. */ - @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = baseUrl + /** + * 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? @@ -2116,6 +2190,13 @@ private constructor( */ @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]. * @@ -2194,7 +2275,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var baseUrl: JsonValue? = null + private var baseUrl: JsonField? = null private var forwardHostHeaderToOrigin: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null @@ -2230,7 +2311,16 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Root URL for the web folder origin. */ - fun baseUrl(baseUrl: JsonValue) = apply { this.baseUrl = baseUrl } + 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) = @@ -2357,6 +2447,7 @@ private constructor( } id() + baseUrl() forwardHostHeaderToOrigin() includeCanonicalHeader() name() @@ -2382,6 +2473,7 @@ private constructor( @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) + @@ -3006,7 +3098,7 @@ private constructor( private val clientEmail: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3023,7 +3115,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -3078,7 +3170,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * @throws ImageKitInvalidDataException if 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -3135,6 +3231,13 @@ private constructor( */ @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 [type]. * @@ -3191,7 +3294,7 @@ private constructor( private var clientEmail: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3275,7 +3378,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -3366,6 +3478,7 @@ private constructor( clientEmail() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -3392,6 +3505,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -3560,7 +3674,7 @@ private constructor( private val container: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3579,7 +3693,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -3634,7 +3748,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * @throws ImageKitInvalidDataException if 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -3691,6 +3809,13 @@ private constructor( */ @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 [type]. * @@ -3747,7 +3872,7 @@ private constructor( private var container: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3831,7 +3956,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -3922,6 +4056,7 @@ private constructor( container() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -3948,6 +4083,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -4112,7 +4248,7 @@ private constructor( class AkeneoPim private constructor( private val id: JsonField, - private val baseUrl: JsonValue, + private val baseUrl: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, private val type: JsonField, @@ -4123,7 +4259,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("includeCanonicalHeader") @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @@ -4151,8 +4287,13 @@ private constructor( */ fun id(): String = id.getRequired("id") - /** Akeneo instance base URL. */ - @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = baseUrl + /** + * 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. @@ -4193,6 +4334,13 @@ private constructor( */ @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]. * @@ -4260,7 +4408,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var baseUrl: JsonValue? = null + private var baseUrl: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var type: JsonField? = null @@ -4294,7 +4442,16 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: JsonValue) = apply { this.baseUrl = baseUrl } + 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) = @@ -4404,6 +4561,7 @@ private constructor( } id() + baseUrl() includeCanonicalHeader() name() type().validate() @@ -4428,6 +4586,7 @@ private constructor( @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.asKnown().getOrNull()?.validity() ?: 0) + diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt index a087c751..0a4e045b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt @@ -382,7 +382,7 @@ private constructor( private val bucket: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -396,7 +396,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -446,8 +446,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -495,6 +500,13 @@ private constructor( */ @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 [type]. * @@ -549,7 +561,7 @@ private constructor( private var bucket: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -621,7 +633,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -709,6 +730,7 @@ private constructor( bucket() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -734,6 +756,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -900,7 +923,7 @@ private constructor( private val endpoint: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val s3ForcePathStyle: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, @@ -918,7 +941,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("s3ForcePathStyle") @ExcludeMissing s3ForcePathStyle: JsonField = JsonMissing.of(), @@ -981,8 +1004,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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? @@ -1045,6 +1073,13 @@ private constructor( */ @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]. * @@ -1112,7 +1147,7 @@ private constructor( private var endpoint: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var s3ForcePathStyle: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() @@ -1199,7 +1234,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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) = @@ -1307,6 +1351,7 @@ private constructor( endpoint() includeCanonicalHeader() name() + prefix() s3ForcePathStyle() type().validate() baseUrlForCanonicalHeader() @@ -1334,6 +1379,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -1504,7 +1550,7 @@ private constructor( private val bucket: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -1518,7 +1564,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -1568,8 +1614,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -1617,6 +1668,13 @@ private constructor( */ @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 [type]. * @@ -1671,7 +1729,7 @@ private constructor( private var bucket: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1743,7 +1801,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -1831,6 +1898,7 @@ private constructor( bucket() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -1856,6 +1924,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -2018,7 +2087,7 @@ private constructor( class WebFolder private constructor( private val id: JsonField, - private val baseUrl: JsonValue, + private val baseUrl: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, @@ -2030,7 +2099,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("forwardHostHeaderToOrigin") @ExcludeMissing forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), @@ -2062,8 +2131,13 @@ private constructor( */ fun id(): String = id.getRequired("id") - /** Root URL for the web folder origin. */ - @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = baseUrl + /** + * 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? @@ -2113,6 +2187,13 @@ private constructor( */ @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]. * @@ -2191,7 +2272,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var baseUrl: JsonValue? = null + private var baseUrl: JsonField? = null private var forwardHostHeaderToOrigin: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null @@ -2227,7 +2308,16 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Root URL for the web folder origin. */ - fun baseUrl(baseUrl: JsonValue) = apply { this.baseUrl = baseUrl } + 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) = @@ -2354,6 +2444,7 @@ private constructor( } id() + baseUrl() forwardHostHeaderToOrigin() includeCanonicalHeader() name() @@ -2379,6 +2470,7 @@ private constructor( @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) + @@ -3003,7 +3095,7 @@ private constructor( private val clientEmail: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3020,7 +3112,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -3075,7 +3167,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * @throws ImageKitInvalidDataException if 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -3132,6 +3228,13 @@ private constructor( */ @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 [type]. * @@ -3188,7 +3291,7 @@ private constructor( private var clientEmail: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3272,7 +3375,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -3363,6 +3475,7 @@ private constructor( clientEmail() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -3389,6 +3502,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -3557,7 +3671,7 @@ private constructor( private val container: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3576,7 +3690,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -3631,7 +3745,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * @throws ImageKitInvalidDataException if 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -3688,6 +3806,13 @@ private constructor( */ @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 [type]. * @@ -3744,7 +3869,7 @@ private constructor( private var container: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3828,7 +3953,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -3919,6 +4053,7 @@ private constructor( container() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -3945,6 +4080,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -4109,7 +4245,7 @@ private constructor( class AkeneoPim private constructor( private val id: JsonField, - private val baseUrl: JsonValue, + private val baseUrl: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, private val type: JsonField, @@ -4120,7 +4256,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("includeCanonicalHeader") @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @@ -4148,8 +4284,13 @@ private constructor( */ fun id(): String = id.getRequired("id") - /** Akeneo instance base URL. */ - @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = baseUrl + /** + * 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. @@ -4190,6 +4331,13 @@ private constructor( */ @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]. * @@ -4257,7 +4405,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var baseUrl: JsonValue? = null + private var baseUrl: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var type: JsonField? = null @@ -4291,7 +4439,16 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: JsonValue) = apply { this.baseUrl = baseUrl } + 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) = @@ -4401,6 +4558,7 @@ private constructor( } id() + baseUrl() includeCanonicalHeader() name() type().validate() @@ -4425,6 +4583,7 @@ private constructor( @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.asKnown().getOrNull()?.validity() ?: 0) + diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt index bc9bec7b..8bc89a12 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt @@ -382,7 +382,7 @@ private constructor( private val bucket: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -396,7 +396,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -446,8 +446,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -495,6 +500,13 @@ private constructor( */ @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 [type]. * @@ -549,7 +561,7 @@ private constructor( private var bucket: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -621,7 +633,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -709,6 +730,7 @@ private constructor( bucket() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -734,6 +756,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -900,7 +923,7 @@ private constructor( private val endpoint: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val s3ForcePathStyle: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, @@ -918,7 +941,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("s3ForcePathStyle") @ExcludeMissing s3ForcePathStyle: JsonField = JsonMissing.of(), @@ -981,8 +1004,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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? @@ -1045,6 +1073,13 @@ private constructor( */ @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]. * @@ -1112,7 +1147,7 @@ private constructor( private var endpoint: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var s3ForcePathStyle: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() @@ -1199,7 +1234,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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) = @@ -1307,6 +1351,7 @@ private constructor( endpoint() includeCanonicalHeader() name() + prefix() s3ForcePathStyle() type().validate() baseUrlForCanonicalHeader() @@ -1334,6 +1379,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -1504,7 +1550,7 @@ private constructor( private val bucket: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -1518,7 +1564,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -1568,8 +1614,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -1617,6 +1668,13 @@ private constructor( */ @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 [type]. * @@ -1671,7 +1729,7 @@ private constructor( private var bucket: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1743,7 +1801,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -1831,6 +1898,7 @@ private constructor( bucket() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -1856,6 +1924,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -2018,7 +2087,7 @@ private constructor( class WebFolder private constructor( private val id: JsonField, - private val baseUrl: JsonValue, + private val baseUrl: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, @@ -2030,7 +2099,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("forwardHostHeaderToOrigin") @ExcludeMissing forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), @@ -2062,8 +2131,13 @@ private constructor( */ fun id(): String = id.getRequired("id") - /** Root URL for the web folder origin. */ - @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = baseUrl + /** + * 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? @@ -2113,6 +2187,13 @@ private constructor( */ @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]. * @@ -2191,7 +2272,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var baseUrl: JsonValue? = null + private var baseUrl: JsonField? = null private var forwardHostHeaderToOrigin: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null @@ -2227,7 +2308,16 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Root URL for the web folder origin. */ - fun baseUrl(baseUrl: JsonValue) = apply { this.baseUrl = baseUrl } + 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) = @@ -2354,6 +2444,7 @@ private constructor( } id() + baseUrl() forwardHostHeaderToOrigin() includeCanonicalHeader() name() @@ -2379,6 +2470,7 @@ private constructor( @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) + @@ -3003,7 +3095,7 @@ private constructor( private val clientEmail: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3020,7 +3112,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -3075,7 +3167,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * @throws ImageKitInvalidDataException if 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -3132,6 +3228,13 @@ private constructor( */ @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 [type]. * @@ -3188,7 +3291,7 @@ private constructor( private var clientEmail: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3272,7 +3375,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -3363,6 +3475,7 @@ private constructor( clientEmail() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -3389,6 +3502,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -3557,7 +3671,7 @@ private constructor( private val container: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3576,7 +3690,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -3631,7 +3745,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * @throws ImageKitInvalidDataException if 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -3688,6 +3806,13 @@ private constructor( */ @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 [type]. * @@ -3744,7 +3869,7 @@ private constructor( private var container: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3828,7 +3953,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -3919,6 +4053,7 @@ private constructor( container() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -3945,6 +4080,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -4109,7 +4245,7 @@ private constructor( class AkeneoPim private constructor( private val id: JsonField, - private val baseUrl: JsonValue, + private val baseUrl: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, private val type: JsonField, @@ -4120,7 +4256,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("includeCanonicalHeader") @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @@ -4148,8 +4284,13 @@ private constructor( */ fun id(): String = id.getRequired("id") - /** Akeneo instance base URL. */ - @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = baseUrl + /** + * 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. @@ -4190,6 +4331,13 @@ private constructor( */ @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]. * @@ -4257,7 +4405,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var baseUrl: JsonValue? = null + private var baseUrl: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var type: JsonField? = null @@ -4291,7 +4439,16 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: JsonValue) = apply { this.baseUrl = baseUrl } + 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) = @@ -4401,6 +4558,7 @@ private constructor( } id() + baseUrl() includeCanonicalHeader() name() type().validate() @@ -4425,6 +4583,7 @@ private constructor( @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.asKnown().getOrNull()?.validity() ?: 0) + diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt index baa71f32..33953080 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt @@ -385,7 +385,7 @@ private constructor( private val bucket: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -399,7 +399,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -449,8 +449,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -498,6 +503,13 @@ private constructor( */ @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 [type]. * @@ -552,7 +564,7 @@ private constructor( private var bucket: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -624,7 +636,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -712,6 +733,7 @@ private constructor( bucket() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -737,6 +759,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -903,7 +926,7 @@ private constructor( private val endpoint: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val s3ForcePathStyle: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, @@ -921,7 +944,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("s3ForcePathStyle") @ExcludeMissing s3ForcePathStyle: JsonField = JsonMissing.of(), @@ -984,8 +1007,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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? @@ -1048,6 +1076,13 @@ private constructor( */ @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]. * @@ -1115,7 +1150,7 @@ private constructor( private var endpoint: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var s3ForcePathStyle: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() @@ -1202,7 +1237,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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) = @@ -1310,6 +1354,7 @@ private constructor( endpoint() includeCanonicalHeader() name() + prefix() s3ForcePathStyle() type().validate() baseUrlForCanonicalHeader() @@ -1337,6 +1382,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -1507,7 +1553,7 @@ private constructor( private val bucket: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -1521,7 +1567,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -1571,8 +1617,13 @@ private constructor( */ fun name(): String = name.getRequired("name") - /** Path prefix inside the bucket. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -1620,6 +1671,13 @@ private constructor( */ @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 [type]. * @@ -1674,7 +1732,7 @@ private constructor( private var bucket: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1746,7 +1804,16 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** Path prefix inside the bucket. */ - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -1834,6 +1901,7 @@ private constructor( bucket() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -1859,6 +1927,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -2021,7 +2090,7 @@ private constructor( class WebFolder private constructor( private val id: JsonField, - private val baseUrl: JsonValue, + private val baseUrl: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, @@ -2033,7 +2102,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("forwardHostHeaderToOrigin") @ExcludeMissing forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), @@ -2065,8 +2134,13 @@ private constructor( */ fun id(): String = id.getRequired("id") - /** Root URL for the web folder origin. */ - @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = baseUrl + /** + * 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? @@ -2116,6 +2190,13 @@ private constructor( */ @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]. * @@ -2194,7 +2275,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var baseUrl: JsonValue? = null + private var baseUrl: JsonField? = null private var forwardHostHeaderToOrigin: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null @@ -2230,7 +2311,16 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Root URL for the web folder origin. */ - fun baseUrl(baseUrl: JsonValue) = apply { this.baseUrl = baseUrl } + 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) = @@ -2357,6 +2447,7 @@ private constructor( } id() + baseUrl() forwardHostHeaderToOrigin() includeCanonicalHeader() name() @@ -2382,6 +2473,7 @@ private constructor( @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) + @@ -3006,7 +3098,7 @@ private constructor( private val clientEmail: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3023,7 +3115,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -3078,7 +3170,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * @throws ImageKitInvalidDataException if 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -3135,6 +3231,13 @@ private constructor( */ @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 [type]. * @@ -3191,7 +3294,7 @@ private constructor( private var clientEmail: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3275,7 +3378,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -3366,6 +3478,7 @@ private constructor( clientEmail() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -3392,6 +3505,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -3560,7 +3674,7 @@ private constructor( private val container: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonValue, + private val prefix: JsonField, private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3579,7 +3693,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonValue = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing @@ -3634,7 +3748,11 @@ private constructor( */ fun name(): String = name.getRequired("name") - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonValue = prefix + /** + * @throws ImageKitInvalidDataException if 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") /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is @@ -3691,6 +3809,13 @@ private constructor( */ @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 [type]. * @@ -3747,7 +3872,7 @@ private constructor( private var container: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonValue? = null + private var prefix: JsonField? = null private var type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3831,7 +3956,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: JsonValue) = apply { this.prefix = prefix } + 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 type(type: Type) = type(JsonField.of(type)) @@ -3922,6 +4056,7 @@ private constructor( container() includeCanonicalHeader() name() + prefix() type().validate() baseUrlForCanonicalHeader() validated = true @@ -3948,6 +4083,7 @@ private constructor( (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.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -4112,7 +4248,7 @@ private constructor( class AkeneoPim private constructor( private val id: JsonField, - private val baseUrl: JsonValue, + private val baseUrl: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, private val type: JsonField, @@ -4123,7 +4259,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("includeCanonicalHeader") @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @@ -4151,8 +4287,13 @@ private constructor( */ fun id(): String = id.getRequired("id") - /** Akeneo instance base URL. */ - @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonValue = baseUrl + /** + * 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. @@ -4193,6 +4334,13 @@ private constructor( */ @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]. * @@ -4260,7 +4408,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var baseUrl: JsonValue? = null + private var baseUrl: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var type: JsonField? = null @@ -4294,7 +4442,16 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: JsonValue) = apply { this.baseUrl = baseUrl } + 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) = @@ -4404,6 +4561,7 @@ private constructor( } id() + baseUrl() includeCanonicalHeader() name() type().validate() @@ -4428,6 +4586,7 @@ private constructor( @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.asKnown().getOrNull()?.validity() ?: 0) + diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt index f11438ad..2b96f081 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt @@ -22,7 +22,7 @@ internal class OriginCreateResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginCreateResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -49,7 +49,7 @@ internal class OriginCreateResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginCreateResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -73,7 +73,7 @@ internal class OriginCreateResponseTest { .endpoint("https://s3.eu-central-1.wasabisys.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .s3ForcePathStyle(true) .type(OriginCreateResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") @@ -102,7 +102,7 @@ internal class OriginCreateResponseTest { .endpoint("https://s3.eu-central-1.wasabisys.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .s3ForcePathStyle(true) .type(OriginCreateResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") @@ -126,7 +126,7 @@ internal class OriginCreateResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginCreateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -153,7 +153,7 @@ internal class OriginCreateResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginCreateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -173,7 +173,7 @@ internal class OriginCreateResponseTest { val webFolder = OriginCreateResponse.WebFolder.builder() .id("id") - .baseUrl(JsonValue.from("https://images.example.com/assets")) + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") @@ -200,7 +200,7 @@ internal class OriginCreateResponseTest { OriginCreateResponse.ofWebFolder( OriginCreateResponse.WebFolder.builder() .id("id") - .baseUrl(JsonValue.from("https://images.example.com/assets")) + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") @@ -273,7 +273,7 @@ internal class OriginCreateResponseTest { .clientEmail("service-account@project.iam.gserviceaccount.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("products")) + .prefix("products") .type(OriginCreateResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -302,7 +302,7 @@ internal class OriginCreateResponseTest { .clientEmail("service-account@project.iam.gserviceaccount.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("products")) + .prefix("products") .type(OriginCreateResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -326,7 +326,7 @@ internal class OriginCreateResponseTest { .container("images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("uploads")) + .prefix("uploads") .type(OriginCreateResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -354,7 +354,7 @@ internal class OriginCreateResponseTest { .container("images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("uploads")) + .prefix("uploads") .type(OriginCreateResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -374,7 +374,7 @@ internal class OriginCreateResponseTest { val akeneoPim = OriginCreateResponse.AkeneoPim.builder() .id("id") - .baseUrl(JsonValue.from("https://akeneo.company.com")) + .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") .type(OriginCreateResponse.AkeneoPim.Type.AKENEO_PIM) @@ -400,7 +400,7 @@ internal class OriginCreateResponseTest { OriginCreateResponse.ofAkeneoPim( OriginCreateResponse.AkeneoPim.builder() .id("id") - .baseUrl(JsonValue.from("https://akeneo.company.com")) + .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") .type(OriginCreateResponse.AkeneoPim.Type.AKENEO_PIM) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt index f248c20d..214e8413 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt @@ -22,7 +22,7 @@ internal class OriginGetResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginGetResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -49,7 +49,7 @@ internal class OriginGetResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginGetResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -73,7 +73,7 @@ internal class OriginGetResponseTest { .endpoint("https://s3.eu-central-1.wasabisys.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .s3ForcePathStyle(true) .type(OriginGetResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") @@ -102,7 +102,7 @@ internal class OriginGetResponseTest { .endpoint("https://s3.eu-central-1.wasabisys.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .s3ForcePathStyle(true) .type(OriginGetResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") @@ -126,7 +126,7 @@ internal class OriginGetResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginGetResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -153,7 +153,7 @@ internal class OriginGetResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginGetResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -173,7 +173,7 @@ internal class OriginGetResponseTest { val webFolder = OriginGetResponse.WebFolder.builder() .id("id") - .baseUrl(JsonValue.from("https://images.example.com/assets")) + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") @@ -200,7 +200,7 @@ internal class OriginGetResponseTest { OriginGetResponse.ofWebFolder( OriginGetResponse.WebFolder.builder() .id("id") - .baseUrl(JsonValue.from("https://images.example.com/assets")) + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") @@ -273,7 +273,7 @@ internal class OriginGetResponseTest { .clientEmail("service-account@project.iam.gserviceaccount.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("products")) + .prefix("products") .type(OriginGetResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -301,7 +301,7 @@ internal class OriginGetResponseTest { .clientEmail("service-account@project.iam.gserviceaccount.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("products")) + .prefix("products") .type(OriginGetResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -325,7 +325,7 @@ internal class OriginGetResponseTest { .container("images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("uploads")) + .prefix("uploads") .type(OriginGetResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -353,7 +353,7 @@ internal class OriginGetResponseTest { .container("images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("uploads")) + .prefix("uploads") .type(OriginGetResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -373,7 +373,7 @@ internal class OriginGetResponseTest { val akeneoPim = OriginGetResponse.AkeneoPim.builder() .id("id") - .baseUrl(JsonValue.from("https://akeneo.company.com")) + .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") .type(OriginGetResponse.AkeneoPim.Type.AKENEO_PIM) @@ -399,7 +399,7 @@ internal class OriginGetResponseTest { OriginGetResponse.ofAkeneoPim( OriginGetResponse.AkeneoPim.builder() .id("id") - .baseUrl(JsonValue.from("https://akeneo.company.com")) + .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") .type(OriginGetResponse.AkeneoPim.Type.AKENEO_PIM) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt index 7763d3a9..36eae79e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt @@ -22,7 +22,7 @@ internal class OriginListResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginListResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -49,7 +49,7 @@ internal class OriginListResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginListResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -73,7 +73,7 @@ internal class OriginListResponseTest { .endpoint("https://s3.eu-central-1.wasabisys.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .s3ForcePathStyle(true) .type(OriginListResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") @@ -102,7 +102,7 @@ internal class OriginListResponseTest { .endpoint("https://s3.eu-central-1.wasabisys.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .s3ForcePathStyle(true) .type(OriginListResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") @@ -126,7 +126,7 @@ internal class OriginListResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginListResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -153,7 +153,7 @@ internal class OriginListResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginListResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -173,7 +173,7 @@ internal class OriginListResponseTest { val webFolder = OriginListResponse.WebFolder.builder() .id("id") - .baseUrl(JsonValue.from("https://images.example.com/assets")) + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") @@ -200,7 +200,7 @@ internal class OriginListResponseTest { OriginListResponse.ofWebFolder( OriginListResponse.WebFolder.builder() .id("id") - .baseUrl(JsonValue.from("https://images.example.com/assets")) + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") @@ -273,7 +273,7 @@ internal class OriginListResponseTest { .clientEmail("service-account@project.iam.gserviceaccount.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("products")) + .prefix("products") .type(OriginListResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -301,7 +301,7 @@ internal class OriginListResponseTest { .clientEmail("service-account@project.iam.gserviceaccount.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("products")) + .prefix("products") .type(OriginListResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -325,7 +325,7 @@ internal class OriginListResponseTest { .container("images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("uploads")) + .prefix("uploads") .type(OriginListResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -353,7 +353,7 @@ internal class OriginListResponseTest { .container("images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("uploads")) + .prefix("uploads") .type(OriginListResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -373,7 +373,7 @@ internal class OriginListResponseTest { val akeneoPim = OriginListResponse.AkeneoPim.builder() .id("id") - .baseUrl(JsonValue.from("https://akeneo.company.com")) + .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") .type(OriginListResponse.AkeneoPim.Type.AKENEO_PIM) @@ -399,7 +399,7 @@ internal class OriginListResponseTest { OriginListResponse.ofAkeneoPim( OriginListResponse.AkeneoPim.builder() .id("id") - .baseUrl(JsonValue.from("https://akeneo.company.com")) + .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") .type(OriginListResponse.AkeneoPim.Type.AKENEO_PIM) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt index b1c8831d..65537053 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt @@ -22,7 +22,7 @@ internal class OriginUpdateResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginUpdateResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -49,7 +49,7 @@ internal class OriginUpdateResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginUpdateResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -73,7 +73,7 @@ internal class OriginUpdateResponseTest { .endpoint("https://s3.eu-central-1.wasabisys.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .s3ForcePathStyle(true) .type(OriginUpdateResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") @@ -102,7 +102,7 @@ internal class OriginUpdateResponseTest { .endpoint("https://s3.eu-central-1.wasabisys.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .s3ForcePathStyle(true) .type(OriginUpdateResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") @@ -126,7 +126,7 @@ internal class OriginUpdateResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginUpdateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -153,7 +153,7 @@ internal class OriginUpdateResponseTest { .bucket("product-images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("raw-assets")) + .prefix("raw-assets") .type(OriginUpdateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -173,7 +173,7 @@ internal class OriginUpdateResponseTest { val webFolder = OriginUpdateResponse.WebFolder.builder() .id("id") - .baseUrl(JsonValue.from("https://images.example.com/assets")) + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") @@ -200,7 +200,7 @@ internal class OriginUpdateResponseTest { OriginUpdateResponse.ofWebFolder( OriginUpdateResponse.WebFolder.builder() .id("id") - .baseUrl(JsonValue.from("https://images.example.com/assets")) + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") @@ -273,7 +273,7 @@ internal class OriginUpdateResponseTest { .clientEmail("service-account@project.iam.gserviceaccount.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("products")) + .prefix("products") .type(OriginUpdateResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -302,7 +302,7 @@ internal class OriginUpdateResponseTest { .clientEmail("service-account@project.iam.gserviceaccount.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("products")) + .prefix("products") .type(OriginUpdateResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -326,7 +326,7 @@ internal class OriginUpdateResponseTest { .container("images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("uploads")) + .prefix("uploads") .type(OriginUpdateResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -354,7 +354,7 @@ internal class OriginUpdateResponseTest { .container("images") .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix(JsonValue.from("uploads")) + .prefix("uploads") .type(OriginUpdateResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -374,7 +374,7 @@ internal class OriginUpdateResponseTest { val akeneoPim = OriginUpdateResponse.AkeneoPim.builder() .id("id") - .baseUrl(JsonValue.from("https://akeneo.company.com")) + .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") .type(OriginUpdateResponse.AkeneoPim.Type.AKENEO_PIM) @@ -400,7 +400,7 @@ internal class OriginUpdateResponseTest { OriginUpdateResponse.ofAkeneoPim( OriginUpdateResponse.AkeneoPim.builder() .id("id") - .baseUrl(JsonValue.from("https://akeneo.company.com")) + .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") .type(OriginUpdateResponse.AkeneoPim.Type.AKENEO_PIM) From dff9f1b2f9a60391147a03d8e1720892697d4031 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:19:10 +0000 Subject: [PATCH 017/125] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/files/FileUpdateParams.kt | 123 ++++++++-------- .../api/models/files/FileUpdateParamsTest.kt | 134 +++++++++--------- .../services/async/FileServiceAsyncTest.kt | 121 ++++++++-------- .../api/services/blocking/FileServiceTest.kt | 121 ++++++++-------- 5 files changed, 260 insertions(+), 241 deletions(-) diff --git a/.stats.yml b/.stats.yml index 91f8d8ce..0384e026 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-a1cf25a2c075ef11eea56c771578a9c36aa5f37677389988c9fb0c776399bc1b.yml openapi_spec_hash: 8fed9fded4a79267764133be71b296e6 -config_hash: e212bc0b32d2d9fe583f77bccfae0375 +config_hash: 398ac75e62a73363899d6839f61a5977 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 49b6961e..4cdc7444 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 @@ -42,14 +42,14 @@ import kotlin.jvm.optionals.getOrNull class FileUpdateParams private constructor( private val fileId: String?, - private val body: Body?, + private val update: Update?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun fileId(): Optional = Optional.ofNullable(fileId) - fun body(): Optional = Optional.ofNullable(body) + fun update(): Optional = Optional.ofNullable(update) /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -71,14 +71,14 @@ private constructor( class Builder internal constructor() { private var fileId: String? = null - private var body: Body? = 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 - body = fileUpdateParams.body + update = fileUpdateParams.update additionalHeaders = fileUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = fileUpdateParams.additionalQueryParams.toBuilder() } @@ -88,20 +88,21 @@ 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 update(update: Update?) = apply { this.update = update } - /** Alias for calling [Builder.body] with `body.orElse(null)`. */ - fun body(body: Optional) = body(body.getOrNull()) + /** Alias for calling [Builder.update] with `update.orElse(null)`. */ + fun update(update: Optional) = update(update.getOrNull()) - /** Alias for calling [body] with `Body.ofUpdateFileDetails(updateFileDetails)`. */ - fun body(updateFileDetails: Body.UpdateFileDetails) = - body(Body.ofUpdateFileDetails(updateFileDetails)) + /** Alias for calling [update] with `Update.ofFileDetails(fileDetails)`. */ + fun update(fileDetails: Update.UpdateFileDetails) = + update(Update.ofFileDetails(fileDetails)) /** - * Alias for calling [body] with `Body.ofChangePublicationStatus(changePublicationStatus)`. + * Alias for calling [update] with + * `Update.ofChangePublicationStatus(changePublicationStatus)`. */ - fun body(changePublicationStatus: Body.ChangePublicationStatus) = - body(Body.ofChangePublicationStatus(changePublicationStatus)) + fun update(changePublicationStatus: Update.ChangePublicationStatus) = + update(Update.ofChangePublicationStatus(changePublicationStatus)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -207,10 +208,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, + update, + additionalHeaders.build(), + additionalQueryParams.build(), + ) } - fun _body(): Optional = Optional.ofNullable(body) + fun _body(): Optional = Optional.ofNullable(update) fun _pathParam(index: Int): String = when (index) { @@ -222,27 +228,25 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body + @JsonDeserialize(using = Update.Deserializer::class) + @JsonSerialize(using = Update.Serializer::class) + class Update private constructor( - private val updateFileDetails: UpdateFileDetails? = null, + private val fileDetails: UpdateFileDetails? = null, private val changePublicationStatus: ChangePublicationStatus? = null, private val _json: JsonValue? = null, ) { - fun updateFileDetails(): Optional = - Optional.ofNullable(updateFileDetails) + fun fileDetails(): Optional = Optional.ofNullable(fileDetails) fun changePublicationStatus(): Optional = Optional.ofNullable(changePublicationStatus) - fun isUpdateFileDetails(): Boolean = updateFileDetails != null + fun isFileDetails(): Boolean = fileDetails != null fun isChangePublicationStatus(): Boolean = changePublicationStatus != null - fun asUpdateFileDetails(): UpdateFileDetails = - updateFileDetails.getOrThrow("updateFileDetails") + fun asFileDetails(): UpdateFileDetails = fileDetails.getOrThrow("fileDetails") fun asChangePublicationStatus(): ChangePublicationStatus = changePublicationStatus.getOrThrow("changePublicationStatus") @@ -251,7 +255,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - updateFileDetails != null -> visitor.visitUpdateFileDetails(updateFileDetails) + fileDetails != null -> visitor.visitFileDetails(fileDetails) changePublicationStatus != null -> visitor.visitChangePublicationStatus(changePublicationStatus) else -> visitor.unknown(_json) @@ -259,15 +263,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { + fun validate(): Update = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) { - updateFileDetails.validate() + override fun visitFileDetails(fileDetails: UpdateFileDetails) { + fileDetails.validate() } override fun visitChangePublicationStatus( @@ -298,8 +302,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) = - updateFileDetails.validity() + override fun visitFileDetails(fileDetails: UpdateFileDetails) = + fileDetails.validity() override fun visitChangePublicationStatus( changePublicationStatus: ChangePublicationStatus @@ -314,66 +318,66 @@ private constructor( return true } - return other is Body && - updateFileDetails == other.updateFileDetails && + return other is Update && + fileDetails == other.fileDetails && changePublicationStatus == other.changePublicationStatus } - override fun hashCode(): Int = Objects.hash(updateFileDetails, changePublicationStatus) + override fun hashCode(): Int = Objects.hash(fileDetails, changePublicationStatus) override fun toString(): String = when { - updateFileDetails != null -> "Body{updateFileDetails=$updateFileDetails}" + fileDetails != null -> "Update{fileDetails=$fileDetails}" changePublicationStatus != null -> - "Body{changePublicationStatus=$changePublicationStatus}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") + "Update{changePublicationStatus=$changePublicationStatus}" + _json != null -> "Update{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Update") } companion object { @JvmStatic - fun ofUpdateFileDetails(updateFileDetails: UpdateFileDetails) = - Body(updateFileDetails = updateFileDetails) + fun ofFileDetails(fileDetails: UpdateFileDetails) = Update(fileDetails = fileDetails) @JvmStatic fun ofChangePublicationStatus(changePublicationStatus: ChangePublicationStatus) = - Body(changePublicationStatus = changePublicationStatus) + Update(changePublicationStatus = changePublicationStatus) } - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + /** An interface that defines how to map each variant of [Update] to a value of type [T]. */ interface Visitor { - fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails): T + fun visitFileDetails(fileDetails: UpdateFileDetails): T fun visitChangePublicationStatus(changePublicationStatus: ChangePublicationStatus): T /** - * Maps an unknown variant of [Body] to a value of type [T]. + * Maps an unknown variant of [Update] 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. + * 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 Body: $json") + throw ImageKitInvalidDataException("Unknown Update: $json") } } - internal class Deserializer : BaseDeserializer(Body::class) { + internal class Deserializer : BaseDeserializer(Update::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Body { + override fun ObjectCodec.deserialize(node: JsonNode): Update { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - Body(updateFileDetails = it, _json = json) + Update(fileDetails = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(changePublicationStatus = it, _json = json) + Update(changePublicationStatus = it, _json = json) }, ) .filterNotNull() @@ -382,7 +386,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 -> Body(_json = json) + 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 @@ -392,20 +396,19 @@ private constructor( } } - internal class Serializer : BaseSerializer(Body::class) { + internal class Serializer : BaseSerializer(Update::class) { override fun serialize( - value: Body, + value: Update, generator: JsonGenerator, provider: SerializerProvider, ) { when { - value.updateFileDetails != null -> - generator.writeObject(value.updateFileDetails) + 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 Body") + else -> throw IllegalStateException("Invalid Update") } } } @@ -3321,14 +3324,14 @@ private constructor( return other is FileUpdateParams && fileId == other.fileId && - body == other.body && + update == other.update && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(fileId, body, additionalHeaders, additionalQueryParams) + Objects.hash(fileId, update, additionalHeaders, additionalQueryParams) override fun toString() = - "FileUpdateParams{fileId=$fileId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileUpdateParams{fileId=$fileId, update=$update, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 7a30086a..e09a185c 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 @@ -13,11 +13,11 @@ internal class FileUpdateParamsTest { fun create() { FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -25,18 +25,18 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -48,40 +48,40 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoDescription( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoDescriptionExtension .builder() .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoDescriptionExtension .Name .AI_AUTO_DESCRIPTION @@ -113,11 +113,11 @@ internal class FileUpdateParamsTest { val params = FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -125,18 +125,18 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -148,46 +148,47 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAutoDescription( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -202,11 +203,11 @@ internal class FileUpdateParamsTest { assertThat(body) .isEqualTo( - FileUpdateParams.Body.ofUpdateFileDetails( - FileUpdateParams.Body.UpdateFileDetails.builder() + FileUpdateParams.Update.ofFileDetails( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -214,18 +215,18 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -237,46 +238,47 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAutoDescription( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) 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 a1b5dc1e..70e6b44d 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 @@ -32,11 +32,11 @@ internal class FileServiceAsyncTest { fileServiceAsync.update( FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -44,64 +44,71 @@ internal class FileServiceAsyncTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) - .options( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofRemovedotBg( + FileUpdateParams.Update.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Update.UpdateFileDetails + .Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + FileUpdateParams.Update.UpdateFileDetails + .Extension + .RemovedotBgExtension + .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 .ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoDescriptionExtension .builder() .name( - FileUpdateParams.Body.UpdateFileDetails + FileUpdateParams.Update.UpdateFileDetails .Extension .AutoDescriptionExtension .Name 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 8f70775a..ae641e9c 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 @@ -32,11 +32,11 @@ internal class FileServiceTest { fileService.update( FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -44,64 +44,71 @@ internal class FileServiceTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) - .options( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofRemovedotBg( + FileUpdateParams.Update.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Update.UpdateFileDetails + .Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + FileUpdateParams.Update.UpdateFileDetails + .Extension + .RemovedotBgExtension + .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 .ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoDescriptionExtension .builder() .name( - FileUpdateParams.Body.UpdateFileDetails + FileUpdateParams.Update.UpdateFileDetails .Extension .AutoDescriptionExtension .Name From 40fc1b6c265772ea03477a7321e76ca16b5a12f3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:25:28 +0000 Subject: [PATCH 018/125] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/files/FileUpdateParams.kt | 123 ++++++++-------- .../api/models/files/FileUpdateParamsTest.kt | 134 +++++++++--------- .../services/async/FileServiceAsyncTest.kt | 121 ++++++++-------- .../api/services/blocking/FileServiceTest.kt | 121 ++++++++-------- 5 files changed, 241 insertions(+), 260 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0384e026..91f8d8ce 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-a1cf25a2c075ef11eea56c771578a9c36aa5f37677389988c9fb0c776399bc1b.yml openapi_spec_hash: 8fed9fded4a79267764133be71b296e6 -config_hash: 398ac75e62a73363899d6839f61a5977 +config_hash: e212bc0b32d2d9fe583f77bccfae0375 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 4cdc7444..49b6961e 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 @@ -42,14 +42,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 @@ -71,14 +71,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() } @@ -88,21 +88,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() @@ -208,15 +207,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) { @@ -228,25 +222,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") @@ -255,7 +251,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) @@ -263,15 +259,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( @@ -302,8 +298,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 @@ -318,66 +314,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() @@ -386,7 +382,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 @@ -396,19 +392,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") } } } @@ -3324,14 +3321,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/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index e09a185c..7a30086a 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 @@ -13,11 +13,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() @@ -25,18 +25,18 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -48,40 +48,40 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoDescriptionExtension .builder() .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoDescriptionExtension .Name .AI_AUTO_DESCRIPTION @@ -113,11 +113,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() @@ -125,18 +125,18 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -148,47 +148,46 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAutoDescription( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -203,11 +202,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() @@ -215,18 +214,18 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .builder() .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Name .REMOVE_BG ) .options( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .RemovedotBgExtension .Options .builder() @@ -238,47 +237,46 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAutoDescription( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoDescriptionExtension + .Name + .AI_AUTO_DESCRIPTION + ) + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) 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 70e6b44d..a1b5dc1e 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 @@ -32,11 +32,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() @@ -44,71 +44,64 @@ internal class FileServiceAsyncTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofRemovedotBg( - FileUpdateParams.Update.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Update.UpdateFileDetails - .Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) - .options( - FileUpdateParams.Update.UpdateFileDetails - .Extension - .RemovedotBgExtension - .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 + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension .ofAutoDescription( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoDescriptionExtension .builder() .name( - FileUpdateParams.Update.UpdateFileDetails + FileUpdateParams.Body.UpdateFileDetails .Extension .AutoDescriptionExtension .Name 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 ae641e9c..8f70775a 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 @@ -32,11 +32,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() @@ -44,71 +44,64 @@ internal class FileServiceTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofRemovedotBg( - FileUpdateParams.Update.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Update.UpdateFileDetails - .Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) - .options( - FileUpdateParams.Update.UpdateFileDetails - .Extension - .RemovedotBgExtension - .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 + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .builder() + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Name + .REMOVE_BG + ) + .options( + FileUpdateParams.Body.UpdateFileDetails.Extension + .RemovedotBgExtension + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Body.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Body.UpdateFileDetails.Extension .ofAutoDescription( - FileUpdateParams.Update.UpdateFileDetails.Extension + FileUpdateParams.Body.UpdateFileDetails.Extension .AutoDescriptionExtension .builder() .name( - FileUpdateParams.Update.UpdateFileDetails + FileUpdateParams.Body.UpdateFileDetails .Extension .AutoDescriptionExtension .Name From f5276c4a270c7812c3e41d0262f16735505ed774 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:31:21 +0000 Subject: [PATCH 019/125] codegen metadata --- .stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 91f8d8ce..2b058894 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-a1cf25a2c075ef11eea56c771578a9c36aa5f37677389988c9fb0c776399bc1b.yml -openapi_spec_hash: 8fed9fded4a79267764133be71b296e6 -config_hash: e212bc0b32d2d9fe583f77bccfae0375 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-ba44a73e45777c7f0831ac2026a9b63ae01f681b6acff7c7f80d7294d1f4ee4a.yml +openapi_spec_hash: df7bdce53da43b2ceae08a2a47bd1b52 +config_hash: b75c4e4432c2d0650589863f8336849b From 76b77757b47dcd1417d132c3bc6a56189f5f3ad5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 08:35:01 +0000 Subject: [PATCH 020/125] feat(api): manual updates --- .stats.yml | 4 +- .../api/models/files/FileUpdateParams.kt | 673 +++--------------- .../api/models/files/FileUpdateParamsTest.kt | 82 +-- .../services/async/FileServiceAsyncTest.kt | 27 +- .../api/services/blocking/FileServiceTest.kt | 27 +- 5 files changed, 138 insertions(+), 675 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2b058894..dc773365 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-ba44a73e45777c7f0831ac2026a9b63ae01f681b6acff7c7f80d7294d1f4ee4a.yml -openapi_spec_hash: df7bdce53da43b2ceae08a2a47bd1b52 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7df229db9f102454c11cef7c98953e5b6463221dd4be66cdb4f4e93f41d447ae.yml +openapi_spec_hash: ecaba4c44e684a0611699e09fca9891b config_hash: b75c4e4432c2d0650589863f8336849b 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 49b6961e..97127453 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 @@ -726,20 +726,16 @@ private constructor( } } - /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = - addExtension(Extension.ofRemovedotBg(removedotBg)) + /** 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.ofAutoDescription(autoDescription)`. - */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = - addExtension(Extension.ofAutoDescription(autoDescription)) + /** 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. @@ -1024,39 +1020,40 @@ private constructor( @JsonSerialize(using = Extension.Serializer::class) class Extension private constructor( - private val removedotBg: RemovedotBgExtension? = null, + private val removeBg: RemoveBg? = null, private val autoTagging: AutoTaggingExtension? = null, - private val autoDescription: AutoDescriptionExtension? = null, + private val aiAutoDescription: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun removedotBg(): Optional = Optional.ofNullable(removedotBg) + fun removeBg(): Optional = Optional.ofNullable(removeBg) fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - fun autoDescription(): Optional = - Optional.ofNullable(autoDescription) + fun aiAutoDescription(): Optional = + Optional.ofNullable(aiAutoDescription) - fun isRemovedotBg(): Boolean = removedotBg != null + fun isRemoveBg(): Boolean = removeBg != null fun isAutoTagging(): Boolean = autoTagging != null - fun isAutoDescription(): Boolean = autoDescription != null + fun isAiAutoDescription(): Boolean = aiAutoDescription != null - fun asRemovedotBg(): RemovedotBgExtension = removedotBg.getOrThrow("removedotBg") + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - fun asAutoDescription(): AutoDescriptionExtension = - autoDescription.getOrThrow("autoDescription") + fun asAiAutoDescription(): JsonValue = + aiAutoDescription.getOrThrow("aiAutoDescription") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - removedotBg != null -> visitor.visitRemovedotBg(removedotBg) + removeBg != null -> visitor.visitRemoveBg(removeBg) autoTagging != null -> visitor.visitAutoTagging(autoTagging) - autoDescription != null -> visitor.visitAutoDescription(autoDescription) + aiAutoDescription != null -> + visitor.visitAiAutoDescription(aiAutoDescription) else -> visitor.unknown(_json) } @@ -1069,18 +1066,24 @@ private constructor( accept( object : Visitor { - override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) { - removedotBg.validate() + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() } override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { autoTagging.validate() } - override fun visitAutoDescription( - autoDescription: AutoDescriptionExtension - ) { - autoDescription.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" + ) + } + } } } ) @@ -1105,15 +1108,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) = - removedotBg.validity() + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = autoTagging.validity() - override fun visitAutoDescription( - autoDescription: AutoDescriptionExtension - ) = autoDescription.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 } @@ -1125,36 +1132,38 @@ private constructor( } return other is Extension && - removedotBg == other.removedotBg && + removeBg == other.removeBg && autoTagging == other.autoTagging && - autoDescription == other.autoDescription + aiAutoDescription == other.aiAutoDescription } override fun hashCode(): Int = - Objects.hash(removedotBg, autoTagging, autoDescription) + Objects.hash(removeBg, autoTagging, aiAutoDescription) override fun toString(): String = when { - removedotBg != null -> "Extension{removedotBg=$removedotBg}" + removeBg != null -> "Extension{removeBg=$removeBg}" autoTagging != null -> "Extension{autoTagging=$autoTagging}" - autoDescription != null -> "Extension{autoDescription=$autoDescription}" + aiAutoDescription != null -> + "Extension{aiAutoDescription=$aiAutoDescription}" _json != null -> "Extension{_unknown=$_json}" else -> throw IllegalStateException("Invalid Extension") } companion object { - @JvmStatic - fun ofRemovedotBg(removedotBg: RemovedotBgExtension) = - Extension(removedotBg = removedotBg) + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) @JvmStatic fun ofAutoTagging(autoTagging: AutoTaggingExtension) = Extension(autoTagging = autoTagging) @JvmStatic - fun ofAutoDescription(autoDescription: AutoDescriptionExtension) = - Extension(autoDescription = autoDescription) + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = + JsonValue.from(mapOf("name" to "ai-auto-description")) + ) } /** @@ -1163,11 +1172,11 @@ private constructor( */ interface Visitor { - fun visitRemovedotBg(removedotBg: RemovedotBgExtension): T + fun visitRemoveBg(removeBg: RemoveBg): T fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - fun visitAutoDescription(autoDescription: AutoDescriptionExtension): T + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** * Maps an unknown variant of [Extension] to a value of type [T]. @@ -1188,30 +1197,24 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Extension { val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(removedotBg = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(autoTagging = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(autoDescription = 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 -> Extension(_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 (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) } } @@ -1223,28 +1226,26 @@ private constructor( provider: SerializerProvider, ) { when { - value.removedotBg != null -> generator.writeObject(value.removedotBg) + value.removeBg != null -> generator.writeObject(value.removeBg) value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.autoDescription != null -> - generator.writeObject(value.autoDescription) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Extension") } } } - class RemovedotBgExtension + class RemoveBg private constructor( - private val name: JsonField, + private val name: JsonValue, private val options: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), @JsonProperty("options") @ExcludeMissing options: JsonField = JsonMissing.of(), @@ -1253,11 +1254,15 @@ private constructor( /** * Specifies the background removal 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). + * 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). */ - fun name(): Name = name.getRequired("name") + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type @@ -1265,14 +1270,6 @@ private constructor( */ fun options(): Optional = options.getOptional("options") - /** - * Returns the raw JSON value 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 [options]. * @@ -1297,45 +1294,38 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [RemovedotBgExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [RemovedotBgExtension]. */ + /** A builder for [RemoveBg]. */ class Builder internal constructor() { - private var name: JsonField? = null + private var name: JsonValue = JsonValue.from("remove-bg") private var options: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { - name = removedotBgExtension.name - options = removedotBgExtension.options - additionalProperties = - removedotBgExtension.additionalProperties.toMutableMap() + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() } - /** Specifies the background removal extension. */ - fun name(name: Name) = name(JsonField.of(name)) - /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.name = name } + fun name(name: JsonValue) = apply { this.name = name } fun options(options: Options) = options(JsonField.of(options)) @@ -1371,33 +1361,28 @@ private constructor( } /** - * Returns an immutable instance of [RemovedotBgExtension]. + * Returns an immutable instance of [RemoveBg]. * * 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(): RemovedotBgExtension = - RemovedotBgExtension( - checkRequired("name", name), - options, - additionalProperties.toMutableMap(), - ) + fun build(): RemoveBg = + RemoveBg(name, options, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): RemovedotBgExtension = apply { + fun validate(): RemoveBg = apply { if (validated) { return@apply } - name().validate() + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException( + "'name' is invalid, received $it" + ) + } + } options().ifPresent { it.validate() } validated = true } @@ -1418,139 +1403,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (name.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + (options.asKnown().getOrNull()?.validity() ?: 0) - /** Specifies the background removal extension. */ - 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 REMOVE_BG = of("remove-bg") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - REMOVE_BG - } - - /** - * 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 { - REMOVE_BG, - /** - * 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) { - REMOVE_BG -> Value.REMOVE_BG - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - REMOVE_BG -> Known.REMOVE_BG - 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() - } - class Options private constructor( private val addShadow: JsonField, @@ -1871,7 +1726,7 @@ private constructor( return true } - return other is RemovedotBgExtension && + return other is RemoveBg && name == other.name && options == other.options && additionalProperties == other.additionalProperties @@ -1884,7 +1739,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RemovedotBgExtension{name=$name, options=$options, additionalProperties=$additionalProperties}" + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" } class AutoTaggingExtension @@ -2283,306 +2138,6 @@ private constructor( override fun toString() = "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } - - class AutoDescriptionExtension - private constructor( - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of() - ) : this(name, mutableMapOf()) - - /** - * Specifies the auto description 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(): Name = name.getRequired("name") - - /** - * Returns the raw JSON value 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 - * [AutoDescriptionExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoDescriptionExtension]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = - apply { - name = autoDescriptionExtension.name - additionalProperties = - autoDescriptionExtension.additionalProperties.toMutableMap() - } - - /** Specifies the auto description extension. */ - 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 [AutoDescriptionExtension]. - * - * 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(): AutoDescriptionExtension = - AutoDescriptionExtension( - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoDescriptionExtension = apply { - if (validated) { - return@apply - } - - 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 = (name.asKnown().getOrNull()?.validity() ?: 0) - - /** Specifies the auto description extension. */ - 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - AI_AUTO_DESCRIPTION - } - - /** - * 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 { - AI_AUTO_DESCRIPTION, - /** - * 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) { - AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION - 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 AutoDescriptionExtension && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoDescriptionExtension{name=$name, 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 7a30086a..9e1d7e14 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 @@ -25,19 +25,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg.builder() .options( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg .Options .builder() .addShadow(true) @@ -76,18 +67,7 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + FileUpdateParams.Body.UpdateFileDetails.Extension.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -125,19 +105,12 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) .options( FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + .RemoveBg .Options .builder() .addShadow(true) @@ -176,18 +149,8 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + FileUpdateParams.Body.UpdateFileDetails.Extension + .ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -214,19 +177,12 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) .options( FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + .RemoveBg .Options .builder() .addShadow(true) @@ -265,18 +221,8 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + FileUpdateParams.Body.UpdateFileDetails.Extension + .ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) 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 a1b5dc1e..af701200 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 @@ -44,19 +44,12 @@ internal class FileServiceAsyncTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) .options( FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + .RemoveBg .Options .builder() .addShadow(true) @@ -96,19 +89,7 @@ internal class FileServiceAsyncTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension - .ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails - .Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + .ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) 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 8f70775a..1510c6e9 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 @@ -44,19 +44,12 @@ internal class FileServiceTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemovedotBg( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension - .Name - .REMOVE_BG - ) .options( FileUpdateParams.Body.UpdateFileDetails.Extension - .RemovedotBgExtension + .RemoveBg .Options .builder() .addShadow(true) @@ -96,19 +89,7 @@ internal class FileServiceTest { .build() ), FileUpdateParams.Body.UpdateFileDetails.Extension - .ofAutoDescription( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoDescriptionExtension - .builder() - .name( - FileUpdateParams.Body.UpdateFileDetails - .Extension - .AutoDescriptionExtension - .Name - .AI_AUTO_DESCRIPTION - ) - .build() - ), + .ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) From 1094c5a1dbde103c4daa1284d46cae578a567443 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 09:59:47 +0000 Subject: [PATCH 021/125] feat(api): manual updates --- .stats.yml | 4 +- .../urlendpoints/UrlEndpointCreateParams.kt | 913 +-------- .../urlendpoints/UrlEndpointUpdateParams.kt | 913 +-------- .../models/beta/v2/files/FileUploadParams.kt | 1796 ++++------------- .../api/models/files/FileUploadParams.kt | 1796 ++++------------- .../UrlEndpointCreateParamsTest.kt | 15 +- .../UrlEndpointUpdateParamsTest.kt | 15 +- .../beta/v2/files/FileUploadParamsTest.kt | 81 +- .../api/models/files/FileUploadParamsTest.kt | 81 +- .../api/services/ErrorHandlingTest.kt | 510 +---- .../api/services/ServiceParamsTest.kt | 24 +- .../services/async/FileServiceAsyncTest.kt | 25 +- .../accounts/UrlEndpointServiceAsyncTest.kt | 12 +- .../async/beta/v2/FileServiceAsyncTest.kt | 25 +- .../api/services/blocking/FileServiceTest.kt | 25 +- .../accounts/UrlEndpointServiceTest.kt | 12 +- .../blocking/beta/v2/FileServiceTest.kt | 25 +- 17 files changed, 1144 insertions(+), 5128 deletions(-) diff --git a/.stats.yml b/.stats.yml index dc773365..9d8aa405 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-7df229db9f102454c11cef7c98953e5b6463221dd4be66cdb4f4e93f41d447ae.yml -openapi_spec_hash: ecaba4c44e684a0611699e09fca9891b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-6c237ebd6f81741286e7cfbaeac1356da3e18c7fe43b74d6c358d62bfb40dbb9.yml +openapi_spec_hash: ad6a65d74e3eb865a5d2915177f92ea7 config_hash: b75c4e4432c2d0650589863f8336849b 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 index ee48d3bd..790da3d6 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt @@ -15,13 +15,11 @@ 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 @@ -222,15 +220,13 @@ private constructor( } /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = apply { - body.urlRewriter(cloudinary) - } + fun urlRewriter(cloudinary: UrlRewriter.Cloudinary) = apply { body.urlRewriter(cloudinary) } - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ - fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = apply { body.urlRewriter(imgix) } + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = apply { body.urlRewriterImgix() } - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ - fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = apply { body.urlRewriter(akamai) } + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = apply { body.urlRewriterAkamai() } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -585,16 +581,14 @@ private constructor( } /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = + fun urlRewriter(cloudinary: UrlRewriter.Cloudinary) = urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ - fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = - urlRewriter(UrlRewriter.ofImgix(imgix)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = urlRewriter(UrlRewriter.ofImgix()) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ - fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = - urlRewriter(UrlRewriter.ofAkamai(akamai)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = urlRewriter(UrlRewriter.ofAkamai()) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -700,17 +694,17 @@ private constructor( @JsonSerialize(using = UrlRewriter.Serializer::class) class UrlRewriter private constructor( - private val cloudinary: CloudinaryUrlRewriter? = null, - private val imgix: ImgixUrlRewriter? = null, - private val akamai: AkamaiUrlRewriter? = null, + 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 cloudinary(): Optional = Optional.ofNullable(cloudinary) - fun imgix(): Optional = Optional.ofNullable(imgix) + fun imgix(): Optional = Optional.ofNullable(imgix) - fun akamai(): Optional = Optional.ofNullable(akamai) + fun akamai(): Optional = Optional.ofNullable(akamai) fun isCloudinary(): Boolean = cloudinary != null @@ -718,11 +712,11 @@ private constructor( fun isAkamai(): Boolean = akamai != null - fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + fun asCloudinary(): Cloudinary = cloudinary.getOrThrow("cloudinary") - fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + fun asImgix(): JsonValue = imgix.getOrThrow("imgix") - fun asAkamai(): AkamaiUrlRewriter = akamai.getOrThrow("akamai") + fun asAkamai(): JsonValue = akamai.getOrThrow("akamai") fun _json(): Optional = Optional.ofNullable(_json) @@ -743,16 +737,28 @@ private constructor( accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) { + override fun visitCloudinary(cloudinary: Cloudinary) { cloudinary.validate() } - override fun visitImgix(imgix: ImgixUrlRewriter) { - imgix.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: AkamaiUrlRewriter) { - akamai.validate() + override fun visitAkamai(akamai: JsonValue) { + akamai.let { + if (it != JsonValue.from(mapOf("type" to "AKAMAI"))) { + throw ImageKitInvalidDataException( + "'akamai' is invalid, received $it" + ) + } + } } } ) @@ -777,12 +783,13 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = - cloudinary.validity() + override fun visitCloudinary(cloudinary: Cloudinary) = cloudinary.validity() - override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } - override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -813,12 +820,12 @@ private constructor( companion object { @JvmStatic - fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = - UrlRewriter(cloudinary = cloudinary) + fun ofCloudinary(cloudinary: Cloudinary) = UrlRewriter(cloudinary = cloudinary) - @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) - @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + @JvmStatic + fun ofAkamai() = UrlRewriter(akamai = JsonValue.from(mapOf("type" to "AKAMAI"))) } /** @@ -827,11 +834,11 @@ private constructor( */ interface Visitor { - fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + fun visitCloudinary(cloudinary: Cloudinary): T - fun visitImgix(imgix: ImgixUrlRewriter): T + fun visitImgix(imgix: JsonValue): T - fun visitAkamai(akamai: AkamaiUrlRewriter): T + fun visitAkamai(akamai: JsonValue): T /** * Maps an unknown variant of [UrlRewriter] to a value of type [T]. @@ -852,32 +859,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): UrlRewriter { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(cloudinary = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(imgix = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(akamai = 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 -> UrlRewriter(_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) { + "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) } } @@ -898,27 +900,31 @@ private constructor( } } - class CloudinaryUrlRewriter + class Cloudinary private constructor( - private val type: JsonField, + private val type: JsonValue, private val preserveAssetDeliveryTypes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("preserveAssetDeliveryTypes") @ExcludeMissing preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), ) : this(type, preserveAssetDeliveryTypes, 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Whether to preserve `/` in the rewritten URL. @@ -929,13 +935,6 @@ private constructor( fun preserveAssetDeliveryTypes(): Optional = preserveAssetDeliveryTypes.getOptional("preserveAssetDeliveryTypes") - /** - * 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 [preserveAssetDeliveryTypes]. * @@ -960,42 +959,37 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [CloudinaryUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Cloudinary]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CloudinaryUrlRewriter]. */ + /** A builder for [Cloudinary]. */ class Builder internal constructor() { - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY") private var preserveAssetDeliveryTypes: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { - type = cloudinaryUrlRewriter.type - preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes - additionalProperties = cloudinaryUrlRewriter.additionalProperties.toMutableMap() + internal fun from(cloudinary: Cloudinary) = apply { + type = cloudinary.type + preserveAssetDeliveryTypes = cloudinary.preserveAssetDeliveryTypes + additionalProperties = cloudinary.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("CLOUDINARY") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** Whether to preserve `/` in the rewritten URL. */ fun preserveAssetDeliveryTypes(preserveAssetDeliveryTypes: Boolean) = @@ -1036,20 +1030,13 @@ private constructor( } /** - * Returns an immutable instance of [CloudinaryUrlRewriter]. + * Returns an immutable instance of [Cloudinary]. * * 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(): CloudinaryUrlRewriter = - CloudinaryUrlRewriter( - checkRequired("type", type), + fun build(): Cloudinary = + Cloudinary( + type, preserveAssetDeliveryTypes, additionalProperties.toMutableMap(), ) @@ -1057,12 +1044,16 @@ private constructor( private var validated: Boolean = false - fun validate(): CloudinaryUrlRewriter = apply { + fun validate(): Cloudinary = apply { if (validated) { return@apply } - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } preserveAssetDeliveryTypes() validated = true } @@ -1083,139 +1074,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("CLOUDINARY")) 1 else 0 } + (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) - 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 CLOUDINARY = of("CLOUDINARY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY - } - - /** - * 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 { - CLOUDINARY, - /** - * 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) { - CLOUDINARY -> Value.CLOUDINARY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY -> Known.CLOUDINARY - 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 CloudinaryUrlRewriter && + return other is Cloudinary && type == other.type && preserveAssetDeliveryTypes == other.preserveAssetDeliveryTypes && additionalProperties == other.additionalProperties @@ -1228,575 +1095,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryUrlRewriter{type=$type, preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, additionalProperties=$additionalProperties}" - } - - class ImgixUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [ImgixUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ImgixUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { - type = imgixUrlRewriter.type - additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [ImgixUrlRewriter]. - * - * 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(): ImgixUrlRewriter = - ImgixUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ImgixUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 IMGIX = of("IMGIX") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMGIX - } - - /** - * 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 { - IMGIX, - /** - * 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) { - IMGIX -> Value.IMGIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - IMGIX -> Known.IMGIX - 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 ImgixUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } - - class AkamaiUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [AkamaiUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AkamaiUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { - type = akamaiUrlRewriter.type - additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [AkamaiUrlRewriter]. - * - * 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(): AkamaiUrlRewriter = - AkamaiUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AkamaiUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 AKAMAI = of("AKAMAI") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKAMAI - } - - /** - * 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 { - AKAMAI, - /** - * 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) { - AKAMAI -> Value.AKAMAI - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKAMAI -> Known.AKAMAI - 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 AkamaiUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + "Cloudinary{type=$type, preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, 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 index 7fc0d953..980d8500 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt @@ -15,13 +15,11 @@ 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 @@ -240,15 +238,13 @@ private constructor( } /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = apply { - body.urlRewriter(cloudinary) - } + fun urlRewriter(cloudinary: UrlRewriter.Cloudinary) = apply { body.urlRewriter(cloudinary) } - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ - fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = apply { body.urlRewriter(imgix) } + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = apply { body.urlRewriterImgix() } - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ - fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = apply { body.urlRewriter(akamai) } + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = apply { body.urlRewriterAkamai() } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -610,16 +606,14 @@ private constructor( } /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = + fun urlRewriter(cloudinary: UrlRewriter.Cloudinary) = urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ - fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = - urlRewriter(UrlRewriter.ofImgix(imgix)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = urlRewriter(UrlRewriter.ofImgix()) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ - fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = - urlRewriter(UrlRewriter.ofAkamai(akamai)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = urlRewriter(UrlRewriter.ofAkamai()) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -725,17 +719,17 @@ private constructor( @JsonSerialize(using = UrlRewriter.Serializer::class) class UrlRewriter private constructor( - private val cloudinary: CloudinaryUrlRewriter? = null, - private val imgix: ImgixUrlRewriter? = null, - private val akamai: AkamaiUrlRewriter? = null, + 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 cloudinary(): Optional = Optional.ofNullable(cloudinary) - fun imgix(): Optional = Optional.ofNullable(imgix) + fun imgix(): Optional = Optional.ofNullable(imgix) - fun akamai(): Optional = Optional.ofNullable(akamai) + fun akamai(): Optional = Optional.ofNullable(akamai) fun isCloudinary(): Boolean = cloudinary != null @@ -743,11 +737,11 @@ private constructor( fun isAkamai(): Boolean = akamai != null - fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + fun asCloudinary(): Cloudinary = cloudinary.getOrThrow("cloudinary") - fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + fun asImgix(): JsonValue = imgix.getOrThrow("imgix") - fun asAkamai(): AkamaiUrlRewriter = akamai.getOrThrow("akamai") + fun asAkamai(): JsonValue = akamai.getOrThrow("akamai") fun _json(): Optional = Optional.ofNullable(_json) @@ -768,16 +762,28 @@ private constructor( accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) { + override fun visitCloudinary(cloudinary: Cloudinary) { cloudinary.validate() } - override fun visitImgix(imgix: ImgixUrlRewriter) { - imgix.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: AkamaiUrlRewriter) { - akamai.validate() + override fun visitAkamai(akamai: JsonValue) { + akamai.let { + if (it != JsonValue.from(mapOf("type" to "AKAMAI"))) { + throw ImageKitInvalidDataException( + "'akamai' is invalid, received $it" + ) + } + } } } ) @@ -802,12 +808,13 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = - cloudinary.validity() + override fun visitCloudinary(cloudinary: Cloudinary) = cloudinary.validity() - override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } - override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -838,12 +845,12 @@ private constructor( companion object { @JvmStatic - fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = - UrlRewriter(cloudinary = cloudinary) + fun ofCloudinary(cloudinary: Cloudinary) = UrlRewriter(cloudinary = cloudinary) - @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) - @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + @JvmStatic + fun ofAkamai() = UrlRewriter(akamai = JsonValue.from(mapOf("type" to "AKAMAI"))) } /** @@ -852,11 +859,11 @@ private constructor( */ interface Visitor { - fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + fun visitCloudinary(cloudinary: Cloudinary): T - fun visitImgix(imgix: ImgixUrlRewriter): T + fun visitImgix(imgix: JsonValue): T - fun visitAkamai(akamai: AkamaiUrlRewriter): T + fun visitAkamai(akamai: JsonValue): T /** * Maps an unknown variant of [UrlRewriter] to a value of type [T]. @@ -877,32 +884,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): UrlRewriter { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(cloudinary = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(imgix = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(akamai = 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 -> UrlRewriter(_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) { + "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) } } @@ -923,27 +925,31 @@ private constructor( } } - class CloudinaryUrlRewriter + class Cloudinary private constructor( - private val type: JsonField, + private val type: JsonValue, private val preserveAssetDeliveryTypes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("preserveAssetDeliveryTypes") @ExcludeMissing preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), ) : this(type, preserveAssetDeliveryTypes, 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Whether to preserve `/` in the rewritten URL. @@ -954,13 +960,6 @@ private constructor( fun preserveAssetDeliveryTypes(): Optional = preserveAssetDeliveryTypes.getOptional("preserveAssetDeliveryTypes") - /** - * 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 [preserveAssetDeliveryTypes]. * @@ -985,42 +984,37 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [CloudinaryUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Cloudinary]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CloudinaryUrlRewriter]. */ + /** A builder for [Cloudinary]. */ class Builder internal constructor() { - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY") private var preserveAssetDeliveryTypes: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { - type = cloudinaryUrlRewriter.type - preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes - additionalProperties = cloudinaryUrlRewriter.additionalProperties.toMutableMap() + internal fun from(cloudinary: Cloudinary) = apply { + type = cloudinary.type + preserveAssetDeliveryTypes = cloudinary.preserveAssetDeliveryTypes + additionalProperties = cloudinary.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("CLOUDINARY") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** Whether to preserve `/` in the rewritten URL. */ fun preserveAssetDeliveryTypes(preserveAssetDeliveryTypes: Boolean) = @@ -1061,20 +1055,13 @@ private constructor( } /** - * Returns an immutable instance of [CloudinaryUrlRewriter]. + * Returns an immutable instance of [Cloudinary]. * * 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(): CloudinaryUrlRewriter = - CloudinaryUrlRewriter( - checkRequired("type", type), + fun build(): Cloudinary = + Cloudinary( + type, preserveAssetDeliveryTypes, additionalProperties.toMutableMap(), ) @@ -1082,12 +1069,16 @@ private constructor( private var validated: Boolean = false - fun validate(): CloudinaryUrlRewriter = apply { + fun validate(): Cloudinary = apply { if (validated) { return@apply } - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } preserveAssetDeliveryTypes() validated = true } @@ -1108,139 +1099,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("CLOUDINARY")) 1 else 0 } + (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) - 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 CLOUDINARY = of("CLOUDINARY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY - } - - /** - * 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 { - CLOUDINARY, - /** - * 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) { - CLOUDINARY -> Value.CLOUDINARY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY -> Known.CLOUDINARY - 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 CloudinaryUrlRewriter && + return other is Cloudinary && type == other.type && preserveAssetDeliveryTypes == other.preserveAssetDeliveryTypes && additionalProperties == other.additionalProperties @@ -1253,575 +1120,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryUrlRewriter{type=$type, preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, additionalProperties=$additionalProperties}" - } - - class ImgixUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [ImgixUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ImgixUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { - type = imgixUrlRewriter.type - additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [ImgixUrlRewriter]. - * - * 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(): ImgixUrlRewriter = - ImgixUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ImgixUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 IMGIX = of("IMGIX") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMGIX - } - - /** - * 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 { - IMGIX, - /** - * 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) { - IMGIX -> Value.IMGIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - IMGIX -> Known.IMGIX - 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 ImgixUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } - - class AkamaiUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [AkamaiUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AkamaiUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { - type = akamaiUrlRewriter.type - additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [AkamaiUrlRewriter]. - * - * 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(): AkamaiUrlRewriter = - AkamaiUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AkamaiUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 AKAMAI = of("AKAMAI") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKAMAI - } - - /** - * 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 { - AKAMAI, - /** - * 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) { - AKAMAI -> Value.AKAMAI - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKAMAI -> Known.AKAMAI - 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 AkamaiUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" + "Cloudinary{type=$type, preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, 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 bf154ec8..a8caac42 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 @@ -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 @@ -36,6 +35,7 @@ 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. @@ -657,20 +657,16 @@ private constructor( */ fun addExtension(extension: Extension) = apply { body.addExtension(extension) } - /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = apply { - body.addExtension(removedotBg) - } + /** 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.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = apply { - body.addExtension(autoDescription) - } + /** 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 @@ -1771,19 +1767,16 @@ private constructor( } } - /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = - addExtension(Extension.ofRemovedotBg(removedotBg)) + /** 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.ofAutoDescription(autoDescription)`. - */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = - addExtension(Extension.ofAutoDescription(autoDescription)) + /** 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 @@ -2293,39 +2286,37 @@ private constructor( @JsonSerialize(using = Extension.Serializer::class) class Extension private constructor( - private val removedotBg: RemovedotBgExtension? = null, + private val removeBg: RemoveBg? = null, private val autoTagging: AutoTaggingExtension? = null, - private val autoDescription: AutoDescriptionExtension? = null, + private val aiAutoDescription: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun removedotBg(): Optional = Optional.ofNullable(removedotBg) + fun removeBg(): Optional = Optional.ofNullable(removeBg) fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - fun autoDescription(): Optional = - Optional.ofNullable(autoDescription) + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) - fun isRemovedotBg(): Boolean = removedotBg != null + fun isRemoveBg(): Boolean = removeBg != null fun isAutoTagging(): Boolean = autoTagging != null - fun isAutoDescription(): Boolean = autoDescription != null + fun isAiAutoDescription(): Boolean = aiAutoDescription != null - fun asRemovedotBg(): RemovedotBgExtension = removedotBg.getOrThrow("removedotBg") + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - fun asAutoDescription(): AutoDescriptionExtension = - autoDescription.getOrThrow("autoDescription") + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - removedotBg != null -> visitor.visitRemovedotBg(removedotBg) + removeBg != null -> visitor.visitRemoveBg(removeBg) autoTagging != null -> visitor.visitAutoTagging(autoTagging) - autoDescription != null -> visitor.visitAutoDescription(autoDescription) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) else -> visitor.unknown(_json) } @@ -2338,16 +2329,22 @@ private constructor( accept( object : Visitor { - override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) { - removedotBg.validate() + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() } override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { autoTagging.validate() } - override fun visitAutoDescription(autoDescription: AutoDescriptionExtension) { - autoDescription.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" + ) + } + } } } ) @@ -2372,14 +2369,16 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) = - removedotBg.validity() + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = autoTagging.validity() - override fun visitAutoDescription(autoDescription: AutoDescriptionExtension) = - autoDescription.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 } @@ -2391,35 +2390,35 @@ private constructor( } return other is Extension && - removedotBg == other.removedotBg && + removeBg == other.removeBg && autoTagging == other.autoTagging && - autoDescription == other.autoDescription + aiAutoDescription == other.aiAutoDescription } - override fun hashCode(): Int = Objects.hash(removedotBg, autoTagging, autoDescription) + override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) override fun toString(): String = when { - removedotBg != null -> "Extension{removedotBg=$removedotBg}" + removeBg != null -> "Extension{removeBg=$removeBg}" autoTagging != null -> "Extension{autoTagging=$autoTagging}" - autoDescription != null -> "Extension{autoDescription=$autoDescription}" + aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" _json != null -> "Extension{_unknown=$_json}" else -> throw IllegalStateException("Invalid Extension") } companion object { - @JvmStatic - fun ofRemovedotBg(removedotBg: RemovedotBgExtension) = - Extension(removedotBg = removedotBg) + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) @JvmStatic fun ofAutoTagging(autoTagging: AutoTaggingExtension) = Extension(autoTagging = autoTagging) @JvmStatic - fun ofAutoDescription(autoDescription: AutoDescriptionExtension) = - Extension(autoDescription = autoDescription) + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) } /** @@ -2427,11 +2426,11 @@ private constructor( */ interface Visitor { - fun visitRemovedotBg(removedotBg: RemovedotBgExtension): T + fun visitRemoveBg(removeBg: RemoveBg): T fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - fun visitAutoDescription(autoDescription: AutoDescriptionExtension): T + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** * Maps an unknown variant of [Extension] to a value of type [T]. @@ -2452,32 +2451,24 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Extension { val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removedotBg = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoDescription = 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 -> Extension(_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 (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) } } @@ -2489,18 +2480,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.removedotBg != null -> generator.writeObject(value.removedotBg) + value.removeBg != null -> generator.writeObject(value.removeBg) value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.autoDescription != null -> generator.writeObject(value.autoDescription) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Extension") } } } - class RemovedotBgExtension + class RemoveBg private constructor( - private val name: MultipartField, + private val name: JsonValue, private val options: MultipartField, private val additionalProperties: MutableMap, ) { @@ -2508,11 +2500,15 @@ private constructor( /** * Specifies the background removal 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). + * 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). */ - fun name(): Name = name.value.getRequired("name") + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. @@ -2520,14 +2516,6 @@ private constructor( */ fun options(): Optional = options.value.getOptional("options") - /** - * 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 - /** * Returns the raw multipart value of [options]. * @@ -2552,42 +2540,37 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [RemovedotBgExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [RemovedotBgExtension]. */ + /** A builder for [RemoveBg]. */ class Builder internal constructor() { - private var name: MultipartField? = null + private var name: JsonValue = JsonValue.from("remove-bg") private var options: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { - name = removedotBgExtension.name - options = removedotBgExtension.options - additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() } - /** Specifies the background removal extension. */ - fun name(name: Name) = name(MultipartField.of(name)) - /** - * Sets [Builder.name] to an arbitrary multipart 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("remove-bg") + * ``` * - * 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: JsonValue) = apply { this.name = name } fun options(options: Options) = options(MultipartField.of(options)) @@ -2623,33 +2606,25 @@ private constructor( } /** - * Returns an immutable instance of [RemovedotBgExtension]. + * Returns an immutable instance of [RemoveBg]. * * 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(): RemovedotBgExtension = - RemovedotBgExtension( - checkRequired("name", name), - options, - additionalProperties.toMutableMap(), - ) + fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): RemovedotBgExtension = apply { + fun validate(): RemoveBg = apply { if (validated) { return@apply } - name().validate() + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } options().ifPresent { it.validate() } validated = true } @@ -2662,131 +2637,6 @@ private constructor( false } - /** Specifies the background removal extension. */ - 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 REMOVE_BG = of("remove-bg") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - REMOVE_BG - } - - /** - * 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 { - REMOVE_BG, - /** - * 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) { - REMOVE_BG -> Value.REMOVE_BG - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - REMOVE_BG -> Known.REMOVE_BG - 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() - } - class Options private constructor( private val addShadow: MultipartField, @@ -3071,7 +2921,7 @@ private constructor( return true } - return other is RemovedotBgExtension && + return other is RemoveBg && name == other.name && options == other.options && additionalProperties == other.additionalProperties @@ -3082,7 +2932,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RemovedotBgExtension{name=$name, options=$options, additionalProperties=$additionalProperties}" + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" } class AutoTaggingExtension @@ -3446,327 +3296,50 @@ private constructor( override fun toString() = "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } + } - class AutoDescriptionExtension - private constructor( - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { + class ResponseField @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** - * Specifies the auto description 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(): Name = name.value.getRequired("name") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the 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 [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + companion object { - @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 - * [AutoDescriptionExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmField val IS_PUBLISHED = of("isPublished") - /** A builder for [AutoDescriptionExtension]. */ - class Builder internal constructor() { + @JvmField val CUSTOM_METADATA = of("customMetadata") - private var name: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val METADATA = of("metadata") - @JvmSynthetic - internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { - name = autoDescriptionExtension.name - additionalProperties = - autoDescriptionExtension.additionalProperties.toMutableMap() - } + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } - /** Specifies the auto description extension. */ - 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 [AutoDescriptionExtension]. - * - * 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(): AutoDescriptionExtension = - AutoDescriptionExtension( - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoDescriptionExtension = apply { - if (validated) { - return@apply - } - - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the auto description extension. */ - 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - AI_AUTO_DESCRIPTION - } - - /** - * 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 { - AI_AUTO_DESCRIPTION, - /** - * 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) { - AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION - 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 AutoDescriptionExtension && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoDescriptionExtension{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. */ + 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. @@ -3995,27 +3568,29 @@ private constructor( } } + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) + /** - * Alias for calling [addPost] with - * `Post.ofSimplePostTransformation(simplePostTransformation)`. + * Alias for calling [addPost] with the following: + * ```java + * Post.InnerTransformation.builder() + * .value(value) + * .build() + * ``` */ - fun addPost(simplePostTransformation: Post.SimplePostTransformation) = - addPost(Post.ofSimplePostTransformation(simplePostTransformation)) + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) - /** Alias for calling [addPost] with `Post.ofConvertGifToVideo(convertGifToVideo)`. */ - fun addPost(convertGifToVideo: Post.ConvertGifToVideo) = - addPost(Post.ofConvertGifToVideo(convertGifToVideo)) + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) - /** Alias for calling [addPost] with `Post.ofGenerateAThumbnail(generateAThumbnail)`. */ - fun addPost(generateAThumbnail: Post.GenerateAThumbnail) = - addPost(Post.ofGenerateAThumbnail(generateAThumbnail)) + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) - /** - * Alias for calling [addPost] with - * `Post.ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming)`. - */ - fun addPost(adaptiveBitrateStreaming: Post.AdaptiveBitrateStreaming) = - addPost(Post.ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming)) + /** 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 @@ -4088,56 +3663,47 @@ private constructor( @JsonSerialize(using = Post.Serializer::class) class Post private constructor( - private val simplePostTransformation: SimplePostTransformation? = null, - private val convertGifToVideo: ConvertGifToVideo? = null, - private val generateAThumbnail: GenerateAThumbnail? = null, - private val adaptiveBitrateStreaming: AdaptiveBitrateStreaming? = null, + 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 simplePostTransformation(): Optional = - Optional.ofNullable(simplePostTransformation) + fun transformation(): Optional = + Optional.ofNullable(transformation) - fun convertGifToVideo(): Optional = - Optional.ofNullable(convertGifToVideo) + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - fun generateAThumbnail(): Optional = - Optional.ofNullable(generateAThumbnail) + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - fun adaptiveBitrateStreaming(): Optional = - Optional.ofNullable(adaptiveBitrateStreaming) + fun abs(): Optional = Optional.ofNullable(abs) - fun isSimplePostTransformation(): Boolean = simplePostTransformation != null + fun isTransformation(): Boolean = transformation != null - fun isConvertGifToVideo(): Boolean = convertGifToVideo != null + fun isGifToVideo(): Boolean = gifToVideo != null - fun isGenerateAThumbnail(): Boolean = generateAThumbnail != null + fun isThumbnail(): Boolean = thumbnail != null - fun isAdaptiveBitrateStreaming(): Boolean = adaptiveBitrateStreaming != null + fun isAbs(): Boolean = abs != null - fun asSimplePostTransformation(): SimplePostTransformation = - simplePostTransformation.getOrThrow("simplePostTransformation") + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") - fun asConvertGifToVideo(): ConvertGifToVideo = - convertGifToVideo.getOrThrow("convertGifToVideo") + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - fun asGenerateAThumbnail(): GenerateAThumbnail = - generateAThumbnail.getOrThrow("generateAThumbnail") + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - fun asAdaptiveBitrateStreaming(): AdaptiveBitrateStreaming = - adaptiveBitrateStreaming.getOrThrow("adaptiveBitrateStreaming") + fun asAbs(): Abs = abs.getOrThrow("abs") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - simplePostTransformation != null -> - visitor.visitSimplePostTransformation(simplePostTransformation) - convertGifToVideo != null -> visitor.visitConvertGifToVideo(convertGifToVideo) - generateAThumbnail != null -> - visitor.visitGenerateAThumbnail(generateAThumbnail) - adaptiveBitrateStreaming != null -> - visitor.visitAdaptiveBitrateStreaming(adaptiveBitrateStreaming) + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) else -> visitor.unknown(_json) } @@ -4150,26 +3716,20 @@ private constructor( accept( object : Visitor { - override fun visitSimplePostTransformation( - simplePostTransformation: SimplePostTransformation - ) { - simplePostTransformation.validate() + override fun visitTransformation(transformation: InnerTransformation) { + transformation.validate() } - override fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) { - convertGifToVideo.validate() + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() } - override fun visitGenerateAThumbnail( - generateAThumbnail: GenerateAThumbnail - ) { - generateAThumbnail.validate() + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() } - override fun visitAdaptiveBitrateStreaming( - adaptiveBitrateStreaming: AdaptiveBitrateStreaming - ) { - adaptiveBitrateStreaming.validate() + override fun visitAbs(abs: Abs) { + abs.validate() } } ) @@ -4194,20 +3754,14 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitSimplePostTransformation( - simplePostTransformation: SimplePostTransformation - ) = simplePostTransformation.validity() + override fun visitTransformation(transformation: InnerTransformation) = + transformation.validity() - override fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) = - convertGifToVideo.validity() + override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() - override fun visitGenerateAThumbnail( - generateAThumbnail: GenerateAThumbnail - ) = generateAThumbnail.validity() + override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() - override fun visitAdaptiveBitrateStreaming( - adaptiveBitrateStreaming: AdaptiveBitrateStreaming - ) = adaptiveBitrateStreaming.validity() + override fun visitAbs(abs: Abs) = abs.validity() override fun unknown(json: JsonValue?) = 0 } @@ -4219,28 +3773,20 @@ private constructor( } return other is Post && - simplePostTransformation == other.simplePostTransformation && - convertGifToVideo == other.convertGifToVideo && - generateAThumbnail == other.generateAThumbnail && - adaptiveBitrateStreaming == other.adaptiveBitrateStreaming + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs } - override fun hashCode(): Int = - Objects.hash( - simplePostTransformation, - convertGifToVideo, - generateAThumbnail, - adaptiveBitrateStreaming, - ) + override fun hashCode(): Int = Objects.hash(transformation, gifToVideo, thumbnail, abs) override fun toString(): String = when { - simplePostTransformation != null -> - "Post{simplePostTransformation=$simplePostTransformation}" - convertGifToVideo != null -> "Post{convertGifToVideo=$convertGifToVideo}" - generateAThumbnail != null -> "Post{generateAThumbnail=$generateAThumbnail}" - adaptiveBitrateStreaming != null -> - "Post{adaptiveBitrateStreaming=$adaptiveBitrateStreaming}" + 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") } @@ -4248,20 +3794,14 @@ private constructor( companion object { @JvmStatic - fun ofSimplePostTransformation(simplePostTransformation: SimplePostTransformation) = - Post(simplePostTransformation = simplePostTransformation) + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) - @JvmStatic - fun ofConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) = - Post(convertGifToVideo = convertGifToVideo) + @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) - @JvmStatic - fun ofGenerateAThumbnail(generateAThumbnail: GenerateAThumbnail) = - Post(generateAThumbnail = generateAThumbnail) + @JvmStatic fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) - @JvmStatic - fun ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming: AdaptiveBitrateStreaming) = - Post(adaptiveBitrateStreaming = adaptiveBitrateStreaming) + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) } /** @@ -4269,17 +3809,13 @@ private constructor( */ interface Visitor { - fun visitSimplePostTransformation( - simplePostTransformation: SimplePostTransformation - ): T + fun visitTransformation(transformation: InnerTransformation): T - fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo): T + fun visitGifToVideo(gifToVideo: GifToVideo): T - fun visitGenerateAThumbnail(generateAThumbnail: GenerateAThumbnail): T + fun visitThumbnail(thumbnail: Thumbnail): T - fun visitAdaptiveBitrateStreaming( - adaptiveBitrateStreaming: AdaptiveBitrateStreaming - ): T + fun visitAbs(abs: Abs): T /** * Maps an unknown variant of [Post] to a value of type [T]. @@ -4300,33 +3836,32 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Post { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Post(simplePostTransformation = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Post(convertGifToVideo = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Post(generateAThumbnail = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Post(adaptiveBitrateStreaming = 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 -> Post(_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) { + "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) } } @@ -4338,23 +3873,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.simplePostTransformation != null -> - generator.writeObject(value.simplePostTransformation) - value.convertGifToVideo != null -> - generator.writeObject(value.convertGifToVideo) - value.generateAThumbnail != null -> - generator.writeObject(value.generateAThumbnail) - value.adaptiveBitrateStreaming != null -> - generator.writeObject(value.adaptiveBitrateStreaming) + 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 SimplePostTransformation + class InnerTransformation private constructor( - private val type: MultipartField, + private val type: JsonValue, private val value: MultipartField, private val additionalProperties: MutableMap, ) { @@ -4362,11 +3893,15 @@ private constructor( /** * Transformation 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 type(): Type = type.value.getRequired("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 @@ -4378,14 +3913,6 @@ private constructor( */ fun value(): String = value.value.getRequired("value") - /** - * Returns the raw multipart value of [type]. - * - * Unlike [type], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type - /** * Returns the raw multipart value of [value]. * @@ -4410,43 +3937,44 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [SimplePostTransformation]. + * [InnerTransformation]. * * The following fields are required: * ```java - * .type() * .value() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [SimplePostTransformation]. */ + /** A builder for [InnerTransformation]. */ class Builder internal constructor() { - private var type: MultipartField? = null + private var type: JsonValue = JsonValue.from("transformation") private var value: MultipartField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(simplePostTransformation: SimplePostTransformation) = apply { - type = simplePostTransformation.type - value = simplePostTransformation.value + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value additionalProperties = - simplePostTransformation.additionalProperties.toMutableMap() + innerTransformation.additionalProperties.toMutableMap() } - /** Transformation type. */ - fun type(type: Type) = type(MultipartField.of(type)) - /** - * Sets [Builder.type] to an arbitrary multipart value. + * Sets the field 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. + * 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: MultipartField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based @@ -4486,21 +4014,20 @@ private constructor( } /** - * Returns an immutable instance of [SimplePostTransformation]. + * Returns an immutable instance of [InnerTransformation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .type() * .value() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): SimplePostTransformation = - SimplePostTransformation( - checkRequired("type", type), + fun build(): InnerTransformation = + InnerTransformation( + type, checkRequired("value", value), additionalProperties.toMutableMap(), ) @@ -4508,12 +4035,16 @@ private constructor( private var validated: Boolean = false - fun validate(): SimplePostTransformation = apply { + fun validate(): InnerTransformation = apply { if (validated) { return@apply } - type().validate() + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } value() validated = true } @@ -4526,140 +4057,12 @@ private constructor( false } - /** Transformation type. */ - 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") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TRANSFORMATION - } - - /** - * 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, - /** - * 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - 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 SimplePostTransformation && + return other is InnerTransformation && type == other.type && value == other.value && additionalProperties == other.additionalProperties @@ -4672,12 +4075,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SimplePostTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" } - class ConvertGifToVideo + class GifToVideo private constructor( - private val type: MultipartField, + private val type: JsonValue, private val value: MultipartField, private val additionalProperties: MutableMap, ) { @@ -4685,11 +4088,15 @@ private constructor( /** * Converts an animated GIF into an MP4. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * 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 type(): Type = type.value.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Optional transformation string to apply to the output video. **Example**: `q-80` @@ -4699,14 +4106,6 @@ private constructor( */ fun value(): Optional = value.value.getOptional("value") - /** - * Returns the raw multipart value of [type]. - * - * Unlike [type], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type - /** * Returns the raw multipart value of [value]. * @@ -4729,43 +4128,37 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [ConvertGifToVideo]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [GifToVideo]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [ConvertGifToVideo]. */ + /** A builder for [GifToVideo]. */ class Builder internal constructor() { - private var type: MultipartField? = 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(convertGifToVideo: ConvertGifToVideo) = apply { - type = convertGifToVideo.type - value = convertGifToVideo.value - additionalProperties = convertGifToVideo.additionalProperties.toMutableMap() + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = gifToVideo.additionalProperties.toMutableMap() } - /** Converts an animated GIF into an MP4. */ - fun type(type: Type) = type(MultipartField.of(type)) - /** - * Sets [Builder.type] to an arbitrary multipart value. + * Sets the field 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. + * 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: MultipartField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * Optional transformation string to apply to the output video. **Example**: @@ -4805,33 +4198,26 @@ private constructor( } /** - * Returns an immutable instance of [ConvertGifToVideo]. + * Returns an immutable instance of [GifToVideo]. * * 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(): ConvertGifToVideo = - ConvertGifToVideo( - checkRequired("type", type), - value, - additionalProperties.toMutableMap(), - ) + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): ConvertGifToVideo = apply { + fun validate(): GifToVideo = apply { if (validated) { return@apply } - type().validate() + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } value() validated = true } @@ -4844,140 +4230,12 @@ private constructor( false } - /** Converts an animated GIF into an MP4. */ - 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 GIF_TO_VIDEO = of("gif-to-video") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GIF_TO_VIDEO - } - - /** - * 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 { - GIF_TO_VIDEO, - /** - * 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) { - GIF_TO_VIDEO -> Value.GIF_TO_VIDEO - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GIF_TO_VIDEO -> Known.GIF_TO_VIDEO - 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 ConvertGifToVideo && + return other is GifToVideo && type == other.type && value == other.value && additionalProperties == other.additionalProperties @@ -4990,12 +4248,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ConvertGifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" } - class GenerateAThumbnail + class Thumbnail private constructor( - private val type: MultipartField, + private val type: JsonValue, private val value: MultipartField, private val additionalProperties: MutableMap, ) { @@ -5003,11 +4261,15 @@ private constructor( /** * Generates a thumbnail 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). + * 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). */ - fun type(): Type = type.value.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Optional transformation string. **Example**: `w-150,h-150` @@ -5017,14 +4279,6 @@ private constructor( */ fun value(): Optional = value.value.getOptional("value") - /** - * Returns the raw multipart value of [type]. - * - * Unlike [type], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type - /** * Returns the raw multipart value of [value]. * @@ -5047,44 +4301,37 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [GenerateAThumbnail]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [GenerateAThumbnail]. */ + /** A builder for [Thumbnail]. */ class Builder internal constructor() { - private var type: MultipartField? = null + private var type: JsonValue = JsonValue.from("thumbnail") private var value: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(generateAThumbnail: GenerateAThumbnail) = apply { - type = generateAThumbnail.type - value = generateAThumbnail.value - additionalProperties = - generateAThumbnail.additionalProperties.toMutableMap() + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() } - /** Generates a thumbnail image. */ - fun type(type: Type) = type(MultipartField.of(type)) - /** - * Sets [Builder.type] to an arbitrary multipart 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("thumbnail") + * ``` * - * 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. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun type(type: MultipartField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** Optional transformation string. **Example**: `w-150,h-150` */ fun value(value: String) = value(MultipartField.of(value)) @@ -5121,33 +4368,26 @@ private constructor( } /** - * Returns an immutable instance of [GenerateAThumbnail]. + * Returns an immutable instance of [Thumbnail]. * * 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(): GenerateAThumbnail = - GenerateAThumbnail( - checkRequired("type", type), - value, - additionalProperties.toMutableMap(), - ) + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): GenerateAThumbnail = apply { + fun validate(): Thumbnail = apply { if (validated) { return@apply } - type().validate() + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } value() validated = true } @@ -5160,140 +4400,12 @@ private constructor( false } - /** Generates a thumbnail image. */ - 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 THUMBNAIL = of("thumbnail") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - 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 { - 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) { - 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) { - 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() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GenerateAThumbnail && + return other is Thumbnail && type == other.type && value == other.value && additionalProperties == other.additionalProperties @@ -5306,13 +4418,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GenerateAThumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" } - class AdaptiveBitrateStreaming + class Abs private constructor( private val protocol: MultipartField, - private val type: MultipartField, + private val type: JsonValue, private val value: MultipartField, private val additionalProperties: MutableMap, ) { @@ -5329,11 +4441,15 @@ private constructor( /** * Adaptive Bitrate Streaming (ABS) setup. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * 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). */ - fun type(): Type = type.value.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * List of different representations you want to create separated by an underscore. @@ -5354,14 +4470,6 @@ private constructor( @ExcludeMissing fun _protocol(): MultipartField = protocol - /** - * Returns the raw multipart value of [type]. - * - * Unlike [type], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type - /** * Returns the raw multipart value of [value]. * @@ -5385,34 +4493,31 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AdaptiveBitrateStreaming]. + * Returns a mutable builder for constructing an instance of [Abs]. * * The following fields are required: * ```java * .protocol() - * .type() * .value() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AdaptiveBitrateStreaming]. */ + /** A builder for [Abs]. */ class Builder internal constructor() { private var protocol: MultipartField? = null - private var type: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") private var value: MultipartField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(adaptiveBitrateStreaming: AdaptiveBitrateStreaming) = apply { - protocol = adaptiveBitrateStreaming.protocol - type = adaptiveBitrateStreaming.type - value = adaptiveBitrateStreaming.value - additionalProperties = - adaptiveBitrateStreaming.additionalProperties.toMutableMap() + 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`). */ @@ -5429,17 +4534,19 @@ private constructor( this.protocol = protocol } - /** Adaptive Bitrate Streaming (ABS) setup. */ - fun type(type: Type) = type(MultipartField.of(type)) - /** - * Sets [Builder.type] to an arbitrary multipart value. + * Sets the field 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. + * 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: MultipartField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * List of different representations you want to create separated by an @@ -5479,23 +4586,22 @@ private constructor( } /** - * Returns an immutable instance of [AdaptiveBitrateStreaming]. + * Returns an immutable instance of [Abs]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .protocol() - * .type() * .value() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AdaptiveBitrateStreaming = - AdaptiveBitrateStreaming( + fun build(): Abs = + Abs( checkRequired("protocol", protocol), - checkRequired("type", type), + type, checkRequired("value", value), additionalProperties.toMutableMap(), ) @@ -5503,13 +4609,17 @@ private constructor( private var validated: Boolean = false - fun validate(): AdaptiveBitrateStreaming = apply { + fun validate(): Abs = apply { if (validated) { return@apply } protocol().validate() - type().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } value() validated = true } @@ -5658,140 +4768,12 @@ private constructor( override fun toString() = value.toString() } - /** Adaptive Bitrate Streaming (ABS) setup. */ - 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 ABS = of("abs") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ABS - } - - /** - * 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 { - ABS, - /** - * 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) { - ABS -> Value.ABS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - ABS -> Known.ABS - 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 AdaptiveBitrateStreaming && + return other is Abs && protocol == other.protocol && type == other.type && value == other.value && @@ -5805,7 +4787,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AdaptiveBitrateStreaming{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + "Abs{protocol=$protocol, type=$type, value=$value, 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 41a1122c..8127f2aa 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 @@ -36,6 +35,7 @@ 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 @@ -737,20 +737,16 @@ private constructor( */ fun addExtension(extension: Extension) = apply { body.addExtension(extension) } - /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = apply { - body.addExtension(removedotBg) - } + /** 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.ofAutoDescription(autoDescription)`. */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = apply { - body.addExtension(autoDescription) - } + /** 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 @@ -1986,19 +1982,16 @@ private constructor( } } - /** Alias for calling [addExtension] with `Extension.ofRemovedotBg(removedotBg)`. */ - fun addExtension(removedotBg: Extension.RemovedotBgExtension) = - addExtension(Extension.ofRemovedotBg(removedotBg)) + /** 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.ofAutoDescription(autoDescription)`. - */ - fun addExtension(autoDescription: Extension.AutoDescriptionExtension) = - addExtension(Extension.ofAutoDescription(autoDescription)) + /** 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 @@ -2559,39 +2552,37 @@ private constructor( @JsonSerialize(using = Extension.Serializer::class) class Extension private constructor( - private val removedotBg: RemovedotBgExtension? = null, + private val removeBg: RemoveBg? = null, private val autoTagging: AutoTaggingExtension? = null, - private val autoDescription: AutoDescriptionExtension? = null, + private val aiAutoDescription: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun removedotBg(): Optional = Optional.ofNullable(removedotBg) + fun removeBg(): Optional = Optional.ofNullable(removeBg) fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - fun autoDescription(): Optional = - Optional.ofNullable(autoDescription) + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) - fun isRemovedotBg(): Boolean = removedotBg != null + fun isRemoveBg(): Boolean = removeBg != null fun isAutoTagging(): Boolean = autoTagging != null - fun isAutoDescription(): Boolean = autoDescription != null + fun isAiAutoDescription(): Boolean = aiAutoDescription != null - fun asRemovedotBg(): RemovedotBgExtension = removedotBg.getOrThrow("removedotBg") + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - fun asAutoDescription(): AutoDescriptionExtension = - autoDescription.getOrThrow("autoDescription") + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - removedotBg != null -> visitor.visitRemovedotBg(removedotBg) + removeBg != null -> visitor.visitRemoveBg(removeBg) autoTagging != null -> visitor.visitAutoTagging(autoTagging) - autoDescription != null -> visitor.visitAutoDescription(autoDescription) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) else -> visitor.unknown(_json) } @@ -2604,16 +2595,22 @@ private constructor( accept( object : Visitor { - override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) { - removedotBg.validate() + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() } override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { autoTagging.validate() } - override fun visitAutoDescription(autoDescription: AutoDescriptionExtension) { - autoDescription.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" + ) + } + } } } ) @@ -2638,14 +2635,16 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitRemovedotBg(removedotBg: RemovedotBgExtension) = - removedotBg.validity() + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = autoTagging.validity() - override fun visitAutoDescription(autoDescription: AutoDescriptionExtension) = - autoDescription.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 } @@ -2657,35 +2656,35 @@ private constructor( } return other is Extension && - removedotBg == other.removedotBg && + removeBg == other.removeBg && autoTagging == other.autoTagging && - autoDescription == other.autoDescription + aiAutoDescription == other.aiAutoDescription } - override fun hashCode(): Int = Objects.hash(removedotBg, autoTagging, autoDescription) + override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) override fun toString(): String = when { - removedotBg != null -> "Extension{removedotBg=$removedotBg}" + removeBg != null -> "Extension{removeBg=$removeBg}" autoTagging != null -> "Extension{autoTagging=$autoTagging}" - autoDescription != null -> "Extension{autoDescription=$autoDescription}" + aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" _json != null -> "Extension{_unknown=$_json}" else -> throw IllegalStateException("Invalid Extension") } companion object { - @JvmStatic - fun ofRemovedotBg(removedotBg: RemovedotBgExtension) = - Extension(removedotBg = removedotBg) + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) @JvmStatic fun ofAutoTagging(autoTagging: AutoTaggingExtension) = Extension(autoTagging = autoTagging) @JvmStatic - fun ofAutoDescription(autoDescription: AutoDescriptionExtension) = - Extension(autoDescription = autoDescription) + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) } /** @@ -2693,11 +2692,11 @@ private constructor( */ interface Visitor { - fun visitRemovedotBg(removedotBg: RemovedotBgExtension): T + fun visitRemoveBg(removeBg: RemoveBg): T fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - fun visitAutoDescription(autoDescription: AutoDescriptionExtension): T + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** * Maps an unknown variant of [Extension] to a value of type [T]. @@ -2718,32 +2717,24 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Extension { val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removedotBg = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoDescription = 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 -> Extension(_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 (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) } } @@ -2755,18 +2746,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.removedotBg != null -> generator.writeObject(value.removedotBg) + value.removeBg != null -> generator.writeObject(value.removeBg) value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.autoDescription != null -> generator.writeObject(value.autoDescription) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Extension") } } } - class RemovedotBgExtension + class RemoveBg private constructor( - private val name: MultipartField, + private val name: JsonValue, private val options: MultipartField, private val additionalProperties: MutableMap, ) { @@ -2774,11 +2766,15 @@ private constructor( /** * Specifies the background removal 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). + * 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). */ - fun name(): Name = name.value.getRequired("name") + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. @@ -2786,14 +2782,6 @@ private constructor( */ fun options(): Optional = options.value.getOptional("options") - /** - * 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 - /** * Returns the raw multipart value of [options]. * @@ -2818,42 +2806,37 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [RemovedotBgExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [RemovedotBgExtension]. */ + /** A builder for [RemoveBg]. */ class Builder internal constructor() { - private var name: MultipartField? = null + private var name: JsonValue = JsonValue.from("remove-bg") private var options: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removedotBgExtension: RemovedotBgExtension) = apply { - name = removedotBgExtension.name - options = removedotBgExtension.options - additionalProperties = removedotBgExtension.additionalProperties.toMutableMap() + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() } - /** Specifies the background removal extension. */ - fun name(name: Name) = name(MultipartField.of(name)) - /** - * Sets [Builder.name] to an arbitrary multipart 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("remove-bg") + * ``` * - * 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: JsonValue) = apply { this.name = name } fun options(options: Options) = options(MultipartField.of(options)) @@ -2889,33 +2872,25 @@ private constructor( } /** - * Returns an immutable instance of [RemovedotBgExtension]. + * Returns an immutable instance of [RemoveBg]. * * 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(): RemovedotBgExtension = - RemovedotBgExtension( - checkRequired("name", name), - options, - additionalProperties.toMutableMap(), - ) + fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): RemovedotBgExtension = apply { + fun validate(): RemoveBg = apply { if (validated) { return@apply } - name().validate() + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } options().ifPresent { it.validate() } validated = true } @@ -2928,131 +2903,6 @@ private constructor( false } - /** Specifies the background removal extension. */ - 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 REMOVE_BG = of("remove-bg") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - REMOVE_BG - } - - /** - * 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 { - REMOVE_BG, - /** - * 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) { - REMOVE_BG -> Value.REMOVE_BG - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - REMOVE_BG -> Known.REMOVE_BG - 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() - } - class Options private constructor( private val addShadow: MultipartField, @@ -3337,7 +3187,7 @@ private constructor( return true } - return other is RemovedotBgExtension && + return other is RemoveBg && name == other.name && options == other.options && additionalProperties == other.additionalProperties @@ -3348,7 +3198,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RemovedotBgExtension{name=$name, options=$options, additionalProperties=$additionalProperties}" + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" } class AutoTaggingExtension @@ -3712,327 +3562,50 @@ private constructor( override fun toString() = "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } + } - class AutoDescriptionExtension - private constructor( - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { + class ResponseField @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** - * Specifies the auto description 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(): Name = name.value.getRequired("name") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the 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 [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + companion object { - @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 - * [AutoDescriptionExtension]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmField val IS_PUBLISHED = of("isPublished") - /** A builder for [AutoDescriptionExtension]. */ - class Builder internal constructor() { + @JvmField val CUSTOM_METADATA = of("customMetadata") - private var name: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val METADATA = of("metadata") - @JvmSynthetic - internal fun from(autoDescriptionExtension: AutoDescriptionExtension) = apply { - name = autoDescriptionExtension.name - additionalProperties = - autoDescriptionExtension.additionalProperties.toMutableMap() - } + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } - /** Specifies the auto description extension. */ - 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 [AutoDescriptionExtension]. - * - * 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(): AutoDescriptionExtension = - AutoDescriptionExtension( - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoDescriptionExtension = apply { - if (validated) { - return@apply - } - - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the auto description extension. */ - 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 AI_AUTO_DESCRIPTION = of("ai-auto-description") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - AI_AUTO_DESCRIPTION - } - - /** - * 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 { - AI_AUTO_DESCRIPTION, - /** - * 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) { - AI_AUTO_DESCRIPTION -> Value.AI_AUTO_DESCRIPTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AI_AUTO_DESCRIPTION -> Known.AI_AUTO_DESCRIPTION - 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 AutoDescriptionExtension && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoDescriptionExtension{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. */ + 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. @@ -4261,27 +3834,29 @@ private constructor( } } + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) + /** - * Alias for calling [addPost] with - * `Post.ofSimplePostTransformation(simplePostTransformation)`. + * Alias for calling [addPost] with the following: + * ```java + * Post.InnerTransformation.builder() + * .value(value) + * .build() + * ``` */ - fun addPost(simplePostTransformation: Post.SimplePostTransformation) = - addPost(Post.ofSimplePostTransformation(simplePostTransformation)) + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) - /** Alias for calling [addPost] with `Post.ofConvertGifToVideo(convertGifToVideo)`. */ - fun addPost(convertGifToVideo: Post.ConvertGifToVideo) = - addPost(Post.ofConvertGifToVideo(convertGifToVideo)) + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) - /** Alias for calling [addPost] with `Post.ofGenerateAThumbnail(generateAThumbnail)`. */ - fun addPost(generateAThumbnail: Post.GenerateAThumbnail) = - addPost(Post.ofGenerateAThumbnail(generateAThumbnail)) + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) - /** - * Alias for calling [addPost] with - * `Post.ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming)`. - */ - fun addPost(adaptiveBitrateStreaming: Post.AdaptiveBitrateStreaming) = - addPost(Post.ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming)) + /** 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 @@ -4354,56 +3929,47 @@ private constructor( @JsonSerialize(using = Post.Serializer::class) class Post private constructor( - private val simplePostTransformation: SimplePostTransformation? = null, - private val convertGifToVideo: ConvertGifToVideo? = null, - private val generateAThumbnail: GenerateAThumbnail? = null, - private val adaptiveBitrateStreaming: AdaptiveBitrateStreaming? = null, + 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 simplePostTransformation(): Optional = - Optional.ofNullable(simplePostTransformation) + fun transformation(): Optional = + Optional.ofNullable(transformation) - fun convertGifToVideo(): Optional = - Optional.ofNullable(convertGifToVideo) + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - fun generateAThumbnail(): Optional = - Optional.ofNullable(generateAThumbnail) + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - fun adaptiveBitrateStreaming(): Optional = - Optional.ofNullable(adaptiveBitrateStreaming) + fun abs(): Optional = Optional.ofNullable(abs) - fun isSimplePostTransformation(): Boolean = simplePostTransformation != null + fun isTransformation(): Boolean = transformation != null - fun isConvertGifToVideo(): Boolean = convertGifToVideo != null + fun isGifToVideo(): Boolean = gifToVideo != null - fun isGenerateAThumbnail(): Boolean = generateAThumbnail != null + fun isThumbnail(): Boolean = thumbnail != null - fun isAdaptiveBitrateStreaming(): Boolean = adaptiveBitrateStreaming != null + fun isAbs(): Boolean = abs != null - fun asSimplePostTransformation(): SimplePostTransformation = - simplePostTransformation.getOrThrow("simplePostTransformation") + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") - fun asConvertGifToVideo(): ConvertGifToVideo = - convertGifToVideo.getOrThrow("convertGifToVideo") + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - fun asGenerateAThumbnail(): GenerateAThumbnail = - generateAThumbnail.getOrThrow("generateAThumbnail") + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - fun asAdaptiveBitrateStreaming(): AdaptiveBitrateStreaming = - adaptiveBitrateStreaming.getOrThrow("adaptiveBitrateStreaming") + fun asAbs(): Abs = abs.getOrThrow("abs") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - simplePostTransformation != null -> - visitor.visitSimplePostTransformation(simplePostTransformation) - convertGifToVideo != null -> visitor.visitConvertGifToVideo(convertGifToVideo) - generateAThumbnail != null -> - visitor.visitGenerateAThumbnail(generateAThumbnail) - adaptiveBitrateStreaming != null -> - visitor.visitAdaptiveBitrateStreaming(adaptiveBitrateStreaming) + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) else -> visitor.unknown(_json) } @@ -4416,26 +3982,20 @@ private constructor( accept( object : Visitor { - override fun visitSimplePostTransformation( - simplePostTransformation: SimplePostTransformation - ) { - simplePostTransformation.validate() + override fun visitTransformation(transformation: InnerTransformation) { + transformation.validate() } - override fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) { - convertGifToVideo.validate() + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() } - override fun visitGenerateAThumbnail( - generateAThumbnail: GenerateAThumbnail - ) { - generateAThumbnail.validate() + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() } - override fun visitAdaptiveBitrateStreaming( - adaptiveBitrateStreaming: AdaptiveBitrateStreaming - ) { - adaptiveBitrateStreaming.validate() + override fun visitAbs(abs: Abs) { + abs.validate() } } ) @@ -4460,20 +4020,14 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitSimplePostTransformation( - simplePostTransformation: SimplePostTransformation - ) = simplePostTransformation.validity() + override fun visitTransformation(transformation: InnerTransformation) = + transformation.validity() - override fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) = - convertGifToVideo.validity() + override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() - override fun visitGenerateAThumbnail( - generateAThumbnail: GenerateAThumbnail - ) = generateAThumbnail.validity() + override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() - override fun visitAdaptiveBitrateStreaming( - adaptiveBitrateStreaming: AdaptiveBitrateStreaming - ) = adaptiveBitrateStreaming.validity() + override fun visitAbs(abs: Abs) = abs.validity() override fun unknown(json: JsonValue?) = 0 } @@ -4485,28 +4039,20 @@ private constructor( } return other is Post && - simplePostTransformation == other.simplePostTransformation && - convertGifToVideo == other.convertGifToVideo && - generateAThumbnail == other.generateAThumbnail && - adaptiveBitrateStreaming == other.adaptiveBitrateStreaming + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs } - override fun hashCode(): Int = - Objects.hash( - simplePostTransformation, - convertGifToVideo, - generateAThumbnail, - adaptiveBitrateStreaming, - ) + override fun hashCode(): Int = Objects.hash(transformation, gifToVideo, thumbnail, abs) override fun toString(): String = when { - simplePostTransformation != null -> - "Post{simplePostTransformation=$simplePostTransformation}" - convertGifToVideo != null -> "Post{convertGifToVideo=$convertGifToVideo}" - generateAThumbnail != null -> "Post{generateAThumbnail=$generateAThumbnail}" - adaptiveBitrateStreaming != null -> - "Post{adaptiveBitrateStreaming=$adaptiveBitrateStreaming}" + 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") } @@ -4514,20 +4060,14 @@ private constructor( companion object { @JvmStatic - fun ofSimplePostTransformation(simplePostTransformation: SimplePostTransformation) = - Post(simplePostTransformation = simplePostTransformation) + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) - @JvmStatic - fun ofConvertGifToVideo(convertGifToVideo: ConvertGifToVideo) = - Post(convertGifToVideo = convertGifToVideo) + @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) - @JvmStatic - fun ofGenerateAThumbnail(generateAThumbnail: GenerateAThumbnail) = - Post(generateAThumbnail = generateAThumbnail) + @JvmStatic fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) - @JvmStatic - fun ofAdaptiveBitrateStreaming(adaptiveBitrateStreaming: AdaptiveBitrateStreaming) = - Post(adaptiveBitrateStreaming = adaptiveBitrateStreaming) + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) } /** @@ -4535,17 +4075,13 @@ private constructor( */ interface Visitor { - fun visitSimplePostTransformation( - simplePostTransformation: SimplePostTransformation - ): T + fun visitTransformation(transformation: InnerTransformation): T - fun visitConvertGifToVideo(convertGifToVideo: ConvertGifToVideo): T + fun visitGifToVideo(gifToVideo: GifToVideo): T - fun visitGenerateAThumbnail(generateAThumbnail: GenerateAThumbnail): T + fun visitThumbnail(thumbnail: Thumbnail): T - fun visitAdaptiveBitrateStreaming( - adaptiveBitrateStreaming: AdaptiveBitrateStreaming - ): T + fun visitAbs(abs: Abs): T /** * Maps an unknown variant of [Post] to a value of type [T]. @@ -4566,33 +4102,32 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Post { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Post(simplePostTransformation = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Post(convertGifToVideo = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Post(generateAThumbnail = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Post(adaptiveBitrateStreaming = 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 -> Post(_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) { + "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) } } @@ -4604,23 +4139,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.simplePostTransformation != null -> - generator.writeObject(value.simplePostTransformation) - value.convertGifToVideo != null -> - generator.writeObject(value.convertGifToVideo) - value.generateAThumbnail != null -> - generator.writeObject(value.generateAThumbnail) - value.adaptiveBitrateStreaming != null -> - generator.writeObject(value.adaptiveBitrateStreaming) + 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 SimplePostTransformation + class InnerTransformation private constructor( - private val type: MultipartField, + private val type: JsonValue, private val value: MultipartField, private val additionalProperties: MutableMap, ) { @@ -4628,11 +4159,15 @@ private constructor( /** * Transformation 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 type(): Type = type.value.getRequired("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 @@ -4644,14 +4179,6 @@ private constructor( */ fun value(): String = value.value.getRequired("value") - /** - * Returns the raw multipart value of [type]. - * - * Unlike [type], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type - /** * Returns the raw multipart value of [value]. * @@ -4676,43 +4203,44 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [SimplePostTransformation]. + * [InnerTransformation]. * * The following fields are required: * ```java - * .type() * .value() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [SimplePostTransformation]. */ + /** A builder for [InnerTransformation]. */ class Builder internal constructor() { - private var type: MultipartField? = null + private var type: JsonValue = JsonValue.from("transformation") private var value: MultipartField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(simplePostTransformation: SimplePostTransformation) = apply { - type = simplePostTransformation.type - value = simplePostTransformation.value + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value additionalProperties = - simplePostTransformation.additionalProperties.toMutableMap() + innerTransformation.additionalProperties.toMutableMap() } - /** Transformation type. */ - fun type(type: Type) = type(MultipartField.of(type)) - /** - * Sets [Builder.type] to an arbitrary multipart value. + * Sets the field 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. + * 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: MultipartField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based @@ -4752,21 +4280,20 @@ private constructor( } /** - * Returns an immutable instance of [SimplePostTransformation]. + * Returns an immutable instance of [InnerTransformation]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .type() * .value() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): SimplePostTransformation = - SimplePostTransformation( - checkRequired("type", type), + fun build(): InnerTransformation = + InnerTransformation( + type, checkRequired("value", value), additionalProperties.toMutableMap(), ) @@ -4774,12 +4301,16 @@ private constructor( private var validated: Boolean = false - fun validate(): SimplePostTransformation = apply { + fun validate(): InnerTransformation = apply { if (validated) { return@apply } - type().validate() + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } value() validated = true } @@ -4792,140 +4323,12 @@ private constructor( false } - /** Transformation type. */ - 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") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TRANSFORMATION - } - - /** - * 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, - /** - * 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - 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 SimplePostTransformation && + return other is InnerTransformation && type == other.type && value == other.value && additionalProperties == other.additionalProperties @@ -4938,12 +4341,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SimplePostTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" } - class ConvertGifToVideo + class GifToVideo private constructor( - private val type: MultipartField, + private val type: JsonValue, private val value: MultipartField, private val additionalProperties: MutableMap, ) { @@ -4951,11 +4354,15 @@ private constructor( /** * Converts an animated GIF into an MP4. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * 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 type(): Type = type.value.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Optional transformation string to apply to the output video. **Example**: `q-80` @@ -4965,14 +4372,6 @@ private constructor( */ fun value(): Optional = value.value.getOptional("value") - /** - * Returns the raw multipart value of [type]. - * - * Unlike [type], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type - /** * Returns the raw multipart value of [value]. * @@ -4995,43 +4394,37 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [ConvertGifToVideo]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [GifToVideo]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [ConvertGifToVideo]. */ + /** A builder for [GifToVideo]. */ class Builder internal constructor() { - private var type: MultipartField? = 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(convertGifToVideo: ConvertGifToVideo) = apply { - type = convertGifToVideo.type - value = convertGifToVideo.value - additionalProperties = convertGifToVideo.additionalProperties.toMutableMap() + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = gifToVideo.additionalProperties.toMutableMap() } - /** Converts an animated GIF into an MP4. */ - fun type(type: Type) = type(MultipartField.of(type)) - /** - * Sets [Builder.type] to an arbitrary multipart value. + * Sets the field 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. + * 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: MultipartField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * Optional transformation string to apply to the output video. **Example**: @@ -5071,33 +4464,26 @@ private constructor( } /** - * Returns an immutable instance of [ConvertGifToVideo]. + * Returns an immutable instance of [GifToVideo]. * * 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(): ConvertGifToVideo = - ConvertGifToVideo( - checkRequired("type", type), - value, - additionalProperties.toMutableMap(), - ) + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): ConvertGifToVideo = apply { + fun validate(): GifToVideo = apply { if (validated) { return@apply } - type().validate() + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } value() validated = true } @@ -5110,140 +4496,12 @@ private constructor( false } - /** Converts an animated GIF into an MP4. */ - 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 GIF_TO_VIDEO = of("gif-to-video") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GIF_TO_VIDEO - } - - /** - * 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 { - GIF_TO_VIDEO, - /** - * 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) { - GIF_TO_VIDEO -> Value.GIF_TO_VIDEO - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GIF_TO_VIDEO -> Known.GIF_TO_VIDEO - 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 ConvertGifToVideo && + return other is GifToVideo && type == other.type && value == other.value && additionalProperties == other.additionalProperties @@ -5256,12 +4514,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ConvertGifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" } - class GenerateAThumbnail + class Thumbnail private constructor( - private val type: MultipartField, + private val type: JsonValue, private val value: MultipartField, private val additionalProperties: MutableMap, ) { @@ -5269,11 +4527,15 @@ private constructor( /** * Generates a thumbnail 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). + * 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). */ - fun type(): Type = type.value.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Optional transformation string. **Example**: `w-150,h-150` @@ -5283,14 +4545,6 @@ private constructor( */ fun value(): Optional = value.value.getOptional("value") - /** - * Returns the raw multipart value of [type]. - * - * Unlike [type], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type - /** * Returns the raw multipart value of [value]. * @@ -5313,44 +4567,37 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of - * [GenerateAThumbnail]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [GenerateAThumbnail]. */ + /** A builder for [Thumbnail]. */ class Builder internal constructor() { - private var type: MultipartField? = null + private var type: JsonValue = JsonValue.from("thumbnail") private var value: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(generateAThumbnail: GenerateAThumbnail) = apply { - type = generateAThumbnail.type - value = generateAThumbnail.value - additionalProperties = - generateAThumbnail.additionalProperties.toMutableMap() + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() } - /** Generates a thumbnail image. */ - fun type(type: Type) = type(MultipartField.of(type)) - /** - * Sets [Builder.type] to an arbitrary multipart 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("thumbnail") + * ``` * - * 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. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun type(type: MultipartField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** Optional transformation string. **Example**: `w-150,h-150` */ fun value(value: String) = value(MultipartField.of(value)) @@ -5387,33 +4634,26 @@ private constructor( } /** - * Returns an immutable instance of [GenerateAThumbnail]. + * Returns an immutable instance of [Thumbnail]. * * 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(): GenerateAThumbnail = - GenerateAThumbnail( - checkRequired("type", type), - value, - additionalProperties.toMutableMap(), - ) + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): GenerateAThumbnail = apply { + fun validate(): Thumbnail = apply { if (validated) { return@apply } - type().validate() + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } value() validated = true } @@ -5426,140 +4666,12 @@ private constructor( false } - /** Generates a thumbnail image. */ - 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 THUMBNAIL = of("thumbnail") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - 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 { - 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) { - 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) { - 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() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GenerateAThumbnail && + return other is Thumbnail && type == other.type && value == other.value && additionalProperties == other.additionalProperties @@ -5572,13 +4684,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GenerateAThumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" } - class AdaptiveBitrateStreaming + class Abs private constructor( private val protocol: MultipartField, - private val type: MultipartField, + private val type: JsonValue, private val value: MultipartField, private val additionalProperties: MutableMap, ) { @@ -5595,11 +4707,15 @@ private constructor( /** * Adaptive Bitrate Streaming (ABS) setup. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). + * 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). */ - fun type(): Type = type.value.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * List of different representations you want to create separated by an underscore. @@ -5620,14 +4736,6 @@ private constructor( @ExcludeMissing fun _protocol(): MultipartField = protocol - /** - * Returns the raw multipart value of [type]. - * - * Unlike [type], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): MultipartField = type - /** * Returns the raw multipart value of [value]. * @@ -5651,34 +4759,31 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AdaptiveBitrateStreaming]. + * Returns a mutable builder for constructing an instance of [Abs]. * * The following fields are required: * ```java * .protocol() - * .type() * .value() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AdaptiveBitrateStreaming]. */ + /** A builder for [Abs]. */ class Builder internal constructor() { private var protocol: MultipartField? = null - private var type: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") private var value: MultipartField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(adaptiveBitrateStreaming: AdaptiveBitrateStreaming) = apply { - protocol = adaptiveBitrateStreaming.protocol - type = adaptiveBitrateStreaming.type - value = adaptiveBitrateStreaming.value - additionalProperties = - adaptiveBitrateStreaming.additionalProperties.toMutableMap() + 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`). */ @@ -5695,17 +4800,19 @@ private constructor( this.protocol = protocol } - /** Adaptive Bitrate Streaming (ABS) setup. */ - fun type(type: Type) = type(MultipartField.of(type)) - /** - * Sets [Builder.type] to an arbitrary multipart value. + * Sets the field 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. + * 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: MultipartField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * List of different representations you want to create separated by an @@ -5745,23 +4852,22 @@ private constructor( } /** - * Returns an immutable instance of [AdaptiveBitrateStreaming]. + * Returns an immutable instance of [Abs]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .protocol() - * .type() * .value() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AdaptiveBitrateStreaming = - AdaptiveBitrateStreaming( + fun build(): Abs = + Abs( checkRequired("protocol", protocol), - checkRequired("type", type), + type, checkRequired("value", value), additionalProperties.toMutableMap(), ) @@ -5769,13 +4875,17 @@ private constructor( private var validated: Boolean = false - fun validate(): AdaptiveBitrateStreaming = apply { + fun validate(): Abs = apply { if (validated) { return@apply } protocol().validate() - type().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } value() validated = true } @@ -5924,140 +5034,12 @@ private constructor( override fun toString() = value.toString() } - /** Adaptive Bitrate Streaming (ABS) setup. */ - 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 ABS = of("abs") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ABS - } - - /** - * 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 { - ABS, - /** - * 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) { - ABS -> Value.ABS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - ABS -> Known.ABS - 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 AdaptiveBitrateStreaming && + return other is Abs && protocol == other.protocol && type == other.type && value == other.value && @@ -6071,7 +5053,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AdaptiveBitrateStreaming{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" } } 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 index fb9504c0..87809f44 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt @@ -15,8 +15,7 @@ internal class UrlEndpointCreateParamsTest { .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type(UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY) + UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -31,11 +30,7 @@ internal class UrlEndpointCreateParamsTest { .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) + UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -49,11 +44,7 @@ internal class UrlEndpointCreateParamsTest { assertThat(body.urlRewriter()) .contains( UrlEndpointCreateParams.UrlRewriter.ofCloudinary( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) + UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) 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 index 0019ab2c..bdd96b6c 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt @@ -16,8 +16,7 @@ internal class UrlEndpointUpdateParamsTest { .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type(UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY) + UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -43,11 +42,7 @@ internal class UrlEndpointUpdateParamsTest { .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) + UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -61,11 +56,7 @@ internal class UrlEndpointUpdateParamsTest { assertThat(body.urlRewriter()) .contains( UrlEndpointUpdateParams.UrlRewriter.ofCloudinary( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) + UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .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 f34d18bc..6014cd06 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 @@ -26,10 +26,9 @@ internal class FileUploadParamsTest { ) .description("Running shoes") .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -63,25 +62,13 @@ internal class FileUploadParamsTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() - .protocol( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.Type - .ABS - ) + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) .value("sr-240_360_480_720_1080") .build() ) @@ -110,10 +97,9 @@ internal class FileUploadParamsTest { ) .description("Running shoes") .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -149,26 +135,13 @@ internal class FileUploadParamsTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() - .protocol( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .Type - .ABS - ) + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) .value("sr-240_360_480_720_1080") .build() ) @@ -207,15 +180,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - FileUploadParams.Extension.ofRemovedotBg( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name - .REMOVE_BG - ) + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension - .Options + FileUploadParams.Extension.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -257,33 +225,16 @@ internal class FileUploadParamsTest { MultipartField.of( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post - .GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol + FileUploadParams.Transformation.Post.Abs.Protocol .DASH ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS - ) .value("sr-240_360_480_720_1080") .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 212f5dfc..bd43f8d5 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 @@ -27,10 +27,9 @@ internal class FileUploadParamsTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -66,25 +65,13 @@ internal class FileUploadParamsTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() - .protocol( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.Type - .ABS - ) + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) .value("sr-240_360_480_720_1080") .build() ) @@ -114,10 +101,9 @@ internal class FileUploadParamsTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -155,26 +141,13 @@ internal class FileUploadParamsTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() - .protocol( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .Type - .ABS - ) + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) .value("sr-240_360_480_720_1080") .build() ) @@ -214,15 +187,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - FileUploadParams.Extension.ofRemovedotBg( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name - .REMOVE_BG - ) + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension - .Options + FileUploadParams.Extension.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -266,33 +234,16 @@ internal class FileUploadParamsTest { MultipartField.of( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post - .GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol + FileUploadParams.Transformation.Post.Abs.Protocol .DASH ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS - ) .value("sr-240_360_480_720_1080") .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 638f2e35..b4e13c9c 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 @@ -87,13 +87,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -132,30 +128,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -202,13 +182,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -247,30 +223,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -317,13 +277,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -362,30 +318,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -432,13 +372,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -477,30 +413,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -547,13 +467,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -592,30 +508,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -662,13 +562,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -707,30 +603,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -777,13 +657,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -822,30 +698,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -892,13 +752,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -937,30 +793,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1007,13 +847,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1052,30 +888,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1122,13 +942,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1167,30 +983,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1237,13 +1037,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1282,30 +1078,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1352,13 +1132,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1397,30 +1173,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1467,13 +1227,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1512,30 +1268,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1582,13 +1322,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1627,30 +1363,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1697,13 +1417,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1742,30 +1458,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1812,13 +1512,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1857,30 +1553,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1925,13 +1605,9 @@ internal class ErrorHandlingTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name( - FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG - ) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options - .builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1970,30 +1646,14 @@ internal class ErrorHandlingTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail - .Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.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 4a8e74c3..48b0f08d 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 @@ -59,10 +59,9 @@ internal class ServiceParamsTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -100,26 +99,13 @@ internal class ServiceParamsTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming.builder() - .protocol( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .Type - .ABS - ) + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.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/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index af701200..d8e6799b 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 @@ -237,10 +237,9 @@ internal class FileServiceAsyncTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -279,28 +278,14 @@ internal class FileServiceAsyncTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.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/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt index d369a913..607f0f1b 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 @@ -31,11 +31,7 @@ internal class UrlEndpointServiceAsyncTest { .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) + UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -65,11 +61,7 @@ internal class UrlEndpointServiceAsyncTest { .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) + UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .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 73140c41..152694fa 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 @@ -40,10 +40,9 @@ internal class FileServiceAsyncTest { ) .description("Running shoes") .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -80,28 +79,14 @@ internal class FileServiceAsyncTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.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/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 1510c6e9..68654463 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 @@ -230,10 +230,9 @@ internal class FileServiceTest { .description("Running shoes") .expire(0L) .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -272,28 +271,14 @@ internal class FileServiceTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.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/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt index be2df93b..d2070ee2 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 @@ -31,11 +31,7 @@ internal class UrlEndpointServiceTest { .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type( - UrlEndpointCreateParams.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) + UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -64,11 +60,7 @@ internal class UrlEndpointServiceTest { .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.builder() - .type( - UrlEndpointUpdateParams.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) + UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .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 ea4d43ff..d92b160a 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 @@ -40,10 +40,9 @@ internal class FileServiceTest { ) .description("Running shoes") .addExtension( - FileUploadParams.Extension.RemovedotBgExtension.builder() - .name(FileUploadParams.Extension.RemovedotBgExtension.Name.REMOVE_BG) + FileUploadParams.Extension.RemoveBg.builder() .options( - FileUploadParams.Extension.RemovedotBgExtension.Options.builder() + FileUploadParams.Extension.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -80,28 +79,14 @@ internal class FileServiceTest { .transformation( FileUploadParams.Transformation.builder() .addPost( - FileUploadParams.Transformation.Post.GenerateAThumbnail.builder() - .type( - FileUploadParams.Transformation.Post.GenerateAThumbnail.Type - .THUMBNAIL - ) + FileUploadParams.Transformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.AdaptiveBitrateStreaming - .builder() + FileUploadParams.Transformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Protocol - .DASH - ) - .type( - FileUploadParams.Transformation.Post - .AdaptiveBitrateStreaming - .Type - .ABS + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() From 2c1059ca6d32c2a7f4d76b079ebc97011d0ab8de Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 10:16:47 +0000 Subject: [PATCH 022/125] feat(api): manual updates --- .stats.yml | 4 +- .../accounts/origins/OriginCreateParams.kt | 1464 +++-------------- .../accounts/origins/OriginCreateResponse.kt | 1356 ++++----------- .../accounts/origins/OriginGetResponse.kt | 1356 ++++----------- .../accounts/origins/OriginListResponse.kt | 1356 ++++----------- .../accounts/origins/OriginUpdateParams.kt | 1463 +++------------- .../accounts/origins/OriginUpdateResponse.kt | 1356 ++++----------- .../urlendpoints/UrlEndpointCreateResponse.kt | 812 +-------- .../urlendpoints/UrlEndpointGetResponse.kt | 812 +-------- .../urlendpoints/UrlEndpointListResponse.kt | 812 +-------- .../urlendpoints/UrlEndpointUpdateResponse.kt | 812 +-------- .../api/models/files/FileUpdateParams.kt | 185 +-- .../origins/OriginCreateParamsTest.kt | 5 - .../origins/OriginCreateResponseTest.kt | 12 - .../accounts/origins/OriginGetResponseTest.kt | 12 - .../origins/OriginListResponseTest.kt | 12 - .../origins/OriginUpdateParamsTest.kt | 6 - .../origins/OriginUpdateResponseTest.kt | 12 - .../UrlEndpointCreateResponseTest.kt | 12 - .../UrlEndpointGetResponseTest.kt | 9 - .../UrlEndpointListResponseTest.kt | 12 - .../UrlEndpointUpdateResponseTest.kt | 12 - .../async/accounts/OriginServiceAsyncTest.kt | 2 - .../blocking/accounts/OriginServiceTest.kt | 2 - 24 files changed, 2078 insertions(+), 9818 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9d8aa405..9c64de6b 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-6c237ebd6f81741286e7cfbaeac1356da3e18c7fe43b74d6c358d62bfb40dbb9.yml -openapi_spec_hash: ad6a65d74e3eb865a5d2915177f92ea7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-5ed7a3dbaf059adbd91e86cd61520f59c5fdcc8df3f561df9ab07d7afb722f18.yml +openapi_spec_hash: 51d4d2be59d5d3f81a695a9b8786c77e config_hash: b75c4e4432c2d0650589863f8336849b 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 2066e7a6..3329192a 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 @@ -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 @@ -30,7 +29,6 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams @@ -583,7 +581,7 @@ private constructor( private val bucket: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -602,7 +600,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -659,11 +657,15 @@ private constructor( fun secretKey(): String = secretKey.getRequired("secretKey") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -725,13 +727,6 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -782,7 +777,6 @@ private constructor( * .bucket() * .name() * .secretKey() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -795,7 +789,7 @@ private constructor( private var bucket: JsonField? = null private var name: JsonField? = null private var secretKey: JsonField? = null - private var type: 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() @@ -862,16 +856,19 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("S3") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -949,7 +946,6 @@ private constructor( * .bucket() * .name() * .secretKey() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -960,7 +956,7 @@ private constructor( checkRequired("bucket", bucket), checkRequired("name", name), checkRequired("secretKey", secretKey), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -979,7 +975,11 @@ private constructor( bucket() name() secretKey() - type().validate() + _type().let { + if (it != JsonValue.from("S3")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1006,135 +1006,11 @@ private constructor( (if (bucket.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (secretKey.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 S3 = of("S3") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3 - } - - /** - * 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 { - S3, - /** - * 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) { - S3 -> Value.S3 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - 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 @@ -1179,7 +1055,7 @@ private constructor( private val endpoint: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1202,7 +1078,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1275,11 +1151,15 @@ private constructor( fun secretKey(): String = secretKey.getRequired("secretKey") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1358,13 +1238,6 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1426,7 +1299,6 @@ private constructor( * .endpoint() * .name() * .secretKey() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1440,7 +1312,7 @@ private constructor( private var endpoint: JsonField? = null private var name: JsonField? = null private var secretKey: JsonField? = null - private var type: 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() @@ -1522,16 +1394,19 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("S3_COMPATIBLE") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1625,7 +1500,6 @@ private constructor( * .endpoint() * .name() * .secretKey() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1637,7 +1511,7 @@ private constructor( checkRequired("endpoint", endpoint), checkRequired("name", name), checkRequired("secretKey", secretKey), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1658,7 +1532,11 @@ private constructor( endpoint() name() secretKey() - type().validate() + _type().let { + if (it != JsonValue.from("S3_COMPATIBLE")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1687,136 +1565,12 @@ private constructor( (if (endpoint.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (secretKey.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3_COMPATIBLE - } - - /** - * 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 { - S3_COMPATIBLE, - /** - * 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) { - S3_COMPATIBLE -> Value.S3_COMPATIBLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3_COMPATIBLE -> Known.S3_COMPATIBLE - 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 @@ -1864,7 +1618,7 @@ private constructor( private val bucket: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1883,7 +1637,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1940,11 +1694,15 @@ private constructor( fun secretKey(): String = secretKey.getRequired("secretKey") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2006,13 +1764,6 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -2063,7 +1814,6 @@ private constructor( * .bucket() * .name() * .secretKey() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2076,7 +1826,7 @@ private constructor( private var bucket: JsonField? = null private var name: JsonField? = null private var secretKey: JsonField? = null - private var type: 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() @@ -2143,16 +1893,19 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("CLOUDINARY_BACKUP") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2230,7 +1983,6 @@ private constructor( * .bucket() * .name() * .secretKey() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2241,7 +1993,7 @@ private constructor( checkRequired("bucket", bucket), checkRequired("name", name), checkRequired("secretKey", secretKey), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -2260,7 +2012,11 @@ private constructor( bucket() name() secretKey() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY_BACKUP")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -2287,135 +2043,11 @@ private constructor( (if (bucket.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (secretKey.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY_BACKUP - } - - /** - * 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 { - CLOUDINARY_BACKUP, - /** - * 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) { - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - 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 @@ -2457,7 +2089,7 @@ private constructor( private constructor( private val baseUrl: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, @@ -2470,7 +2102,7 @@ private constructor( @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2509,11 +2141,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2556,13 +2192,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2614,7 +2243,6 @@ private constructor( * ```java * .baseUrl() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2625,7 +2253,7 @@ private constructor( private var baseUrl: JsonField? = null private var name: JsonField? = null - private var type: 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() @@ -2666,16 +2294,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("WEB_FOLDER") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2755,7 +2386,6 @@ private constructor( * ```java * .baseUrl() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2764,7 +2394,7 @@ private constructor( WebFolder( checkRequired("baseUrl", baseUrl), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, forwardHostHeaderToOrigin, includeCanonicalHeader, @@ -2781,7 +2411,11 @@ private constructor( baseUrl() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_FOLDER")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() forwardHostHeaderToOrigin() includeCanonicalHeader() @@ -2806,181 +2440,57 @@ private constructor( internal fun validity(): Int = (if (baseUrl.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + 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 + } - @JvmField val WEB_FOLDER = of("WEB_FOLDER") + private val hashCode: Int by lazy { + Objects.hash( + baseUrl, + name, + type, + baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + additionalProperties, + ) + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_FOLDER - } + override fun toString() = + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + } - /** - * 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 { - WEB_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) { - WEB_FOLDER -> Value.WEB_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) { - WEB_FOLDER -> Known.WEB_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 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: JsonField, - private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val additionalProperties: MutableMap, - ) { + 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: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2999,11 +2509,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3030,13 +2544,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -3077,7 +2584,6 @@ private constructor( * The following fields are required: * ```java * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3087,7 +2593,7 @@ private constructor( class Builder internal constructor() { private var name: JsonField? = null - private var type: 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() @@ -3113,16 +2619,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("WEB_PROXY") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3185,7 +2694,6 @@ private constructor( * The following fields are required: * ```java * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -3193,7 +2701,7 @@ private constructor( fun build(): WebProxy = WebProxy( checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, additionalProperties.toMutableMap(), @@ -3208,7 +2716,11 @@ private constructor( } name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_PROXY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() validated = true @@ -3231,134 +2743,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 WEB_PROXY = of("WEB_PROXY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_PROXY - } - - /** - * 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 { - WEB_PROXY, - /** - * 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) { - WEB_PROXY -> Value.WEB_PROXY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_PROXY -> Known.WEB_PROXY - 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 @@ -3394,7 +2782,7 @@ private constructor( private val clientEmail: JsonField, private val name: JsonField, private val privateKey: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -3413,7 +2801,7 @@ private constructor( @JsonProperty("privateKey") @ExcludeMissing privateKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3464,11 +2852,15 @@ private constructor( fun privateKey(): String = privateKey.getRequired("privateKey") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3528,13 +2920,6 @@ private constructor( @ExcludeMissing fun _privateKey(): JsonField = privateKey - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3586,7 +2971,6 @@ private constructor( * .clientEmail() * .name() * .privateKey() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3599,7 +2983,7 @@ private constructor( private var clientEmail: JsonField? = null private var name: JsonField? = null private var privateKey: JsonField? = null - private var type: 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() @@ -3667,16 +3051,19 @@ private constructor( this.privateKey = privateKey } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("GCS") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3753,7 +3140,6 @@ private constructor( * .clientEmail() * .name() * .privateKey() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -3764,7 +3150,7 @@ private constructor( checkRequired("clientEmail", clientEmail), checkRequired("name", name), checkRequired("privateKey", privateKey), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3783,7 +3169,11 @@ private constructor( clientEmail() name() privateKey() - type().validate() + _type().let { + if (it != JsonValue.from("GCS")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -3810,135 +3200,11 @@ private constructor( (if (clientEmail.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (privateKey.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 GCS = of("GCS") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GCS - } - - /** - * 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 { - GCS, - /** - * 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) { - GCS -> Value.GCS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GCS -> Known.GCS - 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 @@ -3982,7 +3248,7 @@ private constructor( private val container: JsonField, private val name: JsonField, private val sasToken: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -4001,7 +3267,7 @@ private constructor( @JsonProperty("sasToken") @ExcludeMissing sasToken: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -4052,11 +3318,15 @@ private constructor( fun sasToken(): String = sasToken.getRequired("sasToken") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -4117,13 +3387,6 @@ private constructor( */ @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -4174,7 +3437,6 @@ private constructor( * .container() * .name() * .sasToken() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -4187,7 +3449,7 @@ private constructor( private var container: JsonField? = null private var name: JsonField? = null private var sasToken: JsonField? = null - private var type: 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() @@ -4253,16 +3515,19 @@ private constructor( */ fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("AZURE_BLOB") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -4339,7 +3604,6 @@ private constructor( * .container() * .name() * .sasToken() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -4350,7 +3614,7 @@ private constructor( checkRequired("container", container), checkRequired("name", name), checkRequired("sasToken", sasToken), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -4369,7 +3633,11 @@ private constructor( container() name() sasToken() - type().validate() + _type().let { + if (it != JsonValue.from("AZURE_BLOB")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -4396,135 +3664,11 @@ private constructor( (if (container.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (sasToken.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 AZURE_BLOB = of("AZURE_BLOB") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AZURE_BLOB - } - - /** - * 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 { - AZURE_BLOB, - /** - * 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) { - AZURE_BLOB -> Value.AZURE_BLOB - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AZURE_BLOB -> Known.AZURE_BLOB - 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 @@ -4569,7 +3713,7 @@ private constructor( private val clientSecret: JsonField, private val name: JsonField, private val password: JsonField, - private val type: JsonField, + private val type: JsonValue, private val username: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, @@ -4591,7 +3735,7 @@ private constructor( @JsonProperty("password") @ExcludeMissing password: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), @@ -4660,11 +3804,15 @@ private constructor( fun password(): String = password.getRequired("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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Akeneo API username. @@ -4733,13 +3881,6 @@ private constructor( */ @JsonProperty("password") @ExcludeMissing fun _password(): JsonField = password - /** - * 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 [username]. * @@ -4792,7 +3933,6 @@ private constructor( * .clientSecret() * .name() * .password() - * .type() * .username() * ``` */ @@ -4807,7 +3947,7 @@ private constructor( private var clientSecret: JsonField? = null private var name: JsonField? = null private var password: JsonField? = null - private var type: 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() @@ -4889,16 +4029,19 @@ private constructor( */ fun password(password: JsonField) = apply { this.password = password } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("AKENEO_PIM") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** Akeneo API username. */ fun username(username: String) = username(JsonField.of(username)) @@ -4977,7 +4120,6 @@ private constructor( * .clientSecret() * .name() * .password() - * .type() * .username() * ``` * @@ -4990,7 +4132,7 @@ private constructor( checkRequired("clientSecret", clientSecret), checkRequired("name", name), checkRequired("password", password), - checkRequired("type", type), + type, checkRequired("username", username), baseUrlForCanonicalHeader, includeCanonicalHeader, @@ -5010,7 +4152,11 @@ private constructor( clientSecret() name() password() - type().validate() + _type().let { + if (it != JsonValue.from("AKENEO_PIM")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } username() baseUrlForCanonicalHeader() includeCanonicalHeader() @@ -5038,135 +4184,11 @@ private constructor( (if (clientSecret.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (password.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKENEO_PIM - } - - /** - * 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 { - AKENEO_PIM, - /** - * 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) { - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKENEO_PIM -> Known.AKENEO_PIM - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt index d9c5a23b..b9be7155 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt @@ -1554,7 +1554,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -1568,7 +1568,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1626,10 +1626,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1678,13 +1683,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1719,7 +1717,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1733,7 +1730,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1815,16 +1812,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1872,7 +1872,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1884,7 +1883,7 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -1902,7 +1901,11 @@ private constructor( includeCanonicalHeader() name() prefix() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY_BACKUP")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -1928,130 +1931,9 @@ private constructor( (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY_BACKUP - } - - /** - * 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 { - CLOUDINARY_BACKUP, - /** 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) { - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - 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 @@ -2094,7 +1976,7 @@ private constructor( private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -2110,7 +1992,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2169,10 +2051,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2224,13 +2111,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2265,7 +2145,6 @@ private constructor( * .forwardHostHeaderToOrigin() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2279,7 +2158,7 @@ private constructor( private var forwardHostHeaderToOrigin: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_FOLDER") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2364,16 +2243,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2421,7 +2303,6 @@ private constructor( * .forwardHostHeaderToOrigin() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2433,7 +2314,7 @@ private constructor( checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -2451,7 +2332,11 @@ private constructor( forwardHostHeaderToOrigin() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_FOLDER")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -2477,174 +2362,53 @@ private constructor( (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("WEB_FOLDER")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + 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 + } - @JvmField val WEB_FOLDER = of("WEB_FOLDER") + private val hashCode: Int by lazy { + Objects.hash( + id, + baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_FOLDER - } + override fun toString() = + "WebFolder{id=$id, baseUrl=$baseUrl, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } - /** - * 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 { - WEB_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) { - WEB_FOLDER -> Value.WEB_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) { - WEB_FOLDER -> Known.WEB_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 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: JsonField, - private val baseUrlForCanonicalHeader: JsonField, - private val additionalProperties: MutableMap, - ) { + 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( @@ -2653,7 +2417,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2686,10 +2450,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2724,13 +2493,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2763,7 +2525,6 @@ private constructor( * .id() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2775,7 +2536,7 @@ private constructor( private var id: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_PROXY") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2831,16 +2592,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2886,7 +2650,6 @@ private constructor( * .id() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2896,7 +2659,7 @@ private constructor( checkRequired("id", id), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -2912,7 +2675,11 @@ private constructor( id() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_PROXY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -2936,130 +2703,9 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 WEB_PROXY = of("WEB_PROXY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_PROXY - } - - /** - * 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 { - WEB_PROXY, - /** 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) { - WEB_PROXY -> Value.WEB_PROXY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_PROXY -> Known.WEB_PROXY - 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 @@ -3099,7 +2745,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -3116,7 +2762,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3177,10 +2823,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3238,13 +2889,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3280,7 +2924,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3295,7 +2938,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("GCS") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3389,16 +3032,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3447,7 +3093,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -3460,175 +3105,58 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), - baseUrlForCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GoogleCloudStorageGcs = apply { - if (validated) { - return@apply - } - - id() - bucket() - clientEmail() - includeCanonicalHeader() - name() - prefix() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 GCS = of("GCS") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GCS - } - - /** - * 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 { - GCS, - /** 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) { - GCS -> Value.GCS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GCS -> Known.GCS - 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 - } + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private var validated: Boolean = false - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } - return other is Type && value == other.value + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + prefix() + _type().let { + if (it != JsonValue.from("GCS")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } } + baseUrlForCanonicalHeader() + 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 (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) { @@ -3675,7 +3203,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -3694,7 +3222,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3755,10 +3283,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3816,13 +3349,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3858,7 +3384,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3873,7 +3398,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("AZURE_BLOB") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3967,16 +3492,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3989,225 +3517,107 @@ private constructor( * [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 [AzureBlobStorage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .accountName() - * .container() - * .includeCanonicalHeader() - * .name() - * .prefix() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AzureBlobStorage = - AzureBlobStorage( - checkRequired("id", id), - checkRequired("accountName", accountName), - checkRequired("container", container), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), - checkRequired("name", name), - checkRequired("prefix", prefix), - checkRequired("type", type), - baseUrlForCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AzureBlobStorage = apply { - if (validated) { - return@apply - } - - id() - accountName() - container() - includeCanonicalHeader() - name() - prefix() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 AZURE_BLOB = of("AZURE_BLOB") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AZURE_BLOB - } - - /** - * 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 { - AZURE_BLOB, - /** 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) { - AZURE_BLOB -> Value.AZURE_BLOB - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AZURE_BLOB -> Known.AZURE_BLOB - 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") - } + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): Type = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - known() - validated = true + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [AzureBlobStorage]. * - * Used for best match union deserialization. + * 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. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Type && value == other.value + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + 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 @@ -4251,7 +3661,7 @@ private constructor( private val baseUrl: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -4264,7 +3674,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -4313,10 +3723,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -4358,13 +3773,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -4398,7 +3806,6 @@ private constructor( * .baseUrl() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -4411,7 +3818,7 @@ private constructor( private var baseUrl: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("AKENEO_PIM") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4480,16 +3887,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -4536,7 +3946,6 @@ private constructor( * .baseUrl() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -4547,7 +3956,7 @@ private constructor( checkRequired("baseUrl", baseUrl), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -4564,7 +3973,11 @@ private constructor( baseUrl() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("AKENEO_PIM")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -4589,130 +4002,9 @@ private constructor( (if (baseUrl.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("AKENEO_PIM")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKENEO_PIM - } - - /** - * 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 { - AKENEO_PIM, - /** 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) { - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKENEO_PIM -> Known.AKENEO_PIM - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt index 0a4e045b..2c38cc97 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt @@ -1551,7 +1551,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -1565,7 +1565,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1623,10 +1623,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1675,13 +1680,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1716,7 +1714,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1730,7 +1727,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1812,16 +1809,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1869,7 +1869,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1881,7 +1880,7 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -1899,7 +1898,11 @@ private constructor( includeCanonicalHeader() name() prefix() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY_BACKUP")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -1925,130 +1928,9 @@ private constructor( (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY_BACKUP - } - - /** - * 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 { - CLOUDINARY_BACKUP, - /** 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) { - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - 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 @@ -2091,7 +1973,7 @@ private constructor( private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -2107,7 +1989,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2166,10 +2048,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2221,13 +2108,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2262,7 +2142,6 @@ private constructor( * .forwardHostHeaderToOrigin() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2276,7 +2155,7 @@ private constructor( private var forwardHostHeaderToOrigin: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_FOLDER") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2361,16 +2240,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2418,7 +2300,6 @@ private constructor( * .forwardHostHeaderToOrigin() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2430,7 +2311,7 @@ private constructor( checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -2448,7 +2329,11 @@ private constructor( forwardHostHeaderToOrigin() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_FOLDER")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -2474,174 +2359,53 @@ private constructor( (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("WEB_FOLDER")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + 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 + } - @JvmField val WEB_FOLDER = of("WEB_FOLDER") + private val hashCode: Int by lazy { + Objects.hash( + id, + baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_FOLDER - } + override fun toString() = + "WebFolder{id=$id, baseUrl=$baseUrl, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } - /** - * 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 { - WEB_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) { - WEB_FOLDER -> Value.WEB_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) { - WEB_FOLDER -> Known.WEB_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 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: JsonField, - private val baseUrlForCanonicalHeader: JsonField, - private val additionalProperties: MutableMap, - ) { + 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( @@ -2650,7 +2414,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2683,10 +2447,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2721,13 +2490,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2760,7 +2522,6 @@ private constructor( * .id() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2772,7 +2533,7 @@ private constructor( private var id: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_PROXY") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2828,16 +2589,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2883,7 +2647,6 @@ private constructor( * .id() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2893,7 +2656,7 @@ private constructor( checkRequired("id", id), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -2909,7 +2672,11 @@ private constructor( id() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_PROXY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -2933,130 +2700,9 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 WEB_PROXY = of("WEB_PROXY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_PROXY - } - - /** - * 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 { - WEB_PROXY, - /** 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) { - WEB_PROXY -> Value.WEB_PROXY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_PROXY -> Known.WEB_PROXY - 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 @@ -3096,7 +2742,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -3113,7 +2759,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3174,10 +2820,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3235,13 +2886,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3277,7 +2921,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3292,7 +2935,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("GCS") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3386,16 +3029,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3444,7 +3090,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -3457,175 +3102,58 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), - baseUrlForCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GoogleCloudStorageGcs = apply { - if (validated) { - return@apply - } - - id() - bucket() - clientEmail() - includeCanonicalHeader() - name() - prefix() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 GCS = of("GCS") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GCS - } - - /** - * 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 { - GCS, - /** 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) { - GCS -> Value.GCS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GCS -> Known.GCS - 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 - } + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private var validated: Boolean = false - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } - return other is Type && value == other.value + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + prefix() + _type().let { + if (it != JsonValue.from("GCS")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } } + baseUrlForCanonicalHeader() + 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 (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) { @@ -3672,7 +3200,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -3691,7 +3219,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3752,10 +3280,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3813,13 +3346,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3855,7 +3381,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3870,7 +3395,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("AZURE_BLOB") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3964,16 +3489,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3986,225 +3514,107 @@ private constructor( * [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 [AzureBlobStorage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .accountName() - * .container() - * .includeCanonicalHeader() - * .name() - * .prefix() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AzureBlobStorage = - AzureBlobStorage( - checkRequired("id", id), - checkRequired("accountName", accountName), - checkRequired("container", container), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), - checkRequired("name", name), - checkRequired("prefix", prefix), - checkRequired("type", type), - baseUrlForCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AzureBlobStorage = apply { - if (validated) { - return@apply - } - - id() - accountName() - container() - includeCanonicalHeader() - name() - prefix() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 AZURE_BLOB = of("AZURE_BLOB") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AZURE_BLOB - } - - /** - * 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 { - AZURE_BLOB, - /** 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) { - AZURE_BLOB -> Value.AZURE_BLOB - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AZURE_BLOB -> Known.AZURE_BLOB - 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") - } + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): Type = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - known() - validated = true + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [AzureBlobStorage]. * - * Used for best match union deserialization. + * 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. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Type && value == other.value + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + 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 @@ -4248,7 +3658,7 @@ private constructor( private val baseUrl: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -4261,7 +3671,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -4310,10 +3720,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -4355,13 +3770,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -4395,7 +3803,6 @@ private constructor( * .baseUrl() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -4408,7 +3815,7 @@ private constructor( private var baseUrl: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("AKENEO_PIM") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4477,16 +3884,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -4533,7 +3943,6 @@ private constructor( * .baseUrl() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -4544,7 +3953,7 @@ private constructor( checkRequired("baseUrl", baseUrl), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -4561,7 +3970,11 @@ private constructor( baseUrl() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("AKENEO_PIM")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -4586,130 +3999,9 @@ private constructor( (if (baseUrl.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("AKENEO_PIM")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKENEO_PIM - } - - /** - * 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 { - AKENEO_PIM, - /** 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) { - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKENEO_PIM -> Known.AKENEO_PIM - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt index 8bc89a12..14ab163a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt @@ -1551,7 +1551,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -1565,7 +1565,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1623,10 +1623,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1675,13 +1680,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1716,7 +1714,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1730,7 +1727,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1812,16 +1809,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1869,7 +1869,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1881,7 +1880,7 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -1899,7 +1898,11 @@ private constructor( includeCanonicalHeader() name() prefix() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY_BACKUP")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -1925,130 +1928,9 @@ private constructor( (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY_BACKUP - } - - /** - * 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 { - CLOUDINARY_BACKUP, - /** 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) { - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - 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 @@ -2091,7 +1973,7 @@ private constructor( private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -2107,7 +1989,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2166,10 +2048,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2221,13 +2108,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2262,7 +2142,6 @@ private constructor( * .forwardHostHeaderToOrigin() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2276,7 +2155,7 @@ private constructor( private var forwardHostHeaderToOrigin: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_FOLDER") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2361,16 +2240,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2418,7 +2300,6 @@ private constructor( * .forwardHostHeaderToOrigin() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2430,7 +2311,7 @@ private constructor( checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -2448,7 +2329,11 @@ private constructor( forwardHostHeaderToOrigin() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_FOLDER")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -2474,174 +2359,53 @@ private constructor( (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("WEB_FOLDER")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + 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 + } - @JvmField val WEB_FOLDER = of("WEB_FOLDER") + private val hashCode: Int by lazy { + Objects.hash( + id, + baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_FOLDER - } + override fun toString() = + "WebFolder{id=$id, baseUrl=$baseUrl, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } - /** - * 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 { - WEB_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) { - WEB_FOLDER -> Value.WEB_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) { - WEB_FOLDER -> Known.WEB_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 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: JsonField, - private val baseUrlForCanonicalHeader: JsonField, - private val additionalProperties: MutableMap, - ) { + 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( @@ -2650,7 +2414,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2683,10 +2447,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2721,13 +2490,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2760,7 +2522,6 @@ private constructor( * .id() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2772,7 +2533,7 @@ private constructor( private var id: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_PROXY") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2828,16 +2589,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2883,7 +2647,6 @@ private constructor( * .id() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2893,7 +2656,7 @@ private constructor( checkRequired("id", id), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -2909,7 +2672,11 @@ private constructor( id() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_PROXY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -2933,130 +2700,9 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 WEB_PROXY = of("WEB_PROXY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_PROXY - } - - /** - * 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 { - WEB_PROXY, - /** 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) { - WEB_PROXY -> Value.WEB_PROXY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_PROXY -> Known.WEB_PROXY - 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 @@ -3096,7 +2742,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -3113,7 +2759,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3174,10 +2820,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3235,13 +2886,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3277,7 +2921,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3292,7 +2935,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("GCS") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3386,16 +3029,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3444,7 +3090,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -3457,175 +3102,58 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), - baseUrlForCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GoogleCloudStorageGcs = apply { - if (validated) { - return@apply - } - - id() - bucket() - clientEmail() - includeCanonicalHeader() - name() - prefix() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 GCS = of("GCS") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GCS - } - - /** - * 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 { - GCS, - /** 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) { - GCS -> Value.GCS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GCS -> Known.GCS - 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 - } + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private var validated: Boolean = false - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } - return other is Type && value == other.value + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + prefix() + _type().let { + if (it != JsonValue.from("GCS")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } } + baseUrlForCanonicalHeader() + 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 (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) { @@ -3672,7 +3200,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -3691,7 +3219,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3752,10 +3280,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3813,13 +3346,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3855,7 +3381,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3870,7 +3395,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("AZURE_BLOB") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3964,16 +3489,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3986,225 +3514,107 @@ private constructor( * [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 [AzureBlobStorage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .accountName() - * .container() - * .includeCanonicalHeader() - * .name() - * .prefix() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AzureBlobStorage = - AzureBlobStorage( - checkRequired("id", id), - checkRequired("accountName", accountName), - checkRequired("container", container), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), - checkRequired("name", name), - checkRequired("prefix", prefix), - checkRequired("type", type), - baseUrlForCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AzureBlobStorage = apply { - if (validated) { - return@apply - } - - id() - accountName() - container() - includeCanonicalHeader() - name() - prefix() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 AZURE_BLOB = of("AZURE_BLOB") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AZURE_BLOB - } - - /** - * 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 { - AZURE_BLOB, - /** 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) { - AZURE_BLOB -> Value.AZURE_BLOB - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AZURE_BLOB -> Known.AZURE_BLOB - 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") - } + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): Type = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - known() - validated = true + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [AzureBlobStorage]. * - * Used for best match union deserialization. + * 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. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Type && value == other.value + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + 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 @@ -4248,7 +3658,7 @@ private constructor( private val baseUrl: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -4261,7 +3671,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -4310,10 +3720,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -4355,13 +3770,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -4395,7 +3803,6 @@ private constructor( * .baseUrl() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -4408,7 +3815,7 @@ private constructor( private var baseUrl: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("AKENEO_PIM") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4477,16 +3884,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -4533,7 +3943,6 @@ private constructor( * .baseUrl() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -4544,7 +3953,7 @@ private constructor( checkRequired("baseUrl", baseUrl), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -4561,7 +3970,11 @@ private constructor( baseUrl() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("AKENEO_PIM")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -4586,130 +3999,9 @@ private constructor( (if (baseUrl.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("AKENEO_PIM")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKENEO_PIM - } - - /** - * 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 { - AKENEO_PIM, - /** 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) { - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKENEO_PIM -> Known.AKENEO_PIM - 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 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 c74ef0a2..4f23d963 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 @@ -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 @@ -610,7 +609,7 @@ private constructor( private val bucket: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -629,7 +628,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -686,11 +685,15 @@ private constructor( fun secretKey(): String = secretKey.getRequired("secretKey") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -752,13 +755,6 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -809,7 +805,6 @@ private constructor( * .bucket() * .name() * .secretKey() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -822,7 +817,7 @@ private constructor( private var bucket: JsonField? = null private var name: JsonField? = null private var secretKey: JsonField? = null - private var type: 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() @@ -889,16 +884,19 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("S3") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -976,7 +974,6 @@ private constructor( * .bucket() * .name() * .secretKey() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -987,7 +984,7 @@ private constructor( checkRequired("bucket", bucket), checkRequired("name", name), checkRequired("secretKey", secretKey), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1006,7 +1003,11 @@ private constructor( bucket() name() secretKey() - type().validate() + _type().let { + if (it != JsonValue.from("S3")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1033,135 +1034,11 @@ private constructor( (if (bucket.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (secretKey.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 S3 = of("S3") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3 - } - - /** - * 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 { - S3, - /** - * 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) { - S3 -> Value.S3 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - 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 @@ -1206,7 +1083,7 @@ private constructor( private val endpoint: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1229,7 +1106,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1302,11 +1179,15 @@ private constructor( fun secretKey(): String = secretKey.getRequired("secretKey") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1385,13 +1266,6 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1453,7 +1327,6 @@ private constructor( * .endpoint() * .name() * .secretKey() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1467,7 +1340,7 @@ private constructor( private var endpoint: JsonField? = null private var name: JsonField? = null private var secretKey: JsonField? = null - private var type: 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() @@ -1549,16 +1422,19 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("S3_COMPATIBLE") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1652,7 +1528,6 @@ private constructor( * .endpoint() * .name() * .secretKey() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1664,7 +1539,7 @@ private constructor( checkRequired("endpoint", endpoint), checkRequired("name", name), checkRequired("secretKey", secretKey), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1685,7 +1560,11 @@ private constructor( endpoint() name() secretKey() - type().validate() + _type().let { + if (it != JsonValue.from("S3_COMPATIBLE")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1714,136 +1593,12 @@ private constructor( (if (endpoint.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (secretKey.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3_COMPATIBLE - } - - /** - * 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 { - S3_COMPATIBLE, - /** - * 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) { - S3_COMPATIBLE -> Value.S3_COMPATIBLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3_COMPATIBLE -> Known.S3_COMPATIBLE - 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 @@ -1891,7 +1646,7 @@ private constructor( private val bucket: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1910,7 +1665,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1967,11 +1722,15 @@ private constructor( fun secretKey(): String = secretKey.getRequired("secretKey") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2033,13 +1792,6 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -2090,7 +1842,6 @@ private constructor( * .bucket() * .name() * .secretKey() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2103,7 +1854,7 @@ private constructor( private var bucket: JsonField? = null private var name: JsonField? = null private var secretKey: JsonField? = null - private var type: 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() @@ -2170,16 +1921,19 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("CLOUDINARY_BACKUP") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2257,7 +2011,6 @@ private constructor( * .bucket() * .name() * .secretKey() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2268,7 +2021,7 @@ private constructor( checkRequired("bucket", bucket), checkRequired("name", name), checkRequired("secretKey", secretKey), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -2287,7 +2040,11 @@ private constructor( bucket() name() secretKey() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY_BACKUP")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -2314,135 +2071,11 @@ private constructor( (if (bucket.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (secretKey.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY_BACKUP - } - - /** - * 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 { - CLOUDINARY_BACKUP, - /** - * 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) { - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - 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 @@ -2484,7 +2117,7 @@ private constructor( private constructor( private val baseUrl: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, @@ -2497,7 +2130,7 @@ private constructor( @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2536,11 +2169,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2583,13 +2220,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2641,7 +2271,6 @@ private constructor( * ```java * .baseUrl() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2652,7 +2281,7 @@ private constructor( private var baseUrl: JsonField? = null private var name: JsonField? = null - private var type: 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() @@ -2693,16 +2322,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("WEB_FOLDER") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2782,7 +2414,6 @@ private constructor( * ```java * .baseUrl() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2791,7 +2422,7 @@ private constructor( WebFolder( checkRequired("baseUrl", baseUrl), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, forwardHostHeaderToOrigin, includeCanonicalHeader, @@ -2808,7 +2439,11 @@ private constructor( baseUrl() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_FOLDER")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() forwardHostHeaderToOrigin() includeCanonicalHeader() @@ -2833,181 +2468,57 @@ private constructor( internal fun validity(): Int = (if (baseUrl.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + 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 + } - @JvmField val WEB_FOLDER = of("WEB_FOLDER") + private val hashCode: Int by lazy { + Objects.hash( + baseUrl, + name, + type, + baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + additionalProperties, + ) + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_FOLDER - } + override fun toString() = + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + } - /** - * 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 { - WEB_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) { - WEB_FOLDER -> Value.WEB_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) { - WEB_FOLDER -> Known.WEB_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 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: JsonField, - private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val additionalProperties: MutableMap, - ) { + 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: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3026,11 +2537,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3057,13 +2572,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -3104,7 +2612,6 @@ private constructor( * The following fields are required: * ```java * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3114,7 +2621,7 @@ private constructor( class Builder internal constructor() { private var name: JsonField? = null - private var type: 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() @@ -3140,16 +2647,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("WEB_PROXY") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3212,7 +2722,6 @@ private constructor( * The following fields are required: * ```java * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -3220,7 +2729,7 @@ private constructor( fun build(): WebProxy = WebProxy( checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, additionalProperties.toMutableMap(), @@ -3235,7 +2744,11 @@ private constructor( } name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_PROXY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() validated = true @@ -3258,134 +2771,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 WEB_PROXY = of("WEB_PROXY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_PROXY - } - - /** - * 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 { - WEB_PROXY, - /** - * 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) { - WEB_PROXY -> Value.WEB_PROXY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_PROXY -> Known.WEB_PROXY - 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 @@ -3421,7 +2810,7 @@ private constructor( private val clientEmail: JsonField, private val name: JsonField, private val privateKey: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -3440,7 +2829,7 @@ private constructor( @JsonProperty("privateKey") @ExcludeMissing privateKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3491,11 +2880,15 @@ private constructor( fun privateKey(): String = privateKey.getRequired("privateKey") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3555,13 +2948,6 @@ private constructor( @ExcludeMissing fun _privateKey(): JsonField = privateKey - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3613,7 +2999,6 @@ private constructor( * .clientEmail() * .name() * .privateKey() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3626,7 +3011,7 @@ private constructor( private var clientEmail: JsonField? = null private var name: JsonField? = null private var privateKey: JsonField? = null - private var type: 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() @@ -3694,16 +3079,19 @@ private constructor( this.privateKey = privateKey } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("GCS") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3780,7 +3168,6 @@ private constructor( * .clientEmail() * .name() * .privateKey() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -3791,7 +3178,7 @@ private constructor( checkRequired("clientEmail", clientEmail), checkRequired("name", name), checkRequired("privateKey", privateKey), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3810,7 +3197,11 @@ private constructor( clientEmail() name() privateKey() - type().validate() + _type().let { + if (it != JsonValue.from("GCS")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -3837,135 +3228,11 @@ private constructor( (if (clientEmail.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (privateKey.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 GCS = of("GCS") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GCS - } - - /** - * 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 { - GCS, - /** - * 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) { - GCS -> Value.GCS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GCS -> Known.GCS - 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 @@ -4009,7 +3276,7 @@ private constructor( private val container: JsonField, private val name: JsonField, private val sasToken: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -4028,7 +3295,7 @@ private constructor( @JsonProperty("sasToken") @ExcludeMissing sasToken: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -4079,11 +3346,15 @@ private constructor( fun sasToken(): String = sasToken.getRequired("sasToken") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -4144,13 +3415,6 @@ private constructor( */ @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -4201,7 +3465,6 @@ private constructor( * .container() * .name() * .sasToken() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -4214,7 +3477,7 @@ private constructor( private var container: JsonField? = null private var name: JsonField? = null private var sasToken: JsonField? = null - private var type: 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() @@ -4280,16 +3543,19 @@ private constructor( */ fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("AZURE_BLOB") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -4366,7 +3632,6 @@ private constructor( * .container() * .name() * .sasToken() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -4377,7 +3642,7 @@ private constructor( checkRequired("container", container), checkRequired("name", name), checkRequired("sasToken", sasToken), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -4396,7 +3661,11 @@ private constructor( container() name() sasToken() - type().validate() + _type().let { + if (it != JsonValue.from("AZURE_BLOB")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -4423,135 +3692,11 @@ private constructor( (if (container.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (sasToken.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 AZURE_BLOB = of("AZURE_BLOB") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AZURE_BLOB - } - - /** - * 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 { - AZURE_BLOB, - /** - * 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) { - AZURE_BLOB -> Value.AZURE_BLOB - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AZURE_BLOB -> Known.AZURE_BLOB - 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 @@ -4596,7 +3741,7 @@ private constructor( private val clientSecret: JsonField, private val name: JsonField, private val password: JsonField, - private val type: JsonField, + private val type: JsonValue, private val username: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, @@ -4618,7 +3763,7 @@ private constructor( @JsonProperty("password") @ExcludeMissing password: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), @@ -4687,11 +3832,15 @@ private constructor( fun password(): String = password.getRequired("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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Akeneo API username. @@ -4760,13 +3909,6 @@ private constructor( */ @JsonProperty("password") @ExcludeMissing fun _password(): JsonField = password - /** - * 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 [username]. * @@ -4819,7 +3961,6 @@ private constructor( * .clientSecret() * .name() * .password() - * .type() * .username() * ``` */ @@ -4834,7 +3975,7 @@ private constructor( private var clientSecret: JsonField? = null private var name: JsonField? = null private var password: JsonField? = null - private var type: 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() @@ -4916,16 +4057,19 @@ private constructor( */ fun password(password: JsonField) = apply { this.password = password } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("AKENEO_PIM") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } /** Akeneo API username. */ fun username(username: String) = username(JsonField.of(username)) @@ -5004,7 +4148,6 @@ private constructor( * .clientSecret() * .name() * .password() - * .type() * .username() * ``` * @@ -5017,7 +4160,7 @@ private constructor( checkRequired("clientSecret", clientSecret), checkRequired("name", name), checkRequired("password", password), - checkRequired("type", type), + type, checkRequired("username", username), baseUrlForCanonicalHeader, includeCanonicalHeader, @@ -5037,7 +4180,11 @@ private constructor( clientSecret() name() password() - type().validate() + _type().let { + if (it != JsonValue.from("AKENEO_PIM")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } username() baseUrlForCanonicalHeader() includeCanonicalHeader() @@ -5065,135 +4212,11 @@ private constructor( (if (clientSecret.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (password.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 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) - 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 AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKENEO_PIM - } - - /** - * 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 { - AKENEO_PIM, - /** - * 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) { - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKENEO_PIM -> Known.AKENEO_PIM - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt index 33953080..740d67e4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt @@ -1554,7 +1554,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -1568,7 +1568,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1626,10 +1626,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1678,13 +1683,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1719,7 +1717,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1733,7 +1730,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1815,16 +1812,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1872,7 +1872,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1884,7 +1883,7 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -1902,7 +1901,11 @@ private constructor( includeCanonicalHeader() name() prefix() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY_BACKUP")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -1928,130 +1931,9 @@ private constructor( (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY_BACKUP - } - - /** - * 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 { - CLOUDINARY_BACKUP, - /** 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) { - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - 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 @@ -2094,7 +1976,7 @@ private constructor( private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -2110,7 +1992,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2169,10 +2051,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2224,13 +2111,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2265,7 +2145,6 @@ private constructor( * .forwardHostHeaderToOrigin() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2279,7 +2158,7 @@ private constructor( private var forwardHostHeaderToOrigin: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_FOLDER") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2364,16 +2243,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2421,7 +2303,6 @@ private constructor( * .forwardHostHeaderToOrigin() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2433,7 +2314,7 @@ private constructor( checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -2451,7 +2332,11 @@ private constructor( forwardHostHeaderToOrigin() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_FOLDER")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -2477,174 +2362,53 @@ private constructor( (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("WEB_FOLDER")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + 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 + } - @JvmField val WEB_FOLDER = of("WEB_FOLDER") + private val hashCode: Int by lazy { + Objects.hash( + id, + baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_FOLDER - } + override fun toString() = + "WebFolder{id=$id, baseUrl=$baseUrl, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } - /** - * 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 { - WEB_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) { - WEB_FOLDER -> Value.WEB_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) { - WEB_FOLDER -> Known.WEB_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 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: JsonField, - private val baseUrlForCanonicalHeader: JsonField, - private val additionalProperties: MutableMap, - ) { + 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( @@ -2653,7 +2417,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2686,10 +2450,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -2724,13 +2493,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2763,7 +2525,6 @@ private constructor( * .id() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -2775,7 +2536,7 @@ private constructor( private var id: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_PROXY") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2831,16 +2592,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2886,7 +2650,6 @@ private constructor( * .id() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2896,7 +2659,7 @@ private constructor( checkRequired("id", id), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -2912,7 +2675,11 @@ private constructor( id() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("WEB_PROXY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -2936,130 +2703,9 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 WEB_PROXY = of("WEB_PROXY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_PROXY - } - - /** - * 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 { - WEB_PROXY, - /** 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) { - WEB_PROXY -> Value.WEB_PROXY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_PROXY -> Known.WEB_PROXY - 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 @@ -3099,7 +2745,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -3116,7 +2762,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3177,10 +2823,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3238,13 +2889,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3280,7 +2924,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3295,7 +2938,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("GCS") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3389,16 +3032,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3447,7 +3093,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -3460,175 +3105,58 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), - baseUrlForCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GoogleCloudStorageGcs = apply { - if (validated) { - return@apply - } - - id() - bucket() - clientEmail() - includeCanonicalHeader() - name() - prefix() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 GCS = of("GCS") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GCS - } - - /** - * 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 { - GCS, - /** 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) { - GCS -> Value.GCS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GCS -> Known.GCS - 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 - } + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + private var validated: Boolean = false - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun validate(): GoogleCloudStorageGcs = apply { + if (validated) { + return@apply + } - return other is Type && value == other.value + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + prefix() + _type().let { + if (it != JsonValue.from("GCS")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } } + baseUrlForCanonicalHeader() + 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 (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) { @@ -3675,7 +3203,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -3694,7 +3222,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3755,10 +3283,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -3816,13 +3349,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -3858,7 +3384,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -3873,7 +3398,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("AZURE_BLOB") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3967,16 +3492,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3989,225 +3517,107 @@ private constructor( * [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 [AzureBlobStorage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .accountName() - * .container() - * .includeCanonicalHeader() - * .name() - * .prefix() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AzureBlobStorage = - AzureBlobStorage( - checkRequired("id", id), - checkRequired("accountName", accountName), - checkRequired("container", container), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), - checkRequired("name", name), - checkRequired("prefix", prefix), - checkRequired("type", type), - baseUrlForCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AzureBlobStorage = apply { - if (validated) { - return@apply - } - - id() - accountName() - container() - includeCanonicalHeader() - name() - prefix() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 AZURE_BLOB = of("AZURE_BLOB") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AZURE_BLOB - } - - /** - * 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 { - AZURE_BLOB, - /** 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) { - AZURE_BLOB -> Value.AZURE_BLOB - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AZURE_BLOB -> Known.AZURE_BLOB - 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") - } + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): Type = apply { - if (validated) { - return@apply - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - known() - validated = true + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [AzureBlobStorage]. * - * Used for best match union deserialization. + * 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. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun build(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Type && value == other.value + fun validate(): AzureBlobStorage = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + 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 @@ -4251,7 +3661,7 @@ private constructor( private val baseUrl: JsonField, private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -4264,7 +3674,7 @@ private constructor( @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -4313,10 +3723,15 @@ private constructor( 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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -4358,13 +3773,6 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -4398,7 +3806,6 @@ private constructor( * .baseUrl() * .includeCanonicalHeader() * .name() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -4411,7 +3818,7 @@ private constructor( private var baseUrl: JsonField? = null private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("AKENEO_PIM") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4480,16 +3887,19 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -4536,7 +3946,6 @@ private constructor( * .baseUrl() * .includeCanonicalHeader() * .name() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -4547,7 +3956,7 @@ private constructor( checkRequired("baseUrl", baseUrl), checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -4564,7 +3973,11 @@ private constructor( baseUrl() includeCanonicalHeader() name() - type().validate() + _type().let { + if (it != JsonValue.from("AKENEO_PIM")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -4589,130 +4002,9 @@ private constructor( (if (baseUrl.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("AKENEO_PIM")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKENEO_PIM - } - - /** - * 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 { - AKENEO_PIM, - /** 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) { - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKENEO_PIM -> Known.AKENEO_PIM - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt index d2bd5e61..96a15325 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.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 @@ -275,13 +274,11 @@ private constructor( fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ - fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = - urlRewriter(UrlRewriter.ofImgix(imgix)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = urlRewriter(UrlRewriter.ofImgix()) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ - fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = - urlRewriter(UrlRewriter.ofAkamai(akamai)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = urlRewriter(UrlRewriter.ofAkamai()) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -370,16 +367,16 @@ private constructor( class UrlRewriter private constructor( private val cloudinary: CloudinaryUrlRewriter? = null, - private val imgix: ImgixUrlRewriter? = null, - private val akamai: AkamaiUrlRewriter? = 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 imgix(): Optional = Optional.ofNullable(imgix) - fun akamai(): Optional = Optional.ofNullable(akamai) + fun akamai(): Optional = Optional.ofNullable(akamai) fun isCloudinary(): Boolean = cloudinary != null @@ -389,9 +386,9 @@ private constructor( fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") - fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + fun asImgix(): JsonValue = imgix.getOrThrow("imgix") - fun asAkamai(): AkamaiUrlRewriter = akamai.getOrThrow("akamai") + fun asAkamai(): JsonValue = akamai.getOrThrow("akamai") fun _json(): Optional = Optional.ofNullable(_json) @@ -416,12 +413,24 @@ private constructor( cloudinary.validate() } - override fun visitImgix(imgix: ImgixUrlRewriter) { - imgix.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: AkamaiUrlRewriter) { - akamai.validate() + override fun visitAkamai(akamai: JsonValue) { + akamai.let { + if (it != JsonValue.from(mapOf("type" to "AKAMAI"))) { + throw ImageKitInvalidDataException( + "'akamai' is invalid, received $it" + ) + } + } } } ) @@ -449,9 +458,11 @@ private constructor( override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = cloudinary.validity() - override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } - override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -485,9 +496,10 @@ private constructor( fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = UrlRewriter(cloudinary = cloudinary) - @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) - @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + @JvmStatic + fun ofAkamai() = UrlRewriter(akamai = JsonValue.from(mapOf("type" to "AKAMAI"))) } /** @@ -498,9 +510,9 @@ private constructor( fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T - fun visitImgix(imgix: ImgixUrlRewriter): T + fun visitImgix(imgix: JsonValue): T - fun visitAkamai(akamai: AkamaiUrlRewriter): T + fun visitAkamai(akamai: JsonValue): T /** * Maps an unknown variant of [UrlRewriter] to a value of type [T]. @@ -524,15 +536,15 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(imgix = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(akamai = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { UrlRewriter(cloudinary = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(imgix = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(akamai = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -570,7 +582,7 @@ private constructor( class CloudinaryUrlRewriter private constructor( private val preserveAssetDeliveryTypes: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -579,7 +591,7 @@ private constructor( @JsonProperty("preserveAssetDeliveryTypes") @ExcludeMissing preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(preserveAssetDeliveryTypes, type, mutableMapOf()) /** @@ -593,11 +605,15 @@ private constructor( preserveAssetDeliveryTypes.getRequired("preserveAssetDeliveryTypes") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [preserveAssetDeliveryTypes]. @@ -609,13 +625,6 @@ private constructor( @ExcludeMissing fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes - /** - * 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) @@ -637,7 +646,6 @@ private constructor( * The following fields are required: * ```java * .preserveAssetDeliveryTypes() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -647,7 +655,7 @@ private constructor( class Builder internal constructor() { private var preserveAssetDeliveryTypes: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -673,16 +681,19 @@ private constructor( this.preserveAssetDeliveryTypes = preserveAssetDeliveryTypes } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("CLOUDINARY") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -714,7 +725,6 @@ private constructor( * The following fields are required: * ```java * .preserveAssetDeliveryTypes() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -722,7 +732,7 @@ private constructor( fun build(): CloudinaryUrlRewriter = CloudinaryUrlRewriter( checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } @@ -735,7 +745,11 @@ private constructor( } preserveAssetDeliveryTypes() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -756,131 +770,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - 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 CLOUDINARY = of("CLOUDINARY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY - } - - /** - * 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 { - CLOUDINARY, - /** - * 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) { - CLOUDINARY -> Value.CLOUDINARY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY -> Known.CLOUDINARY - 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() - } + type.let { if (it == JsonValue.from("CLOUDINARY")) 1 else 0 } override fun equals(other: Any?): Boolean { if (this === other) { @@ -902,574 +792,6 @@ private constructor( override fun toString() = "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" } - - class ImgixUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [ImgixUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ImgixUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { - type = imgixUrlRewriter.type - additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [ImgixUrlRewriter]. - * - * 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(): ImgixUrlRewriter = - ImgixUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ImgixUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 IMGIX = of("IMGIX") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMGIX - } - - /** - * 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 { - IMGIX, - /** - * 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) { - IMGIX -> Value.IMGIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - IMGIX -> Known.IMGIX - 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 ImgixUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } - - class AkamaiUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [AkamaiUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AkamaiUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { - type = akamaiUrlRewriter.type - additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [AkamaiUrlRewriter]. - * - * 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(): AkamaiUrlRewriter = - AkamaiUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AkamaiUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 AKAMAI = of("AKAMAI") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKAMAI - } - - /** - * 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 { - AKAMAI, - /** - * 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) { - AKAMAI -> Value.AKAMAI - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKAMAI -> Known.AKAMAI - 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 AkamaiUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt index 7934a7c8..9842c9d6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.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 @@ -275,13 +274,11 @@ private constructor( fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ - fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = - urlRewriter(UrlRewriter.ofImgix(imgix)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = urlRewriter(UrlRewriter.ofImgix()) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ - fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = - urlRewriter(UrlRewriter.ofAkamai(akamai)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = urlRewriter(UrlRewriter.ofAkamai()) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -370,16 +367,16 @@ private constructor( class UrlRewriter private constructor( private val cloudinary: CloudinaryUrlRewriter? = null, - private val imgix: ImgixUrlRewriter? = null, - private val akamai: AkamaiUrlRewriter? = 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 imgix(): Optional = Optional.ofNullable(imgix) - fun akamai(): Optional = Optional.ofNullable(akamai) + fun akamai(): Optional = Optional.ofNullable(akamai) fun isCloudinary(): Boolean = cloudinary != null @@ -389,9 +386,9 @@ private constructor( fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") - fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + fun asImgix(): JsonValue = imgix.getOrThrow("imgix") - fun asAkamai(): AkamaiUrlRewriter = akamai.getOrThrow("akamai") + fun asAkamai(): JsonValue = akamai.getOrThrow("akamai") fun _json(): Optional = Optional.ofNullable(_json) @@ -416,12 +413,24 @@ private constructor( cloudinary.validate() } - override fun visitImgix(imgix: ImgixUrlRewriter) { - imgix.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: AkamaiUrlRewriter) { - akamai.validate() + override fun visitAkamai(akamai: JsonValue) { + akamai.let { + if (it != JsonValue.from(mapOf("type" to "AKAMAI"))) { + throw ImageKitInvalidDataException( + "'akamai' is invalid, received $it" + ) + } + } } } ) @@ -449,9 +458,11 @@ private constructor( override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = cloudinary.validity() - override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } - override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -485,9 +496,10 @@ private constructor( fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = UrlRewriter(cloudinary = cloudinary) - @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) - @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + @JvmStatic + fun ofAkamai() = UrlRewriter(akamai = JsonValue.from(mapOf("type" to "AKAMAI"))) } /** @@ -498,9 +510,9 @@ private constructor( fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T - fun visitImgix(imgix: ImgixUrlRewriter): T + fun visitImgix(imgix: JsonValue): T - fun visitAkamai(akamai: AkamaiUrlRewriter): T + fun visitAkamai(akamai: JsonValue): T /** * Maps an unknown variant of [UrlRewriter] to a value of type [T]. @@ -524,15 +536,15 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(imgix = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(akamai = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { UrlRewriter(cloudinary = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(imgix = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(akamai = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -570,7 +582,7 @@ private constructor( class CloudinaryUrlRewriter private constructor( private val preserveAssetDeliveryTypes: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -579,7 +591,7 @@ private constructor( @JsonProperty("preserveAssetDeliveryTypes") @ExcludeMissing preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(preserveAssetDeliveryTypes, type, mutableMapOf()) /** @@ -593,11 +605,15 @@ private constructor( preserveAssetDeliveryTypes.getRequired("preserveAssetDeliveryTypes") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [preserveAssetDeliveryTypes]. @@ -609,13 +625,6 @@ private constructor( @ExcludeMissing fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes - /** - * 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) @@ -637,7 +646,6 @@ private constructor( * The following fields are required: * ```java * .preserveAssetDeliveryTypes() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -647,7 +655,7 @@ private constructor( class Builder internal constructor() { private var preserveAssetDeliveryTypes: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -673,16 +681,19 @@ private constructor( this.preserveAssetDeliveryTypes = preserveAssetDeliveryTypes } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("CLOUDINARY") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -714,7 +725,6 @@ private constructor( * The following fields are required: * ```java * .preserveAssetDeliveryTypes() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -722,7 +732,7 @@ private constructor( fun build(): CloudinaryUrlRewriter = CloudinaryUrlRewriter( checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } @@ -735,7 +745,11 @@ private constructor( } preserveAssetDeliveryTypes() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -756,131 +770,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - 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 CLOUDINARY = of("CLOUDINARY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY - } - - /** - * 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 { - CLOUDINARY, - /** - * 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) { - CLOUDINARY -> Value.CLOUDINARY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY -> Known.CLOUDINARY - 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() - } + type.let { if (it == JsonValue.from("CLOUDINARY")) 1 else 0 } override fun equals(other: Any?): Boolean { if (this === other) { @@ -902,574 +792,6 @@ private constructor( override fun toString() = "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" } - - class ImgixUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [ImgixUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ImgixUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { - type = imgixUrlRewriter.type - additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [ImgixUrlRewriter]. - * - * 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(): ImgixUrlRewriter = - ImgixUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ImgixUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 IMGIX = of("IMGIX") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMGIX - } - - /** - * 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 { - IMGIX, - /** - * 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) { - IMGIX -> Value.IMGIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - IMGIX -> Known.IMGIX - 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 ImgixUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } - - class AkamaiUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [AkamaiUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AkamaiUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { - type = akamaiUrlRewriter.type - additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [AkamaiUrlRewriter]. - * - * 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(): AkamaiUrlRewriter = - AkamaiUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AkamaiUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 AKAMAI = of("AKAMAI") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKAMAI - } - - /** - * 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 { - AKAMAI, - /** - * 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) { - AKAMAI -> Value.AKAMAI - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKAMAI -> Known.AKAMAI - 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 AkamaiUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt index f5f5754d..5b27b56f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.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 @@ -275,13 +274,11 @@ private constructor( fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ - fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = - urlRewriter(UrlRewriter.ofImgix(imgix)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = urlRewriter(UrlRewriter.ofImgix()) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ - fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = - urlRewriter(UrlRewriter.ofAkamai(akamai)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = urlRewriter(UrlRewriter.ofAkamai()) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -370,16 +367,16 @@ private constructor( class UrlRewriter private constructor( private val cloudinary: CloudinaryUrlRewriter? = null, - private val imgix: ImgixUrlRewriter? = null, - private val akamai: AkamaiUrlRewriter? = 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 imgix(): Optional = Optional.ofNullable(imgix) - fun akamai(): Optional = Optional.ofNullable(akamai) + fun akamai(): Optional = Optional.ofNullable(akamai) fun isCloudinary(): Boolean = cloudinary != null @@ -389,9 +386,9 @@ private constructor( fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") - fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + fun asImgix(): JsonValue = imgix.getOrThrow("imgix") - fun asAkamai(): AkamaiUrlRewriter = akamai.getOrThrow("akamai") + fun asAkamai(): JsonValue = akamai.getOrThrow("akamai") fun _json(): Optional = Optional.ofNullable(_json) @@ -416,12 +413,24 @@ private constructor( cloudinary.validate() } - override fun visitImgix(imgix: ImgixUrlRewriter) { - imgix.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: AkamaiUrlRewriter) { - akamai.validate() + override fun visitAkamai(akamai: JsonValue) { + akamai.let { + if (it != JsonValue.from(mapOf("type" to "AKAMAI"))) { + throw ImageKitInvalidDataException( + "'akamai' is invalid, received $it" + ) + } + } } } ) @@ -449,9 +458,11 @@ private constructor( override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = cloudinary.validity() - override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } - override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -485,9 +496,10 @@ private constructor( fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = UrlRewriter(cloudinary = cloudinary) - @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) - @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + @JvmStatic + fun ofAkamai() = UrlRewriter(akamai = JsonValue.from(mapOf("type" to "AKAMAI"))) } /** @@ -498,9 +510,9 @@ private constructor( fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T - fun visitImgix(imgix: ImgixUrlRewriter): T + fun visitImgix(imgix: JsonValue): T - fun visitAkamai(akamai: AkamaiUrlRewriter): T + fun visitAkamai(akamai: JsonValue): T /** * Maps an unknown variant of [UrlRewriter] to a value of type [T]. @@ -524,15 +536,15 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(imgix = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(akamai = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { UrlRewriter(cloudinary = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(imgix = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(akamai = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -570,7 +582,7 @@ private constructor( class CloudinaryUrlRewriter private constructor( private val preserveAssetDeliveryTypes: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -579,7 +591,7 @@ private constructor( @JsonProperty("preserveAssetDeliveryTypes") @ExcludeMissing preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(preserveAssetDeliveryTypes, type, mutableMapOf()) /** @@ -593,11 +605,15 @@ private constructor( preserveAssetDeliveryTypes.getRequired("preserveAssetDeliveryTypes") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [preserveAssetDeliveryTypes]. @@ -609,13 +625,6 @@ private constructor( @ExcludeMissing fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes - /** - * 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) @@ -637,7 +646,6 @@ private constructor( * The following fields are required: * ```java * .preserveAssetDeliveryTypes() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -647,7 +655,7 @@ private constructor( class Builder internal constructor() { private var preserveAssetDeliveryTypes: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -673,16 +681,19 @@ private constructor( this.preserveAssetDeliveryTypes = preserveAssetDeliveryTypes } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("CLOUDINARY") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -714,7 +725,6 @@ private constructor( * The following fields are required: * ```java * .preserveAssetDeliveryTypes() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -722,7 +732,7 @@ private constructor( fun build(): CloudinaryUrlRewriter = CloudinaryUrlRewriter( checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } @@ -735,7 +745,11 @@ private constructor( } preserveAssetDeliveryTypes() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -756,131 +770,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - 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 CLOUDINARY = of("CLOUDINARY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY - } - - /** - * 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 { - CLOUDINARY, - /** - * 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) { - CLOUDINARY -> Value.CLOUDINARY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY -> Known.CLOUDINARY - 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() - } + type.let { if (it == JsonValue.from("CLOUDINARY")) 1 else 0 } override fun equals(other: Any?): Boolean { if (this === other) { @@ -902,574 +792,6 @@ private constructor( override fun toString() = "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" } - - class ImgixUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [ImgixUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ImgixUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { - type = imgixUrlRewriter.type - additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [ImgixUrlRewriter]. - * - * 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(): ImgixUrlRewriter = - ImgixUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ImgixUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 IMGIX = of("IMGIX") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMGIX - } - - /** - * 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 { - IMGIX, - /** - * 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) { - IMGIX -> Value.IMGIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - IMGIX -> Known.IMGIX - 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 ImgixUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } - - class AkamaiUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [AkamaiUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AkamaiUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { - type = akamaiUrlRewriter.type - additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [AkamaiUrlRewriter]. - * - * 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(): AkamaiUrlRewriter = - AkamaiUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AkamaiUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 AKAMAI = of("AKAMAI") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKAMAI - } - - /** - * 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 { - AKAMAI, - /** - * 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) { - AKAMAI -> Value.AKAMAI - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKAMAI -> Known.AKAMAI - 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 AkamaiUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt index 9de2612a..9d73ae46 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.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 @@ -275,13 +274,11 @@ private constructor( fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix(imgix)`. */ - fun urlRewriter(imgix: UrlRewriter.ImgixUrlRewriter) = - urlRewriter(UrlRewriter.ofImgix(imgix)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = urlRewriter(UrlRewriter.ofImgix()) - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai(akamai)`. */ - fun urlRewriter(akamai: UrlRewriter.AkamaiUrlRewriter) = - urlRewriter(UrlRewriter.ofAkamai(akamai)) + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = urlRewriter(UrlRewriter.ofAkamai()) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -370,16 +367,16 @@ private constructor( class UrlRewriter private constructor( private val cloudinary: CloudinaryUrlRewriter? = null, - private val imgix: ImgixUrlRewriter? = null, - private val akamai: AkamaiUrlRewriter? = 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 imgix(): Optional = Optional.ofNullable(imgix) - fun akamai(): Optional = Optional.ofNullable(akamai) + fun akamai(): Optional = Optional.ofNullable(akamai) fun isCloudinary(): Boolean = cloudinary != null @@ -389,9 +386,9 @@ private constructor( fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") - fun asImgix(): ImgixUrlRewriter = imgix.getOrThrow("imgix") + fun asImgix(): JsonValue = imgix.getOrThrow("imgix") - fun asAkamai(): AkamaiUrlRewriter = akamai.getOrThrow("akamai") + fun asAkamai(): JsonValue = akamai.getOrThrow("akamai") fun _json(): Optional = Optional.ofNullable(_json) @@ -416,12 +413,24 @@ private constructor( cloudinary.validate() } - override fun visitImgix(imgix: ImgixUrlRewriter) { - imgix.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: AkamaiUrlRewriter) { - akamai.validate() + override fun visitAkamai(akamai: JsonValue) { + akamai.let { + if (it != JsonValue.from(mapOf("type" to "AKAMAI"))) { + throw ImageKitInvalidDataException( + "'akamai' is invalid, received $it" + ) + } + } } } ) @@ -449,9 +458,11 @@ private constructor( override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = cloudinary.validity() - override fun visitImgix(imgix: ImgixUrlRewriter) = imgix.validity() + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } - override fun visitAkamai(akamai: AkamaiUrlRewriter) = akamai.validity() + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -485,9 +496,10 @@ private constructor( fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = UrlRewriter(cloudinary = cloudinary) - @JvmStatic fun ofImgix(imgix: ImgixUrlRewriter) = UrlRewriter(imgix = imgix) + @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) - @JvmStatic fun ofAkamai(akamai: AkamaiUrlRewriter) = UrlRewriter(akamai = akamai) + @JvmStatic + fun ofAkamai() = UrlRewriter(akamai = JsonValue.from(mapOf("type" to "AKAMAI"))) } /** @@ -498,9 +510,9 @@ private constructor( fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T - fun visitImgix(imgix: ImgixUrlRewriter): T + fun visitImgix(imgix: JsonValue): T - fun visitAkamai(akamai: AkamaiUrlRewriter): T + fun visitAkamai(akamai: JsonValue): T /** * Maps an unknown variant of [UrlRewriter] to a value of type [T]. @@ -524,15 +536,15 @@ private constructor( val bestMatches = sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(imgix = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(akamai = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { UrlRewriter(cloudinary = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(imgix = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(akamai = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -570,7 +582,7 @@ private constructor( class CloudinaryUrlRewriter private constructor( private val preserveAssetDeliveryTypes: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -579,7 +591,7 @@ private constructor( @JsonProperty("preserveAssetDeliveryTypes") @ExcludeMissing preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(preserveAssetDeliveryTypes, type, mutableMapOf()) /** @@ -593,11 +605,15 @@ private constructor( preserveAssetDeliveryTypes.getRequired("preserveAssetDeliveryTypes") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [preserveAssetDeliveryTypes]. @@ -609,13 +625,6 @@ private constructor( @ExcludeMissing fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes - /** - * 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) @@ -637,7 +646,6 @@ private constructor( * The following fields are required: * ```java * .preserveAssetDeliveryTypes() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -647,7 +655,7 @@ private constructor( class Builder internal constructor() { private var preserveAssetDeliveryTypes: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -673,16 +681,19 @@ private constructor( this.preserveAssetDeliveryTypes = preserveAssetDeliveryTypes } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON 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("CLOUDINARY") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -714,7 +725,6 @@ private constructor( * The following fields are required: * ```java * .preserveAssetDeliveryTypes() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -722,7 +732,7 @@ private constructor( fun build(): CloudinaryUrlRewriter = CloudinaryUrlRewriter( checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } @@ -735,7 +745,11 @@ private constructor( } preserveAssetDeliveryTypes() - type().validate() + _type().let { + if (it != JsonValue.from("CLOUDINARY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -756,131 +770,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - 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 CLOUDINARY = of("CLOUDINARY") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY - } - - /** - * 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 { - CLOUDINARY, - /** - * 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) { - CLOUDINARY -> Value.CLOUDINARY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY -> Known.CLOUDINARY - 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() - } + type.let { if (it == JsonValue.from("CLOUDINARY")) 1 else 0 } override fun equals(other: Any?): Boolean { if (this === other) { @@ -902,574 +792,6 @@ private constructor( override fun toString() = "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" } - - class ImgixUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [ImgixUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ImgixUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(imgixUrlRewriter: ImgixUrlRewriter) = apply { - type = imgixUrlRewriter.type - additionalProperties = imgixUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [ImgixUrlRewriter]. - * - * 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(): ImgixUrlRewriter = - ImgixUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ImgixUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 IMGIX = of("IMGIX") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMGIX - } - - /** - * 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 { - IMGIX, - /** - * 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) { - IMGIX -> Value.IMGIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - IMGIX -> Known.IMGIX - 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 ImgixUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ImgixUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } - - class AkamaiUrlRewriter - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, 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 type(): Type = type.getRequired("type") - - /** - * 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 [AkamaiUrlRewriter]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AkamaiUrlRewriter]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(akamaiUrlRewriter: AkamaiUrlRewriter) = apply { - type = akamaiUrlRewriter.type - additionalProperties = akamaiUrlRewriter.additionalProperties.toMutableMap() - } - - 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 [AkamaiUrlRewriter]. - * - * 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(): AkamaiUrlRewriter = - AkamaiUrlRewriter( - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AkamaiUrlRewriter = apply { - if (validated) { - return@apply - } - - type().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) - - 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 AKAMAI = of("AKAMAI") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKAMAI - } - - /** - * 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 { - AKAMAI, - /** - * 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) { - AKAMAI -> Value.AKAMAI - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKAMAI -> Known.AKAMAI - 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 AkamaiUrlRewriter && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AkamaiUrlRewriter{type=$type, additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { 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 97127453..a6c526b0 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 @@ -764,12 +764,8 @@ private constructor( fun removeAiTagsOfStrings(strings: List) = removeAiTags(RemoveAiTags.ofStrings(strings)) - /** - * Alias for calling [removeAiTags] with - * `RemoveAiTags.ofUnionMember1(unionMember1)`. - */ - fun removeAiTags(unionMember1: RemoveAiTags.UnionMember1) = - removeAiTags(RemoveAiTags.ofUnionMember1(unionMember1)) + /** 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 @@ -2154,28 +2150,28 @@ private constructor( class RemoveAiTags private constructor( private val strings: List? = null, - private val unionMember1: UnionMember1? = null, + private val all: JsonValue? = null, private val _json: JsonValue? = null, ) { fun strings(): Optional> = Optional.ofNullable(strings) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun all(): Optional = Optional.ofNullable(all) fun isStrings(): Boolean = strings != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isAll(): Boolean = all != null fun asStrings(): List = strings.getOrThrow("strings") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asAll(): JsonValue = all.getOrThrow("all") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { strings != null -> visitor.visitStrings(strings) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + all != null -> visitor.visitAll(all) else -> visitor.unknown(_json) } @@ -2190,8 +2186,14 @@ private constructor( object : Visitor { override fun visitStrings(strings: List) {} - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() + override fun visitAll(all: JsonValue) { + all.let { + if (it != JsonValue.from("all")) { + throw ImageKitInvalidDataException( + "'all' is invalid, received $it" + ) + } + } } } ) @@ -2218,8 +2220,8 @@ private constructor( object : Visitor { override fun visitStrings(strings: List) = strings.size - override fun visitUnionMember1(unionMember1: UnionMember1) = - unionMember1.validity() + override fun visitAll(all: JsonValue) = + all.let { if (it == JsonValue.from("all")) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -2230,17 +2232,15 @@ private constructor( return true } - return other is RemoveAiTags && - strings == other.strings && - unionMember1 == other.unionMember1 + return other is RemoveAiTags && strings == other.strings && all == other.all } - override fun hashCode(): Int = Objects.hash(strings, unionMember1) + override fun hashCode(): Int = Objects.hash(strings, all) override fun toString(): String = when { strings != null -> "RemoveAiTags{strings=$strings}" - unionMember1 != null -> "RemoveAiTags{unionMember1=$unionMember1}" + all != null -> "RemoveAiTags{all=$all}" _json != null -> "RemoveAiTags{_unknown=$_json}" else -> throw IllegalStateException("Invalid RemoveAiTags") } @@ -2251,9 +2251,7 @@ private constructor( fun ofStrings(strings: List) = RemoveAiTags(strings = strings.toImmutable()) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - RemoveAiTags(unionMember1 = unionMember1) + @JvmStatic fun ofAll() = RemoveAiTags(all = JsonValue.from("all")) } /** @@ -2264,7 +2262,7 @@ private constructor( fun visitStrings(strings: List): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitAll(all: JsonValue): T /** * Maps an unknown variant of [RemoveAiTags] to a value of type [T]. @@ -2288,9 +2286,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - RemoveAiTags(unionMember1 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { RemoveAiTags(all = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef>())?.let { RemoveAiTags(strings = it, _json = json) }, @@ -2321,143 +2319,12 @@ private constructor( ) { when { value.strings != null -> generator.writeObject(value.strings) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.all != null -> generator.writeObject(value.all) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid RemoveAiTags") } } } - - class UnionMember1 - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API 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") - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - /** An enum containing [UnionMember1]'s known values. */ - enum class Known { - ALL - } - - /** - * An enum containing [UnionMember1]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [UnionMember1] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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, - /** - * An enum member indicating that [UnionMember1] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - else -> - throw ImageKitInvalidDataException("Unknown UnionMember1: $value") - } - - /** - * Returns this class 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(): UnionMember1 = 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 UnionMember1 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } override fun equals(other: Any?): Boolean { 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 f091309e..f6d962db 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 @@ -16,7 +16,6 @@ internal class OriginCreateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginCreateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -35,7 +34,6 @@ internal class OriginCreateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginCreateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -53,7 +51,6 @@ internal class OriginCreateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginCreateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -72,7 +69,6 @@ internal class OriginCreateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginCreateParams.Body.S3.Type.S3) .build() ) .build() @@ -87,7 +83,6 @@ internal class OriginCreateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginCreateParams.Body.S3.Type.S3) .build() ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt index 2b96f081..46ec775a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt @@ -127,7 +127,6 @@ internal class OriginCreateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginCreateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -154,7 +153,6 @@ internal class OriginCreateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginCreateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -177,7 +175,6 @@ internal class OriginCreateResponseTest { .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginCreateResponse.WebFolder.Type.WEB_FOLDER) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -204,7 +201,6 @@ internal class OriginCreateResponseTest { .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginCreateResponse.WebFolder.Type.WEB_FOLDER) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -225,7 +221,6 @@ internal class OriginCreateResponseTest { .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginCreateResponse.WebProxy.Type.WEB_PROXY) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -250,7 +245,6 @@ internal class OriginCreateResponseTest { .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginCreateResponse.WebProxy.Type.WEB_PROXY) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -274,7 +268,6 @@ internal class OriginCreateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("products") - .type(OriginCreateResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -303,7 +296,6 @@ internal class OriginCreateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("products") - .type(OriginCreateResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -327,7 +319,6 @@ internal class OriginCreateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("uploads") - .type(OriginCreateResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -355,7 +346,6 @@ internal class OriginCreateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("uploads") - .type(OriginCreateResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -377,7 +367,6 @@ internal class OriginCreateResponseTest { .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginCreateResponse.AkeneoPim.Type.AKENEO_PIM) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -403,7 +392,6 @@ internal class OriginCreateResponseTest { .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginCreateResponse.AkeneoPim.Type.AKENEO_PIM) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt index 214e8413..6e0ecfdf 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt @@ -127,7 +127,6 @@ internal class OriginGetResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginGetResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -154,7 +153,6 @@ internal class OriginGetResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginGetResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -177,7 +175,6 @@ internal class OriginGetResponseTest { .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginGetResponse.WebFolder.Type.WEB_FOLDER) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -204,7 +201,6 @@ internal class OriginGetResponseTest { .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginGetResponse.WebFolder.Type.WEB_FOLDER) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -225,7 +221,6 @@ internal class OriginGetResponseTest { .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginGetResponse.WebProxy.Type.WEB_PROXY) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -250,7 +245,6 @@ internal class OriginGetResponseTest { .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginGetResponse.WebProxy.Type.WEB_PROXY) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -274,7 +268,6 @@ internal class OriginGetResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("products") - .type(OriginGetResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -302,7 +295,6 @@ internal class OriginGetResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("products") - .type(OriginGetResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -326,7 +318,6 @@ internal class OriginGetResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("uploads") - .type(OriginGetResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -354,7 +345,6 @@ internal class OriginGetResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("uploads") - .type(OriginGetResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -376,7 +366,6 @@ internal class OriginGetResponseTest { .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginGetResponse.AkeneoPim.Type.AKENEO_PIM) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -402,7 +391,6 @@ internal class OriginGetResponseTest { .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginGetResponse.AkeneoPim.Type.AKENEO_PIM) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt index 36eae79e..e3aed573 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt @@ -127,7 +127,6 @@ internal class OriginListResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginListResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -154,7 +153,6 @@ internal class OriginListResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginListResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -177,7 +175,6 @@ internal class OriginListResponseTest { .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginListResponse.WebFolder.Type.WEB_FOLDER) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -204,7 +201,6 @@ internal class OriginListResponseTest { .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginListResponse.WebFolder.Type.WEB_FOLDER) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -225,7 +221,6 @@ internal class OriginListResponseTest { .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginListResponse.WebProxy.Type.WEB_PROXY) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -250,7 +245,6 @@ internal class OriginListResponseTest { .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginListResponse.WebProxy.Type.WEB_PROXY) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -274,7 +268,6 @@ internal class OriginListResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("products") - .type(OriginListResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -302,7 +295,6 @@ internal class OriginListResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("products") - .type(OriginListResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -326,7 +318,6 @@ internal class OriginListResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("uploads") - .type(OriginListResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -354,7 +345,6 @@ internal class OriginListResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("uploads") - .type(OriginListResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -376,7 +366,6 @@ internal class OriginListResponseTest { .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginListResponse.AkeneoPim.Type.AKENEO_PIM) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -402,7 +391,6 @@ internal class OriginListResponseTest { .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginListResponse.AkeneoPim.Type.AKENEO_PIM) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) 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 6def6f75..ac041a2b 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 @@ -17,7 +17,6 @@ internal class OriginUpdateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginUpdateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -37,7 +36,6 @@ internal class OriginUpdateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginUpdateParams.Body.S3.Type.S3) .build() ) .build() @@ -58,7 +56,6 @@ internal class OriginUpdateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginUpdateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -76,7 +73,6 @@ internal class OriginUpdateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginUpdateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -96,7 +92,6 @@ internal class OriginUpdateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginUpdateParams.Body.S3.Type.S3) .build() ) .build() @@ -111,7 +106,6 @@ internal class OriginUpdateParamsTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginUpdateParams.Body.S3.Type.S3) .build() ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt index 65537053..e3a32e54 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt @@ -127,7 +127,6 @@ internal class OriginUpdateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginUpdateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -154,7 +153,6 @@ internal class OriginUpdateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginUpdateResponse.CloudinaryBackup.Type.CLOUDINARY_BACKUP) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -177,7 +175,6 @@ internal class OriginUpdateResponseTest { .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginUpdateResponse.WebFolder.Type.WEB_FOLDER) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -204,7 +201,6 @@ internal class OriginUpdateResponseTest { .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginUpdateResponse.WebFolder.Type.WEB_FOLDER) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -225,7 +221,6 @@ internal class OriginUpdateResponseTest { .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginUpdateResponse.WebProxy.Type.WEB_PROXY) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -250,7 +245,6 @@ internal class OriginUpdateResponseTest { .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginUpdateResponse.WebProxy.Type.WEB_PROXY) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -274,7 +268,6 @@ internal class OriginUpdateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("products") - .type(OriginUpdateResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -303,7 +296,6 @@ internal class OriginUpdateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("products") - .type(OriginUpdateResponse.GoogleCloudStorageGcs.Type.GCS) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -327,7 +319,6 @@ internal class OriginUpdateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("uploads") - .type(OriginUpdateResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -355,7 +346,6 @@ internal class OriginUpdateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("uploads") - .type(OriginUpdateResponse.AzureBlobStorage.Type.AZURE_BLOB) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -377,7 +367,6 @@ internal class OriginUpdateResponseTest { .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginUpdateResponse.AkeneoPim.Type.AKENEO_PIM) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -403,7 +392,6 @@ internal class OriginUpdateResponseTest { .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) .name("US S3 Storage") - .type(OriginUpdateResponse.AkeneoPim.Type.AKENEO_PIM) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt index 579b5930..5f18e0c3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt @@ -21,10 +21,6 @@ internal class UrlEndpointCreateResponseTest { .urlRewriter( UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) .build() @@ -39,10 +35,6 @@ internal class UrlEndpointCreateResponseTest { UrlEndpointCreateResponse.UrlRewriter.ofCloudinary( UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) ) @@ -61,10 +53,6 @@ internal class UrlEndpointCreateResponseTest { .urlRewriter( UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt index 56ed6a2a..f6254249 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt @@ -21,9 +21,6 @@ internal class UrlEndpointGetResponseTest { .urlRewriter( UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY - ) .build() ) .build() @@ -37,9 +34,6 @@ internal class UrlEndpointGetResponseTest { UrlEndpointGetResponse.UrlRewriter.ofCloudinary( UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY - ) .build() ) ) @@ -58,9 +52,6 @@ internal class UrlEndpointGetResponseTest { .urlRewriter( UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.Type.CLOUDINARY - ) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt index 716c1e1f..b21fa619 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt @@ -21,10 +21,6 @@ internal class UrlEndpointListResponseTest { .urlRewriter( UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) .build() @@ -38,10 +34,6 @@ internal class UrlEndpointListResponseTest { UrlEndpointListResponse.UrlRewriter.ofCloudinary( UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) ) @@ -60,10 +52,6 @@ internal class UrlEndpointListResponseTest { .urlRewriter( UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt index 2e8ee57a..e5552227 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt @@ -21,10 +21,6 @@ internal class UrlEndpointUpdateResponseTest { .urlRewriter( UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) .build() @@ -39,10 +35,6 @@ internal class UrlEndpointUpdateResponseTest { UrlEndpointUpdateResponse.UrlRewriter.ofCloudinary( UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) ) @@ -61,10 +53,6 @@ internal class UrlEndpointUpdateResponseTest { .urlRewriter( UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() .preserveAssetDeliveryTypes(true) - .type( - UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.Type - .CLOUDINARY - ) .build() ) .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 b158789e..f22eb5c1 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 @@ -33,7 +33,6 @@ internal class OriginServiceAsyncTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginCreateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -67,7 +66,6 @@ internal class OriginServiceAsyncTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginUpdateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") 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 618762e2..07729640 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 @@ -33,7 +33,6 @@ internal class OriginServiceTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginCreateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -66,7 +65,6 @@ internal class OriginServiceTest { .bucket("test-bucket") .name("My S3 Origin") .secretKey("secrettest123") - .type(OriginUpdateParams.Body.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") From 9cf018aafcad13ab6c4ab58e40ba264032d29330 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 10:22:55 +0000 Subject: [PATCH 023/125] feat(api): manual updates --- .stats.yml | 4 +- .../accounts/origins/OriginCreateResponse.kt | 350 +++--------------- .../accounts/origins/OriginGetResponse.kt | 350 +++--------------- .../accounts/origins/OriginListResponse.kt | 350 +++--------------- .../accounts/origins/OriginUpdateResponse.kt | 350 +++--------------- ...VideoTransformationAcceptedWebhookEvent.kt | 173 ++------- .../VideoTransformationErrorWebhookEvent.kt | 173 ++------- .../VideoTransformationReadyWebhookEvent.kt | 173 ++------- .../origins/OriginCreateResponseTest.kt | 4 - .../accounts/origins/OriginGetResponseTest.kt | 4 - .../origins/OriginListResponseTest.kt | 4 - .../origins/OriginUpdateResponseTest.kt | 4 - .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 8 - .../models/webhooks/UnwrapWebhookEventTest.kt | 8 - ...oTransformationAcceptedWebhookEventTest.kt | 4 - ...ideoTransformationErrorWebhookEventTest.kt | 4 - ...ideoTransformationReadyWebhookEventTest.kt | 4 - 17 files changed, 310 insertions(+), 1657 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9c64de6b..fedb1ee0 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-5ed7a3dbaf059adbd91e86cd61520f59c5fdcc8df3f561df9ab07d7afb722f18.yml -openapi_spec_hash: 51d4d2be59d5d3f81a695a9b8786c77e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-cb2369e849b98127ee6a2cbd01d928e4546d29c1a0a8e64e9b46f90189c1a992.yml +openapi_spec_hash: f8e732e88daf7c4bfbeb2bd2cdba2cec config_hash: b75c4e4432c2d0650589863f8336849b diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt index b9be7155..b72b2ef6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.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 @@ -27,7 +26,6 @@ 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 = OriginCreateResponse.Deserializer::class) @@ -386,7 +384,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -400,7 +398,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -458,10 +456,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -510,13 +513,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -551,7 +547,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -565,7 +560,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("S3") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -647,16 +642,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -704,7 +702,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -716,7 +713,7 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -734,7 +731,11 @@ private constructor( includeCanonicalHeader() name() prefix() - type().validate() + _type().let { + if (it != JsonValue.from("S3")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -760,130 +761,9 @@ private constructor( (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 S3 = of("S3") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3 - } - - /** - * 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 { - S3, - /** 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) { - S3 -> Value.S3 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - 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 @@ -928,7 +808,7 @@ private constructor( private val name: JsonField, private val prefix: JsonField, private val s3ForcePathStyle: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -948,7 +828,7 @@ private constructor( @JsonProperty("s3ForcePathStyle") @ExcludeMissing s3ForcePathStyle: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1024,10 +904,15 @@ private constructor( fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1093,13 +978,6 @@ private constructor( @ExcludeMissing fun _s3ForcePathStyle(): JsonField = s3ForcePathStyle - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1136,7 +1014,6 @@ private constructor( * .name() * .prefix() * .s3ForcePathStyle() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1152,7 +1029,7 @@ private constructor( private var name: JsonField? = null private var prefix: JsonField? = null private var s3ForcePathStyle: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1263,16 +1140,19 @@ private constructor( this.s3ForcePathStyle = s3ForcePathStyle } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1322,7 +1202,6 @@ private constructor( * .name() * .prefix() * .s3ForcePathStyle() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1336,7 +1215,7 @@ private constructor( checkRequired("name", name), checkRequired("prefix", prefix), checkRequired("s3ForcePathStyle", s3ForcePathStyle), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -1356,7 +1235,11 @@ private constructor( name() prefix() s3ForcePathStyle() - type().validate() + _type().let { + if (it != JsonValue.from("S3_COMPATIBLE")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -1384,130 +1267,9 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("S3_COMPATIBLE")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3_COMPATIBLE - } - - /** - * 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 { - S3_COMPATIBLE, - /** 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) { - S3_COMPATIBLE -> Value.S3_COMPATIBLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3_COMPATIBLE -> Known.S3_COMPATIBLE - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt index 2c38cc97..fff95a19 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.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 @@ -27,7 +26,6 @@ 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 = OriginGetResponse.Deserializer::class) @@ -383,7 +381,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -397,7 +395,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -455,10 +453,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -507,13 +510,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -548,7 +544,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -562,7 +557,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("S3") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -644,16 +639,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -701,7 +699,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -713,7 +710,7 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -731,7 +728,11 @@ private constructor( includeCanonicalHeader() name() prefix() - type().validate() + _type().let { + if (it != JsonValue.from("S3")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -757,130 +758,9 @@ private constructor( (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 S3 = of("S3") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3 - } - - /** - * 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 { - S3, - /** 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) { - S3 -> Value.S3 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - 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 @@ -925,7 +805,7 @@ private constructor( private val name: JsonField, private val prefix: JsonField, private val s3ForcePathStyle: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -945,7 +825,7 @@ private constructor( @JsonProperty("s3ForcePathStyle") @ExcludeMissing s3ForcePathStyle: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1021,10 +901,15 @@ private constructor( fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1090,13 +975,6 @@ private constructor( @ExcludeMissing fun _s3ForcePathStyle(): JsonField = s3ForcePathStyle - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1133,7 +1011,6 @@ private constructor( * .name() * .prefix() * .s3ForcePathStyle() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1149,7 +1026,7 @@ private constructor( private var name: JsonField? = null private var prefix: JsonField? = null private var s3ForcePathStyle: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1260,16 +1137,19 @@ private constructor( this.s3ForcePathStyle = s3ForcePathStyle } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1319,7 +1199,6 @@ private constructor( * .name() * .prefix() * .s3ForcePathStyle() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1333,7 +1212,7 @@ private constructor( checkRequired("name", name), checkRequired("prefix", prefix), checkRequired("s3ForcePathStyle", s3ForcePathStyle), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -1353,7 +1232,11 @@ private constructor( name() prefix() s3ForcePathStyle() - type().validate() + _type().let { + if (it != JsonValue.from("S3_COMPATIBLE")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -1381,130 +1264,9 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("S3_COMPATIBLE")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3_COMPATIBLE - } - - /** - * 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 { - S3_COMPATIBLE, - /** 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) { - S3_COMPATIBLE -> Value.S3_COMPATIBLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3_COMPATIBLE -> Known.S3_COMPATIBLE - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt index 14ab163a..4b159e15 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.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 @@ -27,7 +26,6 @@ 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 = OriginListResponse.Deserializer::class) @@ -383,7 +381,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -397,7 +395,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -455,10 +453,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -507,13 +510,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -548,7 +544,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -562,7 +557,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("S3") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -644,16 +639,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -701,7 +699,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -713,7 +710,7 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -731,7 +728,11 @@ private constructor( includeCanonicalHeader() name() prefix() - type().validate() + _type().let { + if (it != JsonValue.from("S3")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -757,130 +758,9 @@ private constructor( (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 S3 = of("S3") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3 - } - - /** - * 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 { - S3, - /** 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) { - S3 -> Value.S3 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - 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 @@ -925,7 +805,7 @@ private constructor( private val name: JsonField, private val prefix: JsonField, private val s3ForcePathStyle: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -945,7 +825,7 @@ private constructor( @JsonProperty("s3ForcePathStyle") @ExcludeMissing s3ForcePathStyle: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1021,10 +901,15 @@ private constructor( fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1090,13 +975,6 @@ private constructor( @ExcludeMissing fun _s3ForcePathStyle(): JsonField = s3ForcePathStyle - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1133,7 +1011,6 @@ private constructor( * .name() * .prefix() * .s3ForcePathStyle() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1149,7 +1026,7 @@ private constructor( private var name: JsonField? = null private var prefix: JsonField? = null private var s3ForcePathStyle: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1260,16 +1137,19 @@ private constructor( this.s3ForcePathStyle = s3ForcePathStyle } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1319,7 +1199,6 @@ private constructor( * .name() * .prefix() * .s3ForcePathStyle() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1333,7 +1212,7 @@ private constructor( checkRequired("name", name), checkRequired("prefix", prefix), checkRequired("s3ForcePathStyle", s3ForcePathStyle), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -1353,7 +1232,11 @@ private constructor( name() prefix() s3ForcePathStyle() - type().validate() + _type().let { + if (it != JsonValue.from("S3_COMPATIBLE")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -1381,130 +1264,9 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("S3_COMPATIBLE")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3_COMPATIBLE - } - - /** - * 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 { - S3_COMPATIBLE, - /** 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) { - S3_COMPATIBLE -> Value.S3_COMPATIBLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3_COMPATIBLE -> Known.S3_COMPATIBLE - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt index 740d67e4..d2c571f8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.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 @@ -27,7 +26,6 @@ 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 = OriginUpdateResponse.Deserializer::class) @@ -386,7 +384,7 @@ private constructor( private val includeCanonicalHeader: JsonField, private val name: JsonField, private val prefix: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -400,7 +398,7 @@ private constructor( includeCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -458,10 +456,15 @@ private constructor( fun prefix(): String = prefix.getRequired("prefix") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -510,13 +513,6 @@ private constructor( */ @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -551,7 +547,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -565,7 +560,7 @@ private constructor( private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null private var prefix: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("S3") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -647,16 +642,19 @@ private constructor( */ fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -704,7 +702,6 @@ private constructor( * .includeCanonicalHeader() * .name() * .prefix() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -716,7 +713,7 @@ private constructor( checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), checkRequired("prefix", prefix), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -734,7 +731,11 @@ private constructor( includeCanonicalHeader() name() prefix() - type().validate() + _type().let { + if (it != JsonValue.from("S3")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -760,130 +761,9 @@ private constructor( (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 S3 = of("S3") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3 - } - - /** - * 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 { - S3, - /** 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) { - S3 -> Value.S3 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - 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 @@ -928,7 +808,7 @@ private constructor( private val name: JsonField, private val prefix: JsonField, private val s3ForcePathStyle: JsonField, - private val type: JsonField, + private val type: JsonValue, private val baseUrlForCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @@ -948,7 +828,7 @@ private constructor( @JsonProperty("s3ForcePathStyle") @ExcludeMissing s3ForcePathStyle: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1024,10 +904,15 @@ private constructor( fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * URL used in the Canonical header (if enabled). @@ -1093,13 +978,6 @@ private constructor( @ExcludeMissing fun _s3ForcePathStyle(): JsonField = s3ForcePathStyle - /** - * 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 [baseUrlForCanonicalHeader]. * @@ -1136,7 +1014,6 @@ private constructor( * .name() * .prefix() * .s3ForcePathStyle() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -1152,7 +1029,7 @@ private constructor( private var name: JsonField? = null private var prefix: JsonField? = null private var s3ForcePathStyle: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1263,16 +1140,19 @@ private constructor( this.s3ForcePathStyle = s3ForcePathStyle } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1322,7 +1202,6 @@ private constructor( * .name() * .prefix() * .s3ForcePathStyle() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1336,7 +1215,7 @@ private constructor( checkRequired("name", name), checkRequired("prefix", prefix), checkRequired("s3ForcePathStyle", s3ForcePathStyle), - checkRequired("type", type), + type, baseUrlForCanonicalHeader, additionalProperties.toMutableMap(), ) @@ -1356,7 +1235,11 @@ private constructor( name() prefix() s3ForcePathStyle() - type().validate() + _type().let { + if (it != JsonValue.from("S3_COMPATIBLE")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } baseUrlForCanonicalHeader() validated = true } @@ -1384,130 +1267,9 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("S3_COMPATIBLE")) 1 else 0 } + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) - 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 S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3_COMPATIBLE - } - - /** - * 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 { - S3_COMPATIBLE, - /** 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) { - S3_COMPATIBLE -> Value.S3_COMPATIBLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3_COMPATIBLE -> Known.S3_COMPATIBLE - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt index 8fc09857..60f51bed 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt @@ -27,7 +27,7 @@ private constructor( private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -39,7 +39,7 @@ private constructor( createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(id, createdAt, data, request, type, mutableMapOf()) /** @@ -69,10 +69,15 @@ private constructor( fun request(): Request = request.getRequired("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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [id]. @@ -104,13 +109,6 @@ private constructor( */ @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request - /** - * 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) @@ -135,7 +133,6 @@ private constructor( * .createdAt() * .data() * .request() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -148,7 +145,7 @@ private constructor( private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("video.transformation.accepted") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -206,15 +203,19 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -246,7 +247,6 @@ private constructor( * .createdAt() * .data() * .request() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -257,7 +257,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } @@ -273,7 +273,11 @@ private constructor( createdAt() data().validate() request().validate() - type().validate() + _type().let { + if (it != JsonValue.from("video.transformation.accepted")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -296,7 +300,7 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + (request.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("video.transformation.accepted")) 1 else 0 } class Data private constructor( @@ -2202,127 +2206,6 @@ private constructor( "Request{url=$url, xRequestId=$xRequestId, userAgent=$userAgent, additionalProperties=$additionalProperties}" } - 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_ACCEPTED = of("video.transformation.accepted") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - VIDEO_TRANSFORMATION_ACCEPTED - } - - /** - * 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_ACCEPTED, - /** 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_ACCEPTED -> Value.VIDEO_TRANSFORMATION_ACCEPTED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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_ACCEPTED -> Known.VIDEO_TRANSFORMATION_ACCEPTED - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt index aaf7c834..4e8911b5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt @@ -27,7 +27,7 @@ private constructor( private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -39,7 +39,7 @@ private constructor( createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(id, createdAt, data, request, type, mutableMapOf()) /** @@ -69,10 +69,15 @@ private constructor( fun request(): Request = request.getRequired("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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [id]. @@ -104,13 +109,6 @@ private constructor( */ @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request - /** - * 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) @@ -135,7 +133,6 @@ private constructor( * .createdAt() * .data() * .request() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -148,7 +145,7 @@ private constructor( private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("video.transformation.error") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -206,15 +203,19 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -246,7 +247,6 @@ private constructor( * .createdAt() * .data() * .request() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -257,7 +257,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } @@ -273,7 +273,11 @@ private constructor( createdAt() data().validate() request().validate() - type().validate() + _type().let { + if (it != JsonValue.from("video.transformation.error")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -296,7 +300,7 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + (request.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("video.transformation.error")) 1 else 0 } class Data private constructor( @@ -2536,127 +2540,6 @@ private constructor( "Request{url=$url, xRequestId=$xRequestId, userAgent=$userAgent, additionalProperties=$additionalProperties}" } - 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_ERROR = of("video.transformation.error") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - VIDEO_TRANSFORMATION_ERROR - } - - /** - * 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_ERROR, - /** 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_ERROR -> Value.VIDEO_TRANSFORMATION_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) { - VIDEO_TRANSFORMATION_ERROR -> Known.VIDEO_TRANSFORMATION_ERROR - 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt index fe77db61..3a99ebb5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt @@ -27,7 +27,7 @@ private constructor( private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonField, + private val type: JsonValue, private val timings: JsonField, private val additionalProperties: MutableMap, ) { @@ -40,7 +40,7 @@ private constructor( createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: 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()) @@ -71,10 +71,15 @@ private constructor( fun request(): Request = request.getRequired("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). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -112,13 +117,6 @@ private constructor( */ @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request - /** - * 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 [timings]. * @@ -150,7 +148,6 @@ private constructor( * .createdAt() * .data() * .request() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -163,7 +160,7 @@ private constructor( private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("video.transformation.ready") private var timings: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -223,15 +220,19 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } fun timings(timings: Timings) = timings(JsonField.of(timings)) @@ -273,7 +274,6 @@ private constructor( * .createdAt() * .data() * .request() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -284,7 +284,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - checkRequired("type", type), + type, timings, additionalProperties.toMutableMap(), ) @@ -301,7 +301,11 @@ private constructor( createdAt() data().validate() request().validate() - type().validate() + _type().let { + if (it != JsonValue.from("video.transformation.ready")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } timings().ifPresent { it.validate() } validated = true } @@ -325,7 +329,7 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + (request.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("video.transformation.ready")) 1 else 0 } + (timings.asKnown().getOrNull()?.validity() ?: 0) class Data @@ -2758,127 +2762,6 @@ private constructor( "Request{url=$url, xRequestId=$xRequestId, userAgent=$userAgent, additionalProperties=$additionalProperties}" } - 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_READY = of("video.transformation.ready") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - VIDEO_TRANSFORMATION_READY - } - - /** - * 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_READY, - /** 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_READY -> Value.VIDEO_TRANSFORMATION_READY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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_READY -> Known.VIDEO_TRANSFORMATION_READY - 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() - } - class Timings private constructor( private val downloadDuration: JsonField, diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt index 46ec775a..db4c0d29 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt @@ -23,7 +23,6 @@ internal class OriginCreateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginCreateResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -50,7 +49,6 @@ internal class OriginCreateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginCreateResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -75,7 +73,6 @@ internal class OriginCreateResponseTest { .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) - .type(OriginCreateResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -104,7 +101,6 @@ internal class OriginCreateResponseTest { .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) - .type(OriginCreateResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt index 6e0ecfdf..d276b8de 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt @@ -23,7 +23,6 @@ internal class OriginGetResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginGetResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -50,7 +49,6 @@ internal class OriginGetResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginGetResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -75,7 +73,6 @@ internal class OriginGetResponseTest { .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) - .type(OriginGetResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -104,7 +101,6 @@ internal class OriginGetResponseTest { .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) - .type(OriginGetResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt index e3aed573..351f3b6c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt @@ -23,7 +23,6 @@ internal class OriginListResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginListResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -50,7 +49,6 @@ internal class OriginListResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginListResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -75,7 +73,6 @@ internal class OriginListResponseTest { .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) - .type(OriginListResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -104,7 +101,6 @@ internal class OriginListResponseTest { .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) - .type(OriginListResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt index e3a32e54..ab884763 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt @@ -23,7 +23,6 @@ internal class OriginUpdateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginUpdateResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -50,7 +49,6 @@ internal class OriginUpdateResponseTest { .includeCanonicalHeader(false) .name("US S3 Storage") .prefix("raw-assets") - .type(OriginUpdateResponse.S3.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -75,7 +73,6 @@ internal class OriginUpdateResponseTest { .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) - .type(OriginUpdateResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") .build() @@ -104,7 +101,6 @@ internal class OriginUpdateResponseTest { .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) - .type(OriginUpdateResponse.S3Compatible.Type.S3_COMPATIBLE) .baseUrlForCanonicalHeader("https://cdn.example.com") .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 c5719432..4c4d677d 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 @@ -82,7 +82,6 @@ internal class UnsafeUnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) .build() val unsafeUnwrapWebhookEvent = @@ -165,9 +164,6 @@ internal class UnsafeUnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type( - VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED - ) .build() ) @@ -259,7 +255,6 @@ internal class UnsafeUnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) .timings( VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) @@ -366,7 +361,6 @@ internal class UnsafeUnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) .timings( VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) @@ -458,7 +452,6 @@ internal class UnsafeUnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) .build() val unsafeUnwrapWebhookEvent = @@ -553,7 +546,6 @@ internal class UnsafeUnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) .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 522d81d3..4b31cdb6 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 @@ -82,7 +82,6 @@ internal class UnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) .build() val unwrapWebhookEvent = @@ -165,9 +164,6 @@ internal class UnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type( - VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED - ) .build() ) @@ -259,7 +255,6 @@ internal class UnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) .timings( VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) @@ -365,7 +360,6 @@ internal class UnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) .timings( VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) @@ -457,7 +451,6 @@ internal class UnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) .build() val unwrapWebhookEvent = @@ -551,7 +544,6 @@ internal class UnwrapWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt index 32268b9b..bc1840af 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt @@ -77,7 +77,6 @@ internal class VideoTransformationAcceptedWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) .build() assertThat(videoTransformationAcceptedWebhookEvent.id()).isEqualTo("id") @@ -141,8 +140,6 @@ internal class VideoTransformationAcceptedWebhookEventTest { .userAgent("user_agent") .build() ) - assertThat(videoTransformationAcceptedWebhookEvent.type()) - .isEqualTo(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) } @Test @@ -213,7 +210,6 @@ internal class VideoTransformationAcceptedWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationAcceptedWebhookEvent.Type.VIDEO_TRANSFORMATION_ACCEPTED) .build() val roundtrippedVideoTransformationAcceptedWebhookEvent = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt index f900a174..5cf7bfe7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt @@ -83,7 +83,6 @@ internal class VideoTransformationErrorWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) .build() assertThat(videoTransformationErrorWebhookEvent.id()).isEqualTo("id") @@ -158,8 +157,6 @@ internal class VideoTransformationErrorWebhookEventTest { .userAgent("user_agent") .build() ) - assertThat(videoTransformationErrorWebhookEvent.type()) - .isEqualTo(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) } @Test @@ -236,7 +233,6 @@ internal class VideoTransformationErrorWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationErrorWebhookEvent.Type.VIDEO_TRANSFORMATION_ERROR) .build() val roundtrippedVideoTransformationErrorWebhookEvent = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt index 5c942b86..c9ad1646 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt @@ -89,7 +89,6 @@ internal class VideoTransformationReadyWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) .timings( VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) @@ -176,8 +175,6 @@ internal class VideoTransformationReadyWebhookEventTest { .userAgent("user_agent") .build() ) - assertThat(videoTransformationReadyWebhookEvent.type()) - .isEqualTo(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) assertThat(videoTransformationReadyWebhookEvent.timings()) .contains( VideoTransformationReadyWebhookEvent.Timings.builder() @@ -267,7 +264,6 @@ internal class VideoTransformationReadyWebhookEventTest { .userAgent("user_agent") .build() ) - .type(VideoTransformationReadyWebhookEvent.Type.VIDEO_TRANSFORMATION_READY) .timings( VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) From 164b524c23570d1697887ea6b4fe5bf7ec22516c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:00:22 +0000 Subject: [PATCH 024/125] feat(api): manual updates --- .stats.yml | 2 +- README.md | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.stats.yml b/.stats.yml index fedb1ee0..3ae65fac 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-cb2369e849b98127ee6a2cbd01d928e4546d29c1a0a8e64e9b46f90189c1a992.yml openapi_spec_hash: f8e732e88daf7c4bfbeb2bd2cdba2cec -config_hash: b75c4e4432c2d0650589863f8336849b +config_hash: c9b1142a72b93ad4d66f0433dca1392e diff --git a/README.md b/README.md index cb3ea8a9..48a34ace 100644 --- a/README.md +++ b/README.md @@ -45,8 +45,8 @@ import java.io.ByteArrayInputStream; ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("some content".getBytes())) - .fileName("fileName") + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -150,8 +150,8 @@ import java.util.concurrent.CompletableFuture; ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("some content".getBytes())) - .fileName("fileName") + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); CompletableFuture response = client.async().files().upload(params); ``` @@ -171,8 +171,8 @@ import java.util.concurrent.CompletableFuture; ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("some content".getBytes())) - .fileName("fileName") + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); CompletableFuture response = client.files().upload(params); ``` @@ -257,8 +257,8 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("some content".getBytes())) - .fileName("fileName") + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); @@ -505,11 +505,10 @@ To set a documented parameter or property to an undocumented or not yet supporte ```java import com.imagekit.api.core.JsonValue; import com.imagekit.api.models.files.FileUploadParams; -import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("some content".getBytes())) - .fileName(JsonValue.from(42)) + .file(JsonValue.from(42)) + .fileName("file-name.jpg") .build(); ``` From fd0113b5c3b303fe84a1c322c939f0f6b53c88b6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:20:36 +0000 Subject: [PATCH 025/125] feat(api): manual updates --- .stats.yml | 4 +- .../CustomMetadataFieldCreateParams.kt | 490 ++++++++++++------ .../CustomMetadataFieldCreateResponse.kt | 490 ++++++++++++------ .../CustomMetadataFieldListResponse.kt | 490 ++++++++++++------ .../CustomMetadataFieldUpdateParams.kt | 490 ++++++++++++------ .../CustomMetadataFieldUpdateResponse.kt | 490 ++++++++++++------ .../CustomMetadataFieldCreateParamsTest.kt | 15 +- .../CustomMetadataFieldCreateResponseTest.kt | 15 +- .../CustomMetadataFieldListResponseTest.kt | 15 +- .../CustomMetadataFieldUpdateParamsTest.kt | 15 +- .../CustomMetadataFieldUpdateResponseTest.kt | 15 +- .../CustomMetadataFieldServiceAsyncTest.kt | 10 +- .../CustomMetadataFieldServiceTest.kt | 10 +- 13 files changed, 1698 insertions(+), 851 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3ae65fac..fe627405 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-cb2369e849b98127ee6a2cbd01d928e4546d29c1a0a8e64e9b46f90189c1a992.yml -openapi_spec_hash: f8e732e88daf7c4bfbeb2bd2cdba2cec +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-cb74df1af0b7cdd4f66573d2d002f003b74702172ddd2c8495c465a7706c4d66.yml +openapi_spec_hash: 9a1fb60cda92b3e693e8c0f0fde0508a config_hash: c9b1142a72b93ad4d66f0433dca1392e 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 cdc7d3fb..e9bb9440 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 @@ -844,25 +844,19 @@ private constructor( 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.ofUnionMember0(unionMember0)`. + */ + fun defaultValue(unionMember0: DefaultValue.UnionMember0) = + defaultValue(DefaultValue.ofUnionMember0(unionMember0)) /** * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s)`. + * `DefaultValue.ofJsonScalarArray(jsonScalarArray)`. */ - fun defaultValueOfUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) - ) + fun defaultValueOfJsonScalarArray( + jsonScalarArray: List + ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) /** * Sets this custom metadata field as required. Setting custom metadata fields on an @@ -1251,56 +1245,33 @@ private constructor( @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 unnamedSchemaWithArrayParent3s: List? = null, + private val unionMember0: UnionMember0? = null, + private val jsonScalarArray: 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 unnamedSchemaWithArrayParent3s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent3s) + /** Primitive JSON scalar. */ + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun isString(): Boolean = string != null + fun jsonScalarArray(): Optional> = + Optional.ofNullable(jsonScalarArray) - fun isNumber(): Boolean = number != null + fun isUnionMember0(): Boolean = unionMember0 != null - fun isBool(): Boolean = bool != null + fun isJsonScalarArray(): Boolean = jsonScalarArray != null - fun isUnnamedSchemaWithArrayParent3s(): Boolean = unnamedSchemaWithArrayParent3s != null + /** Primitive JSON scalar. */ + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - 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 asUnnamedSchemaWithArrayParent3s(): List = - unnamedSchemaWithArrayParent3s.getOrThrow("unnamedSchemaWithArrayParent3s") + fun asJsonScalarArray(): List = + jsonScalarArray.getOrThrow("jsonScalarArray") 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) - unnamedSchemaWithArrayParent3s != null -> - visitor.visitUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) else -> visitor.unknown(_json) } @@ -1313,16 +1284,14 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } - override fun visitUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List + override fun visitJsonScalarArray( + jsonScalarArray: List ) { - unnamedSchemaWithArrayParent3s.forEach { it.validate() } + jsonScalarArray.forEach { it.validate() } } } ) @@ -1347,15 +1316,12 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun visitUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List - ) = unnamedSchemaWithArrayParent3s.sumOf { it.validity().toInt() } + override fun visitJsonScalarArray( + jsonScalarArray: List + ) = jsonScalarArray.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1367,46 +1333,30 @@ private constructor( } return other is DefaultValue && - string == other.string && - number == other.number && - bool == other.bool && - unnamedSchemaWithArrayParent3s == other.unnamedSchemaWithArrayParent3s + unionMember0 == other.unionMember0 && + jsonScalarArray == other.jsonScalarArray } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent3s) + override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) override fun toString(): String = when { - string != null -> "DefaultValue{string=$string}" - number != null -> "DefaultValue{number=$number}" - bool != null -> "DefaultValue{bool=$bool}" - unnamedSchemaWithArrayParent3s != null -> - "DefaultValue{unnamedSchemaWithArrayParent3s=$unnamedSchemaWithArrayParent3s}" + unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" + jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" _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) + /** Primitive JSON scalar. */ + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + DefaultValue(unionMember0 = unionMember0) - /** - * Default value should be of type array when custom metadata field type is set to - * `MultiSelect`. - */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent3s = - unnamedSchemaWithArrayParent3s.toImmutable() - ) + fun ofJsonScalarArray(jsonScalarArray: List) = + DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) } /** @@ -1415,19 +1365,10 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitUnionMember0(unionMember0: UnionMember0): 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 visitUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List - ): T + fun visitJsonScalarArray(jsonScalarArray: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1451,25 +1392,14 @@ private constructor( 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(unionMember0 = it, _json = json) }, tryDeserialize( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent3s = it, - _json = json, - ) - }, + ?.let { DefaultValue(jsonScalarArray = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1495,52 +1425,268 @@ private constructor( 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.unnamedSchemaWithArrayParent3s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent3s) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.jsonScalarArray != null -> + generator.writeObject(value.jsonScalarArray) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } + /** Primitive JSON scalar. */ + @JsonDeserialize(using = UnionMember0.Deserializer::class) + @JsonSerialize(using = UnionMember0.Serializer::class) + class UnionMember0 + private constructor( + private val jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitJsonScalar(jsonScalar: String) {} + + override fun visitJsonScalar(jsonScalar: Double) {} + + override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 + + override fun visitJsonScalar(jsonScalar: Double) = 1 + + override fun visitJsonScalar(jsonScalar: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar + } + + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + + override fun toString(): String = + when { + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + _json != null -> "UnionMember0{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnionMember0") + } + + companion object { + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) + } + + /** + * An interface that defines how to map each variant of [UnionMember0] to a value of + * type [T]. + */ + interface Visitor { + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T + + /** + * Maps an unknown variant of [UnionMember0] to a value of type [T]. + * + * An instance of [UnionMember0] 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 UnionMember0: $json") + } + } + + internal class Deserializer : BaseDeserializer(UnionMember0::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { + + override fun serialize( + value: UnionMember0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnionMember0") + } + } + } + } + + /** Primitive JSON scalar. */ @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) class UnnamedSchemaWithArrayParent3 private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, + private val jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, private val _json: JsonValue? = null, ) { - fun string(): Optional = Optional.ofNullable(string) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun number(): Optional = Optional.ofNullable(number) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun bool(): Optional = Optional.ofNullable(bool) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun isString(): Boolean = string != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isNumber(): Boolean = number != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isBool(): Boolean = bool != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun asString(): String = string.getOrThrow("string") + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - fun asNumber(): Double = number.getOrThrow("number") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - fun asBool(): Boolean = bool.getOrThrow("bool") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") 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) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) else -> visitor.unknown(_json) } @@ -1553,11 +1699,11 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} + override fun visitJsonScalar(jsonScalar: String) {} - override fun visitNumber(number: Double) {} + override fun visitJsonScalar(jsonScalar: Double) {} - override fun visitBool(bool: Boolean) {} + override fun visitJsonScalar(jsonScalar: Boolean) {} } ) validated = true @@ -1581,11 +1727,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitJsonScalar(jsonScalar: String) = 1 - override fun visitNumber(number: Double) = 1 + override fun visitJsonScalar(jsonScalar: Double) = 1 - override fun visitBool(bool: Boolean) = 1 + override fun visitJsonScalar(jsonScalar: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1597,32 +1743,41 @@ private constructor( } return other is UnnamedSchemaWithArrayParent3 && - string == other.string && - number == other.number && - bool == other.bool + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar } - override fun hashCode(): Int = Objects.hash(string, number, bool) + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent3{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent3{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent3{bool=$bool}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent3{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent3{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent3{jsonScalar=$jsonScalar}" _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } companion object { + /** Primitive JSON scalar. */ @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent3(string = string) + fun ofJsonScalar(jsonScalar: String) = + UnnamedSchemaWithArrayParent3(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent3(number = number) + fun ofJsonScalar(jsonScalar: Double) = + UnnamedSchemaWithArrayParent3(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent3(bool = bool) + fun ofJsonScalar(jsonScalar: Boolean) = + UnnamedSchemaWithArrayParent3(jsonScalar = jsonScalar) } /** @@ -1631,11 +1786,14 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T - fun visitNumber(number: Double): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T - fun visitBool(bool: Boolean): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type @@ -1668,13 +1826,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(string = it, _json = json) + UnnamedSchemaWithArrayParent3(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(number = it, _json = json) + UnnamedSchemaWithArrayParent3(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(bool = it, _json = json) + UnnamedSchemaWithArrayParent3(jsonScalar = it, _json = json) }, ) .filterNotNull() @@ -1705,9 +1863,9 @@ private constructor( 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.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt index 0b38db4f..232b8476 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt @@ -553,25 +553,19 @@ private constructor( 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.ofUnionMember0(unionMember0)`. + */ + fun defaultValue(unionMember0: DefaultValue.UnionMember0) = + defaultValue(DefaultValue.ofUnionMember0(unionMember0)) /** * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s)`. + * `DefaultValue.ofJsonScalarArray(jsonScalarArray)`. */ - fun defaultValueOfUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) - ) + fun defaultValueOfJsonScalarArray( + jsonScalarArray: List + ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) /** Specifies if the this custom metadata field is required or not. */ fun isValueRequired(isValueRequired: Boolean) = @@ -946,56 +940,33 @@ private constructor( @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 unnamedSchemaWithArrayParent0s: List? = null, + private val unionMember0: UnionMember0? = null, + private val jsonScalarArray: 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 unnamedSchemaWithArrayParent0s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent0s) + /** Primitive JSON scalar. */ + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun isString(): Boolean = string != null + fun jsonScalarArray(): Optional> = + Optional.ofNullable(jsonScalarArray) - fun isNumber(): Boolean = number != null + fun isUnionMember0(): Boolean = unionMember0 != null - fun isBool(): Boolean = bool != null + fun isJsonScalarArray(): Boolean = jsonScalarArray != null - fun isUnnamedSchemaWithArrayParent0s(): Boolean = unnamedSchemaWithArrayParent0s != null + /** Primitive JSON scalar. */ + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - 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 asUnnamedSchemaWithArrayParent0s(): List = - unnamedSchemaWithArrayParent0s.getOrThrow("unnamedSchemaWithArrayParent0s") + fun asJsonScalarArray(): List = + jsonScalarArray.getOrThrow("jsonScalarArray") 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) - unnamedSchemaWithArrayParent0s != null -> - visitor.visitUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) else -> visitor.unknown(_json) } @@ -1008,16 +979,14 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } - override fun visitUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List + override fun visitJsonScalarArray( + jsonScalarArray: List ) { - unnamedSchemaWithArrayParent0s.forEach { it.validate() } + jsonScalarArray.forEach { it.validate() } } } ) @@ -1042,15 +1011,12 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun visitUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ) = unnamedSchemaWithArrayParent0s.sumOf { it.validity().toInt() } + override fun visitJsonScalarArray( + jsonScalarArray: List + ) = jsonScalarArray.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1062,46 +1028,30 @@ private constructor( } return other is DefaultValue && - string == other.string && - number == other.number && - bool == other.bool && - unnamedSchemaWithArrayParent0s == other.unnamedSchemaWithArrayParent0s + unionMember0 == other.unionMember0 && + jsonScalarArray == other.jsonScalarArray } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent0s) + override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) override fun toString(): String = when { - string != null -> "DefaultValue{string=$string}" - number != null -> "DefaultValue{number=$number}" - bool != null -> "DefaultValue{bool=$bool}" - unnamedSchemaWithArrayParent0s != null -> - "DefaultValue{unnamedSchemaWithArrayParent0s=$unnamedSchemaWithArrayParent0s}" + unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" + jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" _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) + /** Primitive JSON scalar. */ + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + DefaultValue(unionMember0 = unionMember0) - /** - * Default value should be of type array when custom metadata field type is set to - * `MultiSelect`. - */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent0s = - unnamedSchemaWithArrayParent0s.toImmutable() - ) + fun ofJsonScalarArray(jsonScalarArray: List) = + DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) } /** @@ -1110,19 +1060,10 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitUnionMember0(unionMember0: UnionMember0): 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 visitUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ): T + fun visitJsonScalarArray(jsonScalarArray: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1146,25 +1087,14 @@ private constructor( 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(unionMember0 = it, _json = json) }, tryDeserialize( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent0s = it, - _json = json, - ) - }, + ?.let { DefaultValue(jsonScalarArray = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1190,52 +1120,268 @@ private constructor( 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.unnamedSchemaWithArrayParent0s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent0s) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.jsonScalarArray != null -> + generator.writeObject(value.jsonScalarArray) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } + /** Primitive JSON scalar. */ + @JsonDeserialize(using = UnionMember0.Deserializer::class) + @JsonSerialize(using = UnionMember0.Serializer::class) + class UnionMember0 + private constructor( + private val jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitJsonScalar(jsonScalar: String) {} + + override fun visitJsonScalar(jsonScalar: Double) {} + + override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 + + override fun visitJsonScalar(jsonScalar: Double) = 1 + + override fun visitJsonScalar(jsonScalar: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar + } + + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + + override fun toString(): String = + when { + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + _json != null -> "UnionMember0{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnionMember0") + } + + companion object { + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) + } + + /** + * An interface that defines how to map each variant of [UnionMember0] to a value of + * type [T]. + */ + interface Visitor { + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T + + /** + * Maps an unknown variant of [UnionMember0] to a value of type [T]. + * + * An instance of [UnionMember0] 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 UnionMember0: $json") + } + } + + internal class Deserializer : BaseDeserializer(UnionMember0::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { + + override fun serialize( + value: UnionMember0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnionMember0") + } + } + } + } + + /** Primitive JSON scalar. */ @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 jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, private val _json: JsonValue? = null, ) { - fun string(): Optional = Optional.ofNullable(string) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun number(): Optional = Optional.ofNullable(number) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun bool(): Optional = Optional.ofNullable(bool) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun isString(): Boolean = string != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isNumber(): Boolean = number != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isBool(): Boolean = bool != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun asString(): String = string.getOrThrow("string") + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - fun asNumber(): Double = number.getOrThrow("number") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - fun asBool(): Boolean = bool.getOrThrow("bool") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") 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) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) else -> visitor.unknown(_json) } @@ -1248,11 +1394,11 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} + override fun visitJsonScalar(jsonScalar: String) {} - override fun visitNumber(number: Double) {} + override fun visitJsonScalar(jsonScalar: Double) {} - override fun visitBool(bool: Boolean) {} + override fun visitJsonScalar(jsonScalar: Boolean) {} } ) validated = true @@ -1276,11 +1422,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitJsonScalar(jsonScalar: String) = 1 - override fun visitNumber(number: Double) = 1 + override fun visitJsonScalar(jsonScalar: Double) = 1 - override fun visitBool(bool: Boolean) = 1 + override fun visitJsonScalar(jsonScalar: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1292,32 +1438,41 @@ private constructor( } return other is UnnamedSchemaWithArrayParent0 && - string == other.string && - number == other.number && - bool == other.bool + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar } - override fun hashCode(): Int = Objects.hash(string, number, bool) + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent0{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent0{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent0{bool=$bool}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent0{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent0{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent0{jsonScalar=$jsonScalar}" _json != null -> "UnnamedSchemaWithArrayParent0{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") } companion object { + /** Primitive JSON scalar. */ @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent0(string = string) + fun ofJsonScalar(jsonScalar: String) = + UnnamedSchemaWithArrayParent0(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent0(number = number) + fun ofJsonScalar(jsonScalar: Double) = + UnnamedSchemaWithArrayParent0(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent0(bool = bool) + fun ofJsonScalar(jsonScalar: Boolean) = + UnnamedSchemaWithArrayParent0(jsonScalar = jsonScalar) } /** @@ -1326,11 +1481,14 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T - fun visitNumber(number: Double): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T - fun visitBool(bool: Boolean): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to a value of type @@ -1363,13 +1521,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(string = it, _json = json) + UnnamedSchemaWithArrayParent0(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(number = it, _json = json) + UnnamedSchemaWithArrayParent0(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(bool = it, _json = json) + UnnamedSchemaWithArrayParent0(jsonScalar = it, _json = json) }, ) .filterNotNull() @@ -1400,9 +1558,9 @@ private constructor( 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.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt index 8e4fd30f..ca3b9986 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt @@ -553,25 +553,19 @@ private constructor( 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.ofUnionMember0(unionMember0)`. + */ + fun defaultValue(unionMember0: DefaultValue.UnionMember0) = + defaultValue(DefaultValue.ofUnionMember0(unionMember0)) /** * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s)`. + * `DefaultValue.ofJsonScalarArray(jsonScalarArray)`. */ - fun defaultValueOfUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) - ) + fun defaultValueOfJsonScalarArray( + jsonScalarArray: List + ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) /** Specifies if the this custom metadata field is required or not. */ fun isValueRequired(isValueRequired: Boolean) = @@ -946,56 +940,33 @@ private constructor( @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 unnamedSchemaWithArrayParent2s: List? = null, + private val unionMember0: UnionMember0? = null, + private val jsonScalarArray: 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 unnamedSchemaWithArrayParent2s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent2s) + /** Primitive JSON scalar. */ + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun isString(): Boolean = string != null + fun jsonScalarArray(): Optional> = + Optional.ofNullable(jsonScalarArray) - fun isNumber(): Boolean = number != null + fun isUnionMember0(): Boolean = unionMember0 != null - fun isBool(): Boolean = bool != null + fun isJsonScalarArray(): Boolean = jsonScalarArray != null - fun isUnnamedSchemaWithArrayParent2s(): Boolean = unnamedSchemaWithArrayParent2s != null + /** Primitive JSON scalar. */ + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - 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 asUnnamedSchemaWithArrayParent2s(): List = - unnamedSchemaWithArrayParent2s.getOrThrow("unnamedSchemaWithArrayParent2s") + fun asJsonScalarArray(): List = + jsonScalarArray.getOrThrow("jsonScalarArray") 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) - unnamedSchemaWithArrayParent2s != null -> - visitor.visitUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) else -> visitor.unknown(_json) } @@ -1008,16 +979,14 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } - override fun visitUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List + override fun visitJsonScalarArray( + jsonScalarArray: List ) { - unnamedSchemaWithArrayParent2s.forEach { it.validate() } + jsonScalarArray.forEach { it.validate() } } } ) @@ -1042,15 +1011,12 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun visitUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ) = unnamedSchemaWithArrayParent2s.sumOf { it.validity().toInt() } + override fun visitJsonScalarArray( + jsonScalarArray: List + ) = jsonScalarArray.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1062,46 +1028,30 @@ private constructor( } return other is DefaultValue && - string == other.string && - number == other.number && - bool == other.bool && - unnamedSchemaWithArrayParent2s == other.unnamedSchemaWithArrayParent2s + unionMember0 == other.unionMember0 && + jsonScalarArray == other.jsonScalarArray } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent2s) + override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) override fun toString(): String = when { - string != null -> "DefaultValue{string=$string}" - number != null -> "DefaultValue{number=$number}" - bool != null -> "DefaultValue{bool=$bool}" - unnamedSchemaWithArrayParent2s != null -> - "DefaultValue{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" + unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" + jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" _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) + /** Primitive JSON scalar. */ + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + DefaultValue(unionMember0 = unionMember0) - /** - * Default value should be of type array when custom metadata field type is set to - * `MultiSelect`. - */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent2s = - unnamedSchemaWithArrayParent2s.toImmutable() - ) + fun ofJsonScalarArray(jsonScalarArray: List) = + DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) } /** @@ -1110,19 +1060,10 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitUnionMember0(unionMember0: UnionMember0): 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 visitUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ): T + fun visitJsonScalarArray(jsonScalarArray: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1146,25 +1087,14 @@ private constructor( 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(unionMember0 = it, _json = json) }, tryDeserialize( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent2s = it, - _json = json, - ) - }, + ?.let { DefaultValue(jsonScalarArray = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1190,52 +1120,268 @@ private constructor( 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.unnamedSchemaWithArrayParent2s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent2s) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.jsonScalarArray != null -> + generator.writeObject(value.jsonScalarArray) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } + /** Primitive JSON scalar. */ + @JsonDeserialize(using = UnionMember0.Deserializer::class) + @JsonSerialize(using = UnionMember0.Serializer::class) + class UnionMember0 + private constructor( + private val jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitJsonScalar(jsonScalar: String) {} + + override fun visitJsonScalar(jsonScalar: Double) {} + + override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 + + override fun visitJsonScalar(jsonScalar: Double) = 1 + + override fun visitJsonScalar(jsonScalar: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar + } + + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + + override fun toString(): String = + when { + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + _json != null -> "UnionMember0{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnionMember0") + } + + companion object { + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) + } + + /** + * An interface that defines how to map each variant of [UnionMember0] to a value of + * type [T]. + */ + interface Visitor { + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T + + /** + * Maps an unknown variant of [UnionMember0] to a value of type [T]. + * + * An instance of [UnionMember0] 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 UnionMember0: $json") + } + } + + internal class Deserializer : BaseDeserializer(UnionMember0::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { + + override fun serialize( + value: UnionMember0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnionMember0") + } + } + } + } + + /** Primitive JSON scalar. */ @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 jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, private val _json: JsonValue? = null, ) { - fun string(): Optional = Optional.ofNullable(string) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun number(): Optional = Optional.ofNullable(number) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun bool(): Optional = Optional.ofNullable(bool) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun isString(): Boolean = string != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isNumber(): Boolean = number != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isBool(): Boolean = bool != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun asString(): String = string.getOrThrow("string") + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - fun asNumber(): Double = number.getOrThrow("number") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - fun asBool(): Boolean = bool.getOrThrow("bool") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") 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) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) else -> visitor.unknown(_json) } @@ -1248,11 +1394,11 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} + override fun visitJsonScalar(jsonScalar: String) {} - override fun visitNumber(number: Double) {} + override fun visitJsonScalar(jsonScalar: Double) {} - override fun visitBool(bool: Boolean) {} + override fun visitJsonScalar(jsonScalar: Boolean) {} } ) validated = true @@ -1276,11 +1422,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitJsonScalar(jsonScalar: String) = 1 - override fun visitNumber(number: Double) = 1 + override fun visitJsonScalar(jsonScalar: Double) = 1 - override fun visitBool(bool: Boolean) = 1 + override fun visitJsonScalar(jsonScalar: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1292,32 +1438,41 @@ private constructor( } return other is UnnamedSchemaWithArrayParent2 && - string == other.string && - number == other.number && - bool == other.bool + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar } - override fun hashCode(): Int = Objects.hash(string, number, bool) + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent2{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent2{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent2{bool=$bool}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent2{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent2{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent2{jsonScalar=$jsonScalar}" _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") } companion object { + /** Primitive JSON scalar. */ @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent2(string = string) + fun ofJsonScalar(jsonScalar: String) = + UnnamedSchemaWithArrayParent2(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent2(number = number) + fun ofJsonScalar(jsonScalar: Double) = + UnnamedSchemaWithArrayParent2(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent2(bool = bool) + fun ofJsonScalar(jsonScalar: Boolean) = + UnnamedSchemaWithArrayParent2(jsonScalar = jsonScalar) } /** @@ -1326,11 +1481,14 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T - fun visitNumber(number: Double): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T - fun visitBool(bool: Boolean): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of type @@ -1363,13 +1521,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(string = it, _json = json) + UnnamedSchemaWithArrayParent2(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(number = it, _json = json) + UnnamedSchemaWithArrayParent2(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(bool = it, _json = json) + UnnamedSchemaWithArrayParent2(jsonScalar = it, _json = json) }, ) .filterNotNull() @@ -1400,9 +1558,9 @@ private constructor( 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.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) value._json != null -> generator.writeObject(value._json) else -> 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 d8f5d652..15768edb 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 @@ -734,25 +734,19 @@ private constructor( 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.ofUnionMember0(unionMember0)`. + */ + fun defaultValue(unionMember0: DefaultValue.UnionMember0) = + defaultValue(DefaultValue.ofUnionMember0(unionMember0)) /** * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s)`. + * `DefaultValue.ofJsonScalarArray(jsonScalarArray)`. */ - fun defaultValueOfUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) - ) + fun defaultValueOfJsonScalarArray( + jsonScalarArray: List + ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) /** * Sets this custom metadata field as required. Setting custom metadata fields on an @@ -973,56 +967,33 @@ private constructor( @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 unnamedSchemaWithArrayParent4s: List? = null, + private val unionMember0: UnionMember0? = null, + private val jsonScalarArray: 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 unnamedSchemaWithArrayParent4s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent4s) + /** Primitive JSON scalar. */ + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun isString(): Boolean = string != null + fun jsonScalarArray(): Optional> = + Optional.ofNullable(jsonScalarArray) - fun isNumber(): Boolean = number != null + fun isUnionMember0(): Boolean = unionMember0 != null - fun isBool(): Boolean = bool != null + fun isJsonScalarArray(): Boolean = jsonScalarArray != null - fun isUnnamedSchemaWithArrayParent4s(): Boolean = unnamedSchemaWithArrayParent4s != null + /** Primitive JSON scalar. */ + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - 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 asUnnamedSchemaWithArrayParent4s(): List = - unnamedSchemaWithArrayParent4s.getOrThrow("unnamedSchemaWithArrayParent4s") + fun asJsonScalarArray(): List = + jsonScalarArray.getOrThrow("jsonScalarArray") 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) - unnamedSchemaWithArrayParent4s != null -> - visitor.visitUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) else -> visitor.unknown(_json) } @@ -1035,16 +1006,14 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } - override fun visitUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List + override fun visitJsonScalarArray( + jsonScalarArray: List ) { - unnamedSchemaWithArrayParent4s.forEach { it.validate() } + jsonScalarArray.forEach { it.validate() } } } ) @@ -1069,15 +1038,12 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun visitUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ) = unnamedSchemaWithArrayParent4s.sumOf { it.validity().toInt() } + override fun visitJsonScalarArray( + jsonScalarArray: List + ) = jsonScalarArray.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1089,46 +1055,30 @@ private constructor( } return other is DefaultValue && - string == other.string && - number == other.number && - bool == other.bool && - unnamedSchemaWithArrayParent4s == other.unnamedSchemaWithArrayParent4s + unionMember0 == other.unionMember0 && + jsonScalarArray == other.jsonScalarArray } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent4s) + override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) override fun toString(): String = when { - string != null -> "DefaultValue{string=$string}" - number != null -> "DefaultValue{number=$number}" - bool != null -> "DefaultValue{bool=$bool}" - unnamedSchemaWithArrayParent4s != null -> - "DefaultValue{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" + unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" + jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" _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) + /** Primitive JSON scalar. */ + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + DefaultValue(unionMember0 = unionMember0) - /** - * Default value should be of type array when custom metadata field type is set to - * `MultiSelect`. - */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent4s = - unnamedSchemaWithArrayParent4s.toImmutable() - ) + fun ofJsonScalarArray(jsonScalarArray: List) = + DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) } /** @@ -1137,19 +1087,10 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitUnionMember0(unionMember0: UnionMember0): 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 visitUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ): T + fun visitJsonScalarArray(jsonScalarArray: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1173,25 +1114,14 @@ private constructor( 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(unionMember0 = it, _json = json) }, tryDeserialize( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent4s = it, - _json = json, - ) - }, + ?.let { DefaultValue(jsonScalarArray = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1217,52 +1147,268 @@ private constructor( 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.unnamedSchemaWithArrayParent4s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent4s) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.jsonScalarArray != null -> + generator.writeObject(value.jsonScalarArray) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } + /** Primitive JSON scalar. */ + @JsonDeserialize(using = UnionMember0.Deserializer::class) + @JsonSerialize(using = UnionMember0.Serializer::class) + class UnionMember0 + private constructor( + private val jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitJsonScalar(jsonScalar: String) {} + + override fun visitJsonScalar(jsonScalar: Double) {} + + override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 + + override fun visitJsonScalar(jsonScalar: Double) = 1 + + override fun visitJsonScalar(jsonScalar: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar + } + + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + + override fun toString(): String = + when { + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + _json != null -> "UnionMember0{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnionMember0") + } + + companion object { + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) + } + + /** + * An interface that defines how to map each variant of [UnionMember0] to a value of + * type [T]. + */ + interface Visitor { + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T + + /** + * Maps an unknown variant of [UnionMember0] to a value of type [T]. + * + * An instance of [UnionMember0] 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 UnionMember0: $json") + } + } + + internal class Deserializer : BaseDeserializer(UnionMember0::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { + + override fun serialize( + value: UnionMember0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnionMember0") + } + } + } + } + + /** Primitive JSON scalar. */ @JsonDeserialize(using = UnnamedSchemaWithArrayParent4.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) class UnnamedSchemaWithArrayParent4 private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, + private val jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, private val _json: JsonValue? = null, ) { - fun string(): Optional = Optional.ofNullable(string) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun number(): Optional = Optional.ofNullable(number) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun bool(): Optional = Optional.ofNullable(bool) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun isString(): Boolean = string != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isNumber(): Boolean = number != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isBool(): Boolean = bool != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun asString(): String = string.getOrThrow("string") + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - fun asNumber(): Double = number.getOrThrow("number") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - fun asBool(): Boolean = bool.getOrThrow("bool") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") 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) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) else -> visitor.unknown(_json) } @@ -1275,11 +1421,11 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} + override fun visitJsonScalar(jsonScalar: String) {} - override fun visitNumber(number: Double) {} + override fun visitJsonScalar(jsonScalar: Double) {} - override fun visitBool(bool: Boolean) {} + override fun visitJsonScalar(jsonScalar: Boolean) {} } ) validated = true @@ -1303,11 +1449,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitJsonScalar(jsonScalar: String) = 1 - override fun visitNumber(number: Double) = 1 + override fun visitJsonScalar(jsonScalar: Double) = 1 - override fun visitBool(bool: Boolean) = 1 + override fun visitJsonScalar(jsonScalar: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1319,32 +1465,41 @@ private constructor( } return other is UnnamedSchemaWithArrayParent4 && - string == other.string && - number == other.number && - bool == other.bool + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar } - override fun hashCode(): Int = Objects.hash(string, number, bool) + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent4{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent4{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent4{bool=$bool}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent4{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent4{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent4{jsonScalar=$jsonScalar}" _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") } companion object { + /** Primitive JSON scalar. */ @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent4(string = string) + fun ofJsonScalar(jsonScalar: String) = + UnnamedSchemaWithArrayParent4(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent4(number = number) + fun ofJsonScalar(jsonScalar: Double) = + UnnamedSchemaWithArrayParent4(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent4(bool = bool) + fun ofJsonScalar(jsonScalar: Boolean) = + UnnamedSchemaWithArrayParent4(jsonScalar = jsonScalar) } /** @@ -1353,11 +1508,14 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T - fun visitNumber(number: Double): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T - fun visitBool(bool: Boolean): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type @@ -1390,13 +1548,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(string = it, _json = json) + UnnamedSchemaWithArrayParent4(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(number = it, _json = json) + UnnamedSchemaWithArrayParent4(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(bool = it, _json = json) + UnnamedSchemaWithArrayParent4(jsonScalar = it, _json = json) }, ) .filterNotNull() @@ -1427,9 +1585,9 @@ private constructor( 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.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt index 29d241ff..b7ad259b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt @@ -553,25 +553,19 @@ private constructor( 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.ofUnionMember0(unionMember0)`. + */ + fun defaultValue(unionMember0: DefaultValue.UnionMember0) = + defaultValue(DefaultValue.ofUnionMember0(unionMember0)) /** * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s)`. + * `DefaultValue.ofJsonScalarArray(jsonScalarArray)`. */ - fun defaultValueOfUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) - ) + fun defaultValueOfJsonScalarArray( + jsonScalarArray: List + ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) /** Specifies if the this custom metadata field is required or not. */ fun isValueRequired(isValueRequired: Boolean) = @@ -946,56 +940,33 @@ private constructor( @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 unnamedSchemaWithArrayParent1s: List? = null, + private val unionMember0: UnionMember0? = null, + private val jsonScalarArray: 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 unnamedSchemaWithArrayParent1s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent1s) + /** Primitive JSON scalar. */ + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun isString(): Boolean = string != null + fun jsonScalarArray(): Optional> = + Optional.ofNullable(jsonScalarArray) - fun isNumber(): Boolean = number != null + fun isUnionMember0(): Boolean = unionMember0 != null - fun isBool(): Boolean = bool != null + fun isJsonScalarArray(): Boolean = jsonScalarArray != null - fun isUnnamedSchemaWithArrayParent1s(): Boolean = unnamedSchemaWithArrayParent1s != null + /** Primitive JSON scalar. */ + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - 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 asUnnamedSchemaWithArrayParent1s(): List = - unnamedSchemaWithArrayParent1s.getOrThrow("unnamedSchemaWithArrayParent1s") + fun asJsonScalarArray(): List = + jsonScalarArray.getOrThrow("jsonScalarArray") 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) - unnamedSchemaWithArrayParent1s != null -> - visitor.visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) else -> visitor.unknown(_json) } @@ -1008,16 +979,14 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } - override fun visitUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List + override fun visitJsonScalarArray( + jsonScalarArray: List ) { - unnamedSchemaWithArrayParent1s.forEach { it.validate() } + jsonScalarArray.forEach { it.validate() } } } ) @@ -1042,15 +1011,12 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun visitUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ) = unnamedSchemaWithArrayParent1s.sumOf { it.validity().toInt() } + override fun visitJsonScalarArray( + jsonScalarArray: List + ) = jsonScalarArray.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1062,46 +1028,30 @@ private constructor( } return other is DefaultValue && - string == other.string && - number == other.number && - bool == other.bool && - unnamedSchemaWithArrayParent1s == other.unnamedSchemaWithArrayParent1s + unionMember0 == other.unionMember0 && + jsonScalarArray == other.jsonScalarArray } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent1s) + override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) override fun toString(): String = when { - string != null -> "DefaultValue{string=$string}" - number != null -> "DefaultValue{number=$number}" - bool != null -> "DefaultValue{bool=$bool}" - unnamedSchemaWithArrayParent1s != null -> - "DefaultValue{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" + unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" + jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" _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) + /** Primitive JSON scalar. */ + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + DefaultValue(unionMember0 = unionMember0) - /** - * Default value should be of type array when custom metadata field type is set to - * `MultiSelect`. - */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent1s = - unnamedSchemaWithArrayParent1s.toImmutable() - ) + fun ofJsonScalarArray(jsonScalarArray: List) = + DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) } /** @@ -1110,19 +1060,10 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitUnionMember0(unionMember0: UnionMember0): 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 visitUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ): T + fun visitJsonScalarArray(jsonScalarArray: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1146,25 +1087,14 @@ private constructor( 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(unionMember0 = it, _json = json) }, tryDeserialize( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent1s = it, - _json = json, - ) - }, + ?.let { DefaultValue(jsonScalarArray = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1190,52 +1120,268 @@ private constructor( 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.unnamedSchemaWithArrayParent1s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent1s) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.jsonScalarArray != null -> + generator.writeObject(value.jsonScalarArray) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } + /** Primitive JSON scalar. */ + @JsonDeserialize(using = UnionMember0.Deserializer::class) + @JsonSerialize(using = UnionMember0.Serializer::class) + class UnionMember0 + private constructor( + private val jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + fun isJsonScalar(): Boolean = jsonScalar != null + + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitJsonScalar(jsonScalar: String) {} + + override fun visitJsonScalar(jsonScalar: Double) {} + + override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 + + override fun visitJsonScalar(jsonScalar: Double) = 1 + + override fun visitJsonScalar(jsonScalar: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar + } + + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + + override fun toString(): String = + when { + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" + _json != null -> "UnionMember0{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnionMember0") + } + + companion object { + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) + + /** Primitive JSON scalar. */ + @JvmStatic + fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) + } + + /** + * An interface that defines how to map each variant of [UnionMember0] to a value of + * type [T]. + */ + interface Visitor { + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T + + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T + + /** + * Maps an unknown variant of [UnionMember0] to a value of type [T]. + * + * An instance of [UnionMember0] 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 UnionMember0: $json") + } + } + + internal class Deserializer : BaseDeserializer(UnionMember0::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { + + override fun serialize( + value: UnionMember0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnionMember0") + } + } + } + } + + /** Primitive JSON scalar. */ @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 jsonScalar: String? = null, + private val jsonScalar: Double? = null, + private val jsonScalar: Boolean? = null, private val _json: JsonValue? = null, ) { - fun string(): Optional = Optional.ofNullable(string) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun number(): Optional = Optional.ofNullable(number) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun bool(): Optional = Optional.ofNullable(bool) + /** Primitive JSON scalar. */ + fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - fun isString(): Boolean = string != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isNumber(): Boolean = number != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun isBool(): Boolean = bool != null + fun isJsonScalar(): Boolean = jsonScalar != null - fun asString(): String = string.getOrThrow("string") + /** Primitive JSON scalar. */ + fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - fun asNumber(): Double = number.getOrThrow("number") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - fun asBool(): Boolean = bool.getOrThrow("bool") + /** Primitive JSON scalar. */ + fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") 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) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) else -> visitor.unknown(_json) } @@ -1248,11 +1394,11 @@ private constructor( accept( object : Visitor { - override fun visitString(string: String) {} + override fun visitJsonScalar(jsonScalar: String) {} - override fun visitNumber(number: Double) {} + override fun visitJsonScalar(jsonScalar: Double) {} - override fun visitBool(bool: Boolean) {} + override fun visitJsonScalar(jsonScalar: Boolean) {} } ) validated = true @@ -1276,11 +1422,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitString(string: String) = 1 + override fun visitJsonScalar(jsonScalar: String) = 1 - override fun visitNumber(number: Double) = 1 + override fun visitJsonScalar(jsonScalar: Double) = 1 - override fun visitBool(bool: Boolean) = 1 + override fun visitJsonScalar(jsonScalar: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1292,32 +1438,41 @@ private constructor( } return other is UnnamedSchemaWithArrayParent1 && - string == other.string && - number == other.number && - bool == other.bool + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar && + jsonScalar == other.jsonScalar } - override fun hashCode(): Int = Objects.hash(string, number, bool) + override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent1{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent1{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent1{bool=$bool}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent1{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent1{jsonScalar=$jsonScalar}" + jsonScalar != null -> + "UnnamedSchemaWithArrayParent1{jsonScalar=$jsonScalar}" _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") } companion object { + /** Primitive JSON scalar. */ @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent1(string = string) + fun ofJsonScalar(jsonScalar: String) = + UnnamedSchemaWithArrayParent1(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent1(number = number) + fun ofJsonScalar(jsonScalar: Double) = + UnnamedSchemaWithArrayParent1(jsonScalar = jsonScalar) + /** Primitive JSON scalar. */ @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent1(bool = bool) + fun ofJsonScalar(jsonScalar: Boolean) = + UnnamedSchemaWithArrayParent1(jsonScalar = jsonScalar) } /** @@ -1326,11 +1481,14 @@ private constructor( */ interface Visitor { - fun visitString(string: String): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: String): T - fun visitNumber(number: Double): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Double): T - fun visitBool(bool: Boolean): T + /** Primitive JSON scalar. */ + fun visitJsonScalar(jsonScalar: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type @@ -1363,13 +1521,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(string = it, _json = json) + UnnamedSchemaWithArrayParent1(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(number = it, _json = json) + UnnamedSchemaWithArrayParent1(jsonScalar = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(bool = it, _json = json) + UnnamedSchemaWithArrayParent1(jsonScalar = it, _json = json) }, ) .filterNotNull() @@ -1400,9 +1558,9 @@ private constructor( 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.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + value.jsonScalar != null -> generator.writeObject(value.jsonScalar) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") 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..428598e9 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,10 @@ internal class CustomMetadataFieldCreateParamsTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -45,7 +48,10 @@ internal class CustomMetadataFieldCreateParamsTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -79,7 +85,10 @@ internal class CustomMetadataFieldCreateParamsTest { .isEqualTo( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt index 0fa0ea81..008a01f4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt @@ -19,7 +19,10 @@ internal class CustomMetadataFieldCreateResponseTest { .schema( CustomMetadataFieldCreateResponse.Schema.builder() .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldCreateResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -56,7 +59,10 @@ internal class CustomMetadataFieldCreateResponseTest { .isEqualTo( CustomMetadataFieldCreateResponse.Schema.builder() .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldCreateResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -89,7 +95,10 @@ internal class CustomMetadataFieldCreateResponseTest { .schema( CustomMetadataFieldCreateResponse.Schema.builder() .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldCreateResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt index 6dd28045..ab06f21b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt @@ -19,7 +19,10 @@ internal class CustomMetadataFieldListResponseTest { .schema( CustomMetadataFieldListResponse.Schema.builder() .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldListResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -52,7 +55,10 @@ internal class CustomMetadataFieldListResponseTest { .isEqualTo( CustomMetadataFieldListResponse.Schema.builder() .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldListResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -83,7 +89,10 @@ internal class CustomMetadataFieldListResponseTest { .schema( CustomMetadataFieldListResponse.Schema.builder() .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldListResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("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..eaf4ef8e 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,10 @@ internal class CustomMetadataFieldUpdateParamsTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValue( + CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -52,7 +55,10 @@ internal class CustomMetadataFieldUpdateParamsTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValue( + CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -84,7 +90,10 @@ internal class CustomMetadataFieldUpdateParamsTest { assertThat(body.schema()) .contains( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValue( + CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt index 2ce6e88a..1a9aa8cf 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt @@ -19,7 +19,10 @@ internal class CustomMetadataFieldUpdateResponseTest { .schema( CustomMetadataFieldUpdateResponse.Schema.builder() .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldUpdateResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -56,7 +59,10 @@ internal class CustomMetadataFieldUpdateResponseTest { .isEqualTo( CustomMetadataFieldUpdateResponse.Schema.builder() .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldUpdateResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -89,7 +95,10 @@ internal class CustomMetadataFieldUpdateResponseTest { .schema( CustomMetadataFieldUpdateResponse.Schema.builder() .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldUpdateResponse.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue("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 bb8af989..a8296f21 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 @@ -33,7 +33,10 @@ internal class CustomMetadataFieldServiceAsyncTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -86,7 +89,10 @@ internal class CustomMetadataFieldServiceAsyncTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValue( + CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("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 be0a158b..168f3def 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 @@ -33,7 +33,10 @@ internal class CustomMetadataFieldServiceTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValue( + CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -85,7 +88,10 @@ internal class CustomMetadataFieldServiceTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValue( + CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 + .ofJsonScalar("Hello") + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) From 4229ed0a310b172d3457d0507cb3609c9f16f2f1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:25:43 +0000 Subject: [PATCH 026/125] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index fe627405..134be349 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-cb74df1af0b7cdd4f66573d2d002f003b74702172ddd2c8495c465a7706c4d66.yml -openapi_spec_hash: 9a1fb60cda92b3e693e8c0f0fde0508a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-6db4fc859c70677af91f711d10e420694e96273880b0dc7931be2c7cf7a68586.yml +openapi_spec_hash: d4060e780214d95ccd90306aa8f2e28b config_hash: c9b1142a72b93ad4d66f0433dca1392e From eef3461ad8bbb7f3337fddad0ef78254a3354b64 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:32:41 +0000 Subject: [PATCH 027/125] feat(api): manual updates --- .stats.yml | 4 +- .../CustomMetadataFieldCreateParams.kt | 490 ++++++------------ .../CustomMetadataFieldCreateResponse.kt | 490 ++++++------------ .../CustomMetadataFieldListResponse.kt | 490 ++++++------------ .../CustomMetadataFieldUpdateParams.kt | 490 ++++++------------ .../CustomMetadataFieldUpdateResponse.kt | 490 ++++++------------ .../CustomMetadataFieldCreateParamsTest.kt | 15 +- .../CustomMetadataFieldCreateResponseTest.kt | 15 +- .../CustomMetadataFieldListResponseTest.kt | 15 +- .../CustomMetadataFieldUpdateParamsTest.kt | 15 +- .../CustomMetadataFieldUpdateResponseTest.kt | 15 +- .../CustomMetadataFieldServiceAsyncTest.kt | 10 +- .../CustomMetadataFieldServiceTest.kt | 10 +- 13 files changed, 851 insertions(+), 1698 deletions(-) diff --git a/.stats.yml b/.stats.yml index 134be349..3ae65fac 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-6db4fc859c70677af91f711d10e420694e96273880b0dc7931be2c7cf7a68586.yml -openapi_spec_hash: d4060e780214d95ccd90306aa8f2e28b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-cb2369e849b98127ee6a2cbd01d928e4546d29c1a0a8e64e9b46f90189c1a992.yml +openapi_spec_hash: f8e732e88daf7c4bfbeb2bd2cdba2cec config_hash: c9b1142a72b93ad4d66f0433dca1392e 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 e9bb9440..cdc7d3fb 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 @@ -844,19 +844,25 @@ private constructor( this.defaultValue = defaultValue } - /** - * Alias for calling [defaultValue] with `DefaultValue.ofUnionMember0(unionMember0)`. - */ - fun defaultValue(unionMember0: DefaultValue.UnionMember0) = - defaultValue(DefaultValue.ofUnionMember0(unionMember0)) + /** 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.ofJsonScalarArray(jsonScalarArray)`. + * `DefaultValue.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s)`. */ - fun defaultValueOfJsonScalarArray( - jsonScalarArray: List - ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) + fun defaultValueOfUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) + ) /** * Sets this custom metadata field as required. Setting custom metadata fields on an @@ -1245,33 +1251,56 @@ private constructor( @JsonSerialize(using = DefaultValue.Serializer::class) class DefaultValue private constructor( - private val unionMember0: UnionMember0? = null, - private val jsonScalarArray: List? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val unnamedSchemaWithArrayParent3s: List? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + 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 unnamedSchemaWithArrayParent3s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent3s) - fun jsonScalarArray(): Optional> = - Optional.ofNullable(jsonScalarArray) + fun isString(): Boolean = string != null - fun isUnionMember0(): Boolean = unionMember0 != null + fun isNumber(): Boolean = number != null - fun isJsonScalarArray(): Boolean = jsonScalarArray != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun isUnnamedSchemaWithArrayParent3s(): Boolean = unnamedSchemaWithArrayParent3s != null - fun asJsonScalarArray(): List = - jsonScalarArray.getOrThrow("jsonScalarArray") + 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 asUnnamedSchemaWithArrayParent3s(): List = + unnamedSchemaWithArrayParent3s.getOrThrow("unnamedSchemaWithArrayParent3s") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + unnamedSchemaWithArrayParent3s != null -> + visitor.visitUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) else -> visitor.unknown(_json) } @@ -1284,14 +1313,16 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } + override fun visitString(string: String) {} - override fun visitJsonScalarArray( - jsonScalarArray: List + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List ) { - jsonScalarArray.forEach { it.validate() } + unnamedSchemaWithArrayParent3s.forEach { it.validate() } } } ) @@ -1316,12 +1347,15 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitString(string: String) = 1 - override fun visitJsonScalarArray( - jsonScalarArray: List - ) = jsonScalarArray.sumOf { it.validity().toInt() } + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = unnamedSchemaWithArrayParent3s.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1333,30 +1367,46 @@ private constructor( } return other is DefaultValue && - unionMember0 == other.unionMember0 && - jsonScalarArray == other.jsonScalarArray + string == other.string && + number == other.number && + bool == other.bool && + unnamedSchemaWithArrayParent3s == other.unnamedSchemaWithArrayParent3s } - override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent3s) override fun toString(): String = when { - unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" - jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent3s != null -> + "DefaultValue{unnamedSchemaWithArrayParent3s=$unnamedSchemaWithArrayParent3s}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } companion object { - /** Primitive JSON scalar. */ - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - DefaultValue(unionMember0 = unionMember0) + @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 ofJsonScalarArray(jsonScalarArray: List) = - DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) + fun ofUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent3s = + unnamedSchemaWithArrayParent3s.toImmutable() + ) } /** @@ -1365,10 +1415,19 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitString(string: String): T - fun visitJsonScalarArray(jsonScalarArray: List): 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 visitUnnamedSchemaWithArrayParent3s( + unnamedSchemaWithArrayParent3s: List + ): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1392,14 +1451,25 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - DefaultValue(unionMember0 = it, _json = json) + 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(jsonScalarArray = it, _json = json) }, + ?.let { + DefaultValue( + unnamedSchemaWithArrayParent3s = it, + _json = json, + ) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1425,268 +1495,52 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.jsonScalarArray != null -> - generator.writeObject(value.jsonScalarArray) + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.unnamedSchemaWithArrayParent3s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent3s) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } - /** Primitive JSON scalar. */ - @JsonDeserialize(using = UnionMember0.Deserializer::class) - @JsonSerialize(using = UnionMember0.Serializer::class) - class UnionMember0 - private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} - - override fun visitJsonScalar(jsonScalar: Double) {} - - override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 - - override fun visitJsonScalar(jsonScalar: Double) = 1 - - override fun visitJsonScalar(jsonScalar: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar - } - - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) - - override fun toString(): String = - when { - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - _json != null -> "UnionMember0{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnionMember0") - } - - companion object { - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) - } - - /** - * An interface that defines how to map each variant of [UnionMember0] to a value of - * type [T]. - */ - interface Visitor { - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T - - /** - * Maps an unknown variant of [UnionMember0] to a value of type [T]. - * - * An instance of [UnionMember0] 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 UnionMember0: $json") - } - } - - internal class Deserializer : BaseDeserializer(UnionMember0::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { - - override fun serialize( - value: UnionMember0, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnionMember0") - } - } - } - } - - /** Primitive JSON scalar. */ @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) class UnnamedSchemaWithArrayParent3 private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun string(): Optional = Optional.ofNullable(string) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun number(): Optional = Optional.ofNullable(number) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun bool(): Optional = Optional.ofNullable(bool) - fun isJsonScalar(): Boolean = jsonScalar != null + fun isString(): Boolean = string != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isNumber(): Boolean = number != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + fun asString(): String = string.getOrThrow("string") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + fun asNumber(): Double = number.getOrThrow("number") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + fun asBool(): Boolean = bool.getOrThrow("bool") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) else -> visitor.unknown(_json) } @@ -1699,11 +1553,11 @@ private constructor( accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} + override fun visitString(string: String) {} - override fun visitJsonScalar(jsonScalar: Double) {} + override fun visitNumber(number: Double) {} - override fun visitJsonScalar(jsonScalar: Boolean) {} + override fun visitBool(bool: Boolean) {} } ) validated = true @@ -1727,11 +1581,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) = 1 + override fun visitString(string: String) = 1 - override fun visitJsonScalar(jsonScalar: Double) = 1 + override fun visitNumber(number: Double) = 1 - override fun visitJsonScalar(jsonScalar: Boolean) = 1 + override fun visitBool(bool: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1743,41 +1597,32 @@ private constructor( } return other is UnnamedSchemaWithArrayParent3 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar + string == other.string && + number == other.number && + bool == other.bool } - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + override fun hashCode(): Int = Objects.hash(string, number, bool) override fun toString(): String = when { - jsonScalar != null -> - "UnnamedSchemaWithArrayParent3{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent3{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent3{jsonScalar=$jsonScalar}" + 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 { - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: String) = - UnnamedSchemaWithArrayParent3(jsonScalar = jsonScalar) + fun ofString(string: String) = UnnamedSchemaWithArrayParent3(string = string) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = - UnnamedSchemaWithArrayParent3(jsonScalar = jsonScalar) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent3(number = number) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = - UnnamedSchemaWithArrayParent3(jsonScalar = jsonScalar) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent3(bool = bool) } /** @@ -1786,14 +1631,11 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T + fun visitString(string: String): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T + fun visitNumber(number: Double): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T + fun visitBool(bool: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type @@ -1826,13 +1668,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent3(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent3(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent3(bool = it, _json = json) }, ) .filterNotNull() @@ -1863,9 +1705,9 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + 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 UnnamedSchemaWithArrayParent3") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt index 232b8476..0b38db4f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt @@ -553,19 +553,25 @@ private constructor( this.defaultValue = defaultValue } - /** - * Alias for calling [defaultValue] with `DefaultValue.ofUnionMember0(unionMember0)`. - */ - fun defaultValue(unionMember0: DefaultValue.UnionMember0) = - defaultValue(DefaultValue.ofUnionMember0(unionMember0)) + /** 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.ofJsonScalarArray(jsonScalarArray)`. + * `DefaultValue.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s)`. */ - fun defaultValueOfJsonScalarArray( - jsonScalarArray: List - ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) + fun defaultValueOfUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) + ) /** Specifies if the this custom metadata field is required or not. */ fun isValueRequired(isValueRequired: Boolean) = @@ -940,33 +946,56 @@ private constructor( @JsonSerialize(using = DefaultValue.Serializer::class) class DefaultValue private constructor( - private val unionMember0: UnionMember0? = null, - private val jsonScalarArray: List? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val unnamedSchemaWithArrayParent0s: List? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + 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 unnamedSchemaWithArrayParent0s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent0s) - fun jsonScalarArray(): Optional> = - Optional.ofNullable(jsonScalarArray) + fun isString(): Boolean = string != null - fun isUnionMember0(): Boolean = unionMember0 != null + fun isNumber(): Boolean = number != null - fun isJsonScalarArray(): Boolean = jsonScalarArray != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun isUnnamedSchemaWithArrayParent0s(): Boolean = unnamedSchemaWithArrayParent0s != null - fun asJsonScalarArray(): List = - jsonScalarArray.getOrThrow("jsonScalarArray") + 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 asUnnamedSchemaWithArrayParent0s(): List = + unnamedSchemaWithArrayParent0s.getOrThrow("unnamedSchemaWithArrayParent0s") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + unnamedSchemaWithArrayParent0s != null -> + visitor.visitUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) else -> visitor.unknown(_json) } @@ -979,14 +1008,16 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } + override fun visitString(string: String) {} - override fun visitJsonScalarArray( - jsonScalarArray: List + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List ) { - jsonScalarArray.forEach { it.validate() } + unnamedSchemaWithArrayParent0s.forEach { it.validate() } } } ) @@ -1011,12 +1042,15 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitString(string: String) = 1 - override fun visitJsonScalarArray( - jsonScalarArray: List - ) = jsonScalarArray.sumOf { it.validity().toInt() } + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List + ) = unnamedSchemaWithArrayParent0s.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1028,30 +1062,46 @@ private constructor( } return other is DefaultValue && - unionMember0 == other.unionMember0 && - jsonScalarArray == other.jsonScalarArray + string == other.string && + number == other.number && + bool == other.bool && + unnamedSchemaWithArrayParent0s == other.unnamedSchemaWithArrayParent0s } - override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent0s) override fun toString(): String = when { - unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" - jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent0s != null -> + "DefaultValue{unnamedSchemaWithArrayParent0s=$unnamedSchemaWithArrayParent0s}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } companion object { - /** Primitive JSON scalar. */ - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - DefaultValue(unionMember0 = unionMember0) + @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 ofJsonScalarArray(jsonScalarArray: List) = - DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) + fun ofUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent0s = + unnamedSchemaWithArrayParent0s.toImmutable() + ) } /** @@ -1060,10 +1110,19 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitString(string: String): T - fun visitJsonScalarArray(jsonScalarArray: List): 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 visitUnnamedSchemaWithArrayParent0s( + unnamedSchemaWithArrayParent0s: List + ): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1087,14 +1146,25 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - DefaultValue(unionMember0 = it, _json = json) + 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(jsonScalarArray = it, _json = json) }, + ?.let { + DefaultValue( + unnamedSchemaWithArrayParent0s = it, + _json = json, + ) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1120,268 +1190,52 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.jsonScalarArray != null -> - generator.writeObject(value.jsonScalarArray) + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.unnamedSchemaWithArrayParent0s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent0s) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } - /** Primitive JSON scalar. */ - @JsonDeserialize(using = UnionMember0.Deserializer::class) - @JsonSerialize(using = UnionMember0.Serializer::class) - class UnionMember0 - private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} - - override fun visitJsonScalar(jsonScalar: Double) {} - - override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 - - override fun visitJsonScalar(jsonScalar: Double) = 1 - - override fun visitJsonScalar(jsonScalar: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar - } - - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) - - override fun toString(): String = - when { - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - _json != null -> "UnionMember0{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnionMember0") - } - - companion object { - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) - } - - /** - * An interface that defines how to map each variant of [UnionMember0] to a value of - * type [T]. - */ - interface Visitor { - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T - - /** - * Maps an unknown variant of [UnionMember0] to a value of type [T]. - * - * An instance of [UnionMember0] 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 UnionMember0: $json") - } - } - - internal class Deserializer : BaseDeserializer(UnionMember0::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { - - override fun serialize( - value: UnionMember0, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnionMember0") - } - } - } - } - - /** Primitive JSON scalar. */ @JsonDeserialize(using = UnnamedSchemaWithArrayParent0.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) class UnnamedSchemaWithArrayParent0 private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun string(): Optional = Optional.ofNullable(string) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun number(): Optional = Optional.ofNullable(number) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun bool(): Optional = Optional.ofNullable(bool) - fun isJsonScalar(): Boolean = jsonScalar != null + fun isString(): Boolean = string != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isNumber(): Boolean = number != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + fun asString(): String = string.getOrThrow("string") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + fun asNumber(): Double = number.getOrThrow("number") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + fun asBool(): Boolean = bool.getOrThrow("bool") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) else -> visitor.unknown(_json) } @@ -1394,11 +1248,11 @@ private constructor( accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} + override fun visitString(string: String) {} - override fun visitJsonScalar(jsonScalar: Double) {} + override fun visitNumber(number: Double) {} - override fun visitJsonScalar(jsonScalar: Boolean) {} + override fun visitBool(bool: Boolean) {} } ) validated = true @@ -1422,11 +1276,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) = 1 + override fun visitString(string: String) = 1 - override fun visitJsonScalar(jsonScalar: Double) = 1 + override fun visitNumber(number: Double) = 1 - override fun visitJsonScalar(jsonScalar: Boolean) = 1 + override fun visitBool(bool: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1438,41 +1292,32 @@ private constructor( } return other is UnnamedSchemaWithArrayParent0 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar + string == other.string && + number == other.number && + bool == other.bool } - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + override fun hashCode(): Int = Objects.hash(string, number, bool) override fun toString(): String = when { - jsonScalar != null -> - "UnnamedSchemaWithArrayParent0{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent0{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent0{jsonScalar=$jsonScalar}" + 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 { - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: String) = - UnnamedSchemaWithArrayParent0(jsonScalar = jsonScalar) + fun ofString(string: String) = UnnamedSchemaWithArrayParent0(string = string) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = - UnnamedSchemaWithArrayParent0(jsonScalar = jsonScalar) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent0(number = number) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = - UnnamedSchemaWithArrayParent0(jsonScalar = jsonScalar) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent0(bool = bool) } /** @@ -1481,14 +1326,11 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T + fun visitString(string: String): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T + fun visitNumber(number: Double): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T + fun visitBool(bool: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to a value of type @@ -1521,13 +1363,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent0(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent0(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent0(bool = it, _json = json) }, ) .filterNotNull() @@ -1558,9 +1400,9 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + 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") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt index ca3b9986..8e4fd30f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt @@ -553,19 +553,25 @@ private constructor( this.defaultValue = defaultValue } - /** - * Alias for calling [defaultValue] with `DefaultValue.ofUnionMember0(unionMember0)`. - */ - fun defaultValue(unionMember0: DefaultValue.UnionMember0) = - defaultValue(DefaultValue.ofUnionMember0(unionMember0)) + /** 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.ofJsonScalarArray(jsonScalarArray)`. + * `DefaultValue.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s)`. */ - fun defaultValueOfJsonScalarArray( - jsonScalarArray: List - ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) + fun defaultValueOfUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) + ) /** Specifies if the this custom metadata field is required or not. */ fun isValueRequired(isValueRequired: Boolean) = @@ -940,33 +946,56 @@ private constructor( @JsonSerialize(using = DefaultValue.Serializer::class) class DefaultValue private constructor( - private val unionMember0: UnionMember0? = null, - private val jsonScalarArray: List? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val unnamedSchemaWithArrayParent2s: List? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + 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 unnamedSchemaWithArrayParent2s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent2s) - fun jsonScalarArray(): Optional> = - Optional.ofNullable(jsonScalarArray) + fun isString(): Boolean = string != null - fun isUnionMember0(): Boolean = unionMember0 != null + fun isNumber(): Boolean = number != null - fun isJsonScalarArray(): Boolean = jsonScalarArray != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun isUnnamedSchemaWithArrayParent2s(): Boolean = unnamedSchemaWithArrayParent2s != null - fun asJsonScalarArray(): List = - jsonScalarArray.getOrThrow("jsonScalarArray") + 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 asUnnamedSchemaWithArrayParent2s(): List = + unnamedSchemaWithArrayParent2s.getOrThrow("unnamedSchemaWithArrayParent2s") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + unnamedSchemaWithArrayParent2s != null -> + visitor.visitUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) else -> visitor.unknown(_json) } @@ -979,14 +1008,16 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } + override fun visitString(string: String) {} - override fun visitJsonScalarArray( - jsonScalarArray: List + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List ) { - jsonScalarArray.forEach { it.validate() } + unnamedSchemaWithArrayParent2s.forEach { it.validate() } } } ) @@ -1011,12 +1042,15 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitString(string: String) = 1 - override fun visitJsonScalarArray( - jsonScalarArray: List - ) = jsonScalarArray.sumOf { it.validity().toInt() } + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = unnamedSchemaWithArrayParent2s.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1028,30 +1062,46 @@ private constructor( } return other is DefaultValue && - unionMember0 == other.unionMember0 && - jsonScalarArray == other.jsonScalarArray + string == other.string && + number == other.number && + bool == other.bool && + unnamedSchemaWithArrayParent2s == other.unnamedSchemaWithArrayParent2s } - override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent2s) override fun toString(): String = when { - unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" - jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent2s != null -> + "DefaultValue{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } companion object { - /** Primitive JSON scalar. */ - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - DefaultValue(unionMember0 = unionMember0) + @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 ofJsonScalarArray(jsonScalarArray: List) = - DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) + fun ofUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent2s = + unnamedSchemaWithArrayParent2s.toImmutable() + ) } /** @@ -1060,10 +1110,19 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitString(string: String): T - fun visitJsonScalarArray(jsonScalarArray: List): 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 visitUnnamedSchemaWithArrayParent2s( + unnamedSchemaWithArrayParent2s: List + ): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1087,14 +1146,25 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - DefaultValue(unionMember0 = it, _json = json) + 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(jsonScalarArray = it, _json = json) }, + ?.let { + DefaultValue( + unnamedSchemaWithArrayParent2s = it, + _json = json, + ) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1120,268 +1190,52 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.jsonScalarArray != null -> - generator.writeObject(value.jsonScalarArray) + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.unnamedSchemaWithArrayParent2s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent2s) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } - /** Primitive JSON scalar. */ - @JsonDeserialize(using = UnionMember0.Deserializer::class) - @JsonSerialize(using = UnionMember0.Serializer::class) - class UnionMember0 - private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} - - override fun visitJsonScalar(jsonScalar: Double) {} - - override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 - - override fun visitJsonScalar(jsonScalar: Double) = 1 - - override fun visitJsonScalar(jsonScalar: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar - } - - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) - - override fun toString(): String = - when { - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - _json != null -> "UnionMember0{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnionMember0") - } - - companion object { - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) - } - - /** - * An interface that defines how to map each variant of [UnionMember0] to a value of - * type [T]. - */ - interface Visitor { - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T - - /** - * Maps an unknown variant of [UnionMember0] to a value of type [T]. - * - * An instance of [UnionMember0] 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 UnionMember0: $json") - } - } - - internal class Deserializer : BaseDeserializer(UnionMember0::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { - - override fun serialize( - value: UnionMember0, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnionMember0") - } - } - } - } - - /** Primitive JSON scalar. */ @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) class UnnamedSchemaWithArrayParent2 private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun string(): Optional = Optional.ofNullable(string) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun number(): Optional = Optional.ofNullable(number) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun bool(): Optional = Optional.ofNullable(bool) - fun isJsonScalar(): Boolean = jsonScalar != null + fun isString(): Boolean = string != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isNumber(): Boolean = number != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + fun asString(): String = string.getOrThrow("string") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + fun asNumber(): Double = number.getOrThrow("number") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + fun asBool(): Boolean = bool.getOrThrow("bool") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) else -> visitor.unknown(_json) } @@ -1394,11 +1248,11 @@ private constructor( accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} + override fun visitString(string: String) {} - override fun visitJsonScalar(jsonScalar: Double) {} + override fun visitNumber(number: Double) {} - override fun visitJsonScalar(jsonScalar: Boolean) {} + override fun visitBool(bool: Boolean) {} } ) validated = true @@ -1422,11 +1276,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) = 1 + override fun visitString(string: String) = 1 - override fun visitJsonScalar(jsonScalar: Double) = 1 + override fun visitNumber(number: Double) = 1 - override fun visitJsonScalar(jsonScalar: Boolean) = 1 + override fun visitBool(bool: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1438,41 +1292,32 @@ private constructor( } return other is UnnamedSchemaWithArrayParent2 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar + string == other.string && + number == other.number && + bool == other.bool } - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + override fun hashCode(): Int = Objects.hash(string, number, bool) override fun toString(): String = when { - jsonScalar != null -> - "UnnamedSchemaWithArrayParent2{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent2{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent2{jsonScalar=$jsonScalar}" + 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 { - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: String) = - UnnamedSchemaWithArrayParent2(jsonScalar = jsonScalar) + fun ofString(string: String) = UnnamedSchemaWithArrayParent2(string = string) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = - UnnamedSchemaWithArrayParent2(jsonScalar = jsonScalar) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent2(number = number) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = - UnnamedSchemaWithArrayParent2(jsonScalar = jsonScalar) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent2(bool = bool) } /** @@ -1481,14 +1326,11 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T + fun visitString(string: String): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T + fun visitNumber(number: Double): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T + fun visitBool(bool: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of type @@ -1521,13 +1363,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent2(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent2(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent2(bool = it, _json = json) }, ) .filterNotNull() @@ -1558,9 +1400,9 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + 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") 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 15768edb..d8f5d652 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 @@ -734,19 +734,25 @@ private constructor( this.defaultValue = defaultValue } - /** - * Alias for calling [defaultValue] with `DefaultValue.ofUnionMember0(unionMember0)`. - */ - fun defaultValue(unionMember0: DefaultValue.UnionMember0) = - defaultValue(DefaultValue.ofUnionMember0(unionMember0)) + /** 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.ofJsonScalarArray(jsonScalarArray)`. + * `DefaultValue.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s)`. */ - fun defaultValueOfJsonScalarArray( - jsonScalarArray: List - ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) + fun defaultValueOfUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) + ) /** * Sets this custom metadata field as required. Setting custom metadata fields on an @@ -967,33 +973,56 @@ private constructor( @JsonSerialize(using = DefaultValue.Serializer::class) class DefaultValue private constructor( - private val unionMember0: UnionMember0? = null, - private val jsonScalarArray: List? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val unnamedSchemaWithArrayParent4s: List? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + 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 unnamedSchemaWithArrayParent4s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent4s) - fun jsonScalarArray(): Optional> = - Optional.ofNullable(jsonScalarArray) + fun isString(): Boolean = string != null - fun isUnionMember0(): Boolean = unionMember0 != null + fun isNumber(): Boolean = number != null - fun isJsonScalarArray(): Boolean = jsonScalarArray != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun isUnnamedSchemaWithArrayParent4s(): Boolean = unnamedSchemaWithArrayParent4s != null - fun asJsonScalarArray(): List = - jsonScalarArray.getOrThrow("jsonScalarArray") + 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 asUnnamedSchemaWithArrayParent4s(): List = + unnamedSchemaWithArrayParent4s.getOrThrow("unnamedSchemaWithArrayParent4s") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + unnamedSchemaWithArrayParent4s != null -> + visitor.visitUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) else -> visitor.unknown(_json) } @@ -1006,14 +1035,16 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } + override fun visitString(string: String) {} - override fun visitJsonScalarArray( - jsonScalarArray: List + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List ) { - jsonScalarArray.forEach { it.validate() } + unnamedSchemaWithArrayParent4s.forEach { it.validate() } } } ) @@ -1038,12 +1069,15 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitString(string: String) = 1 - override fun visitJsonScalarArray( - jsonScalarArray: List - ) = jsonScalarArray.sumOf { it.validity().toInt() } + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = unnamedSchemaWithArrayParent4s.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1055,30 +1089,46 @@ private constructor( } return other is DefaultValue && - unionMember0 == other.unionMember0 && - jsonScalarArray == other.jsonScalarArray + string == other.string && + number == other.number && + bool == other.bool && + unnamedSchemaWithArrayParent4s == other.unnamedSchemaWithArrayParent4s } - override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent4s) override fun toString(): String = when { - unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" - jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent4s != null -> + "DefaultValue{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } companion object { - /** Primitive JSON scalar. */ - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - DefaultValue(unionMember0 = unionMember0) + @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 ofJsonScalarArray(jsonScalarArray: List) = - DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) + fun ofUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent4s = + unnamedSchemaWithArrayParent4s.toImmutable() + ) } /** @@ -1087,10 +1137,19 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitString(string: String): T - fun visitJsonScalarArray(jsonScalarArray: List): 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 visitUnnamedSchemaWithArrayParent4s( + unnamedSchemaWithArrayParent4s: List + ): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1114,14 +1173,25 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - DefaultValue(unionMember0 = it, _json = json) + 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(jsonScalarArray = it, _json = json) }, + ?.let { + DefaultValue( + unnamedSchemaWithArrayParent4s = it, + _json = json, + ) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1147,268 +1217,52 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.jsonScalarArray != null -> - generator.writeObject(value.jsonScalarArray) + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.unnamedSchemaWithArrayParent4s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent4s) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } - /** Primitive JSON scalar. */ - @JsonDeserialize(using = UnionMember0.Deserializer::class) - @JsonSerialize(using = UnionMember0.Serializer::class) - class UnionMember0 - private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} - - override fun visitJsonScalar(jsonScalar: Double) {} - - override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 - - override fun visitJsonScalar(jsonScalar: Double) = 1 - - override fun visitJsonScalar(jsonScalar: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar - } - - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) - - override fun toString(): String = - when { - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - _json != null -> "UnionMember0{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnionMember0") - } - - companion object { - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) - } - - /** - * An interface that defines how to map each variant of [UnionMember0] to a value of - * type [T]. - */ - interface Visitor { - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T - - /** - * Maps an unknown variant of [UnionMember0] to a value of type [T]. - * - * An instance of [UnionMember0] 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 UnionMember0: $json") - } - } - - internal class Deserializer : BaseDeserializer(UnionMember0::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { - - override fun serialize( - value: UnionMember0, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnionMember0") - } - } - } - } - - /** Primitive JSON scalar. */ @JsonDeserialize(using = UnnamedSchemaWithArrayParent4.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) class UnnamedSchemaWithArrayParent4 private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun string(): Optional = Optional.ofNullable(string) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun number(): Optional = Optional.ofNullable(number) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun bool(): Optional = Optional.ofNullable(bool) - fun isJsonScalar(): Boolean = jsonScalar != null + fun isString(): Boolean = string != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isNumber(): Boolean = number != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + fun asString(): String = string.getOrThrow("string") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + fun asNumber(): Double = number.getOrThrow("number") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + fun asBool(): Boolean = bool.getOrThrow("bool") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) else -> visitor.unknown(_json) } @@ -1421,11 +1275,11 @@ private constructor( accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} + override fun visitString(string: String) {} - override fun visitJsonScalar(jsonScalar: Double) {} + override fun visitNumber(number: Double) {} - override fun visitJsonScalar(jsonScalar: Boolean) {} + override fun visitBool(bool: Boolean) {} } ) validated = true @@ -1449,11 +1303,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) = 1 + override fun visitString(string: String) = 1 - override fun visitJsonScalar(jsonScalar: Double) = 1 + override fun visitNumber(number: Double) = 1 - override fun visitJsonScalar(jsonScalar: Boolean) = 1 + override fun visitBool(bool: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1465,41 +1319,32 @@ private constructor( } return other is UnnamedSchemaWithArrayParent4 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar + string == other.string && + number == other.number && + bool == other.bool } - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + override fun hashCode(): Int = Objects.hash(string, number, bool) override fun toString(): String = when { - jsonScalar != null -> - "UnnamedSchemaWithArrayParent4{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent4{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent4{jsonScalar=$jsonScalar}" + string != null -> "UnnamedSchemaWithArrayParent4{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent4{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent4{bool=$bool}" _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") } companion object { - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: String) = - UnnamedSchemaWithArrayParent4(jsonScalar = jsonScalar) + fun ofString(string: String) = UnnamedSchemaWithArrayParent4(string = string) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = - UnnamedSchemaWithArrayParent4(jsonScalar = jsonScalar) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent4(number = number) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = - UnnamedSchemaWithArrayParent4(jsonScalar = jsonScalar) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent4(bool = bool) } /** @@ -1508,14 +1353,11 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T + fun visitString(string: String): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T + fun visitNumber(number: Double): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T + fun visitBool(bool: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type @@ -1548,13 +1390,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent4(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent4(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent4(bool = it, _json = json) }, ) .filterNotNull() @@ -1585,9 +1427,9 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + 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 UnnamedSchemaWithArrayParent4") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt index b7ad259b..29d241ff 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt @@ -553,19 +553,25 @@ private constructor( this.defaultValue = defaultValue } - /** - * Alias for calling [defaultValue] with `DefaultValue.ofUnionMember0(unionMember0)`. - */ - fun defaultValue(unionMember0: DefaultValue.UnionMember0) = - defaultValue(DefaultValue.ofUnionMember0(unionMember0)) + /** 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.ofJsonScalarArray(jsonScalarArray)`. + * `DefaultValue.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s)`. */ - fun defaultValueOfJsonScalarArray( - jsonScalarArray: List - ) = defaultValue(DefaultValue.ofJsonScalarArray(jsonScalarArray)) + fun defaultValueOfUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List + ) = + defaultValue( + DefaultValue.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) + ) /** Specifies if the this custom metadata field is required or not. */ fun isValueRequired(isValueRequired: Boolean) = @@ -940,33 +946,56 @@ private constructor( @JsonSerialize(using = DefaultValue.Serializer::class) class DefaultValue private constructor( - private val unionMember0: UnionMember0? = null, - private val jsonScalarArray: List? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val unnamedSchemaWithArrayParent1s: List? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + 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 unnamedSchemaWithArrayParent1s(): Optional> = + Optional.ofNullable(unnamedSchemaWithArrayParent1s) - fun jsonScalarArray(): Optional> = - Optional.ofNullable(jsonScalarArray) + fun isString(): Boolean = string != null - fun isUnionMember0(): Boolean = unionMember0 != null + fun isNumber(): Boolean = number != null - fun isJsonScalarArray(): Boolean = jsonScalarArray != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun isUnnamedSchemaWithArrayParent1s(): Boolean = unnamedSchemaWithArrayParent1s != null - fun asJsonScalarArray(): List = - jsonScalarArray.getOrThrow("jsonScalarArray") + 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 asUnnamedSchemaWithArrayParent1s(): List = + unnamedSchemaWithArrayParent1s.getOrThrow("unnamedSchemaWithArrayParent1s") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - jsonScalarArray != null -> visitor.visitJsonScalarArray(jsonScalarArray) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + unnamedSchemaWithArrayParent1s != null -> + visitor.visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) else -> visitor.unknown(_json) } @@ -979,14 +1008,16 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } + override fun visitString(string: String) {} - override fun visitJsonScalarArray( - jsonScalarArray: List + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List ) { - jsonScalarArray.forEach { it.validate() } + unnamedSchemaWithArrayParent1s.forEach { it.validate() } } } ) @@ -1011,12 +1042,15 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitString(string: String) = 1 - override fun visitJsonScalarArray( - jsonScalarArray: List - ) = jsonScalarArray.sumOf { it.validity().toInt() } + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List + ) = unnamedSchemaWithArrayParent1s.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1028,30 +1062,46 @@ private constructor( } return other is DefaultValue && - unionMember0 == other.unionMember0 && - jsonScalarArray == other.jsonScalarArray + string == other.string && + number == other.number && + bool == other.bool && + unnamedSchemaWithArrayParent1s == other.unnamedSchemaWithArrayParent1s } - override fun hashCode(): Int = Objects.hash(unionMember0, jsonScalarArray) + override fun hashCode(): Int = + Objects.hash(string, number, bool, unnamedSchemaWithArrayParent1s) override fun toString(): String = when { - unionMember0 != null -> "DefaultValue{unionMember0=$unionMember0}" - jsonScalarArray != null -> "DefaultValue{jsonScalarArray=$jsonScalarArray}" + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + unnamedSchemaWithArrayParent1s != null -> + "DefaultValue{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } companion object { - /** Primitive JSON scalar. */ - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - DefaultValue(unionMember0 = unionMember0) + @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 ofJsonScalarArray(jsonScalarArray: List) = - DefaultValue(jsonScalarArray = jsonScalarArray.toImmutable()) + fun ofUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List + ) = + DefaultValue( + unnamedSchemaWithArrayParent1s = + unnamedSchemaWithArrayParent1s.toImmutable() + ) } /** @@ -1060,10 +1110,19 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitString(string: String): T - fun visitJsonScalarArray(jsonScalarArray: List): 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 visitUnnamedSchemaWithArrayParent1s( + unnamedSchemaWithArrayParent1s: List + ): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1087,14 +1146,25 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - DefaultValue(unionMember0 = it, _json = json) + 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(jsonScalarArray = it, _json = json) }, + ?.let { + DefaultValue( + unnamedSchemaWithArrayParent1s = it, + _json = json, + ) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1120,268 +1190,52 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.jsonScalarArray != null -> - generator.writeObject(value.jsonScalarArray) + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.unnamedSchemaWithArrayParent1s != null -> + generator.writeObject(value.unnamedSchemaWithArrayParent1s) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } } } - /** Primitive JSON scalar. */ - @JsonDeserialize(using = UnionMember0.Deserializer::class) - @JsonSerialize(using = UnionMember0.Serializer::class) - class UnionMember0 - private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - fun isJsonScalar(): Boolean = jsonScalar != null - - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") - - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} - - override fun visitJsonScalar(jsonScalar: Double) {} - - override fun visitJsonScalar(jsonScalar: 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 visitJsonScalar(jsonScalar: String) = 1 - - override fun visitJsonScalar(jsonScalar: Double) = 1 - - override fun visitJsonScalar(jsonScalar: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar - } - - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) - - override fun toString(): String = - when { - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - jsonScalar != null -> "UnionMember0{jsonScalar=$jsonScalar}" - _json != null -> "UnionMember0{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnionMember0") - } - - companion object { - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: String) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = UnionMember0(jsonScalar = jsonScalar) - - /** Primitive JSON scalar. */ - @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = UnionMember0(jsonScalar = jsonScalar) - } - - /** - * An interface that defines how to map each variant of [UnionMember0] to a value of - * type [T]. - */ - interface Visitor { - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T - - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T - - /** - * Maps an unknown variant of [UnionMember0] to a value of type [T]. - * - * An instance of [UnionMember0] 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 UnionMember0: $json") - } - } - - internal class Deserializer : BaseDeserializer(UnionMember0::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnionMember0 { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnionMember0(jsonScalar = 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 -> UnionMember0(_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(UnionMember0::class) { - - override fun serialize( - value: UnionMember0, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnionMember0") - } - } - } - } - - /** Primitive JSON scalar. */ @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) class UnnamedSchemaWithArrayParent1 private constructor( - private val jsonScalar: String? = null, - private val jsonScalar: Double? = null, - private val jsonScalar: Boolean? = null, + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, private val _json: JsonValue? = null, ) { - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun string(): Optional = Optional.ofNullable(string) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun number(): Optional = Optional.ofNullable(number) - /** Primitive JSON scalar. */ - fun jsonScalar(): Optional = Optional.ofNullable(jsonScalar) + fun bool(): Optional = Optional.ofNullable(bool) - fun isJsonScalar(): Boolean = jsonScalar != null + fun isString(): Boolean = string != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isNumber(): Boolean = number != null - fun isJsonScalar(): Boolean = jsonScalar != null + fun isBool(): Boolean = bool != null - /** Primitive JSON scalar. */ - fun asJsonScalar(): String = jsonScalar.getOrThrow("jsonScalar") + fun asString(): String = string.getOrThrow("string") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Double = jsonScalar.getOrThrow("jsonScalar") + fun asNumber(): Double = number.getOrThrow("number") - /** Primitive JSON scalar. */ - fun asJsonScalar(): Boolean = jsonScalar.getOrThrow("jsonScalar") + fun asBool(): Boolean = bool.getOrThrow("bool") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) - jsonScalar != null -> visitor.visitJsonScalar(jsonScalar) + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) else -> visitor.unknown(_json) } @@ -1394,11 +1248,11 @@ private constructor( accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) {} + override fun visitString(string: String) {} - override fun visitJsonScalar(jsonScalar: Double) {} + override fun visitNumber(number: Double) {} - override fun visitJsonScalar(jsonScalar: Boolean) {} + override fun visitBool(bool: Boolean) {} } ) validated = true @@ -1422,11 +1276,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitJsonScalar(jsonScalar: String) = 1 + override fun visitString(string: String) = 1 - override fun visitJsonScalar(jsonScalar: Double) = 1 + override fun visitNumber(number: Double) = 1 - override fun visitJsonScalar(jsonScalar: Boolean) = 1 + override fun visitBool(bool: Boolean) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -1438,41 +1292,32 @@ private constructor( } return other is UnnamedSchemaWithArrayParent1 && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar && - jsonScalar == other.jsonScalar + string == other.string && + number == other.number && + bool == other.bool } - override fun hashCode(): Int = Objects.hash(jsonScalar, jsonScalar, jsonScalar) + override fun hashCode(): Int = Objects.hash(string, number, bool) override fun toString(): String = when { - jsonScalar != null -> - "UnnamedSchemaWithArrayParent1{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent1{jsonScalar=$jsonScalar}" - jsonScalar != null -> - "UnnamedSchemaWithArrayParent1{jsonScalar=$jsonScalar}" + 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 { - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: String) = - UnnamedSchemaWithArrayParent1(jsonScalar = jsonScalar) + fun ofString(string: String) = UnnamedSchemaWithArrayParent1(string = string) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Double) = - UnnamedSchemaWithArrayParent1(jsonScalar = jsonScalar) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent1(number = number) - /** Primitive JSON scalar. */ @JvmStatic - fun ofJsonScalar(jsonScalar: Boolean) = - UnnamedSchemaWithArrayParent1(jsonScalar = jsonScalar) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent1(bool = bool) } /** @@ -1481,14 +1326,11 @@ private constructor( */ interface Visitor { - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: String): T + fun visitString(string: String): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Double): T + fun visitNumber(number: Double): T - /** Primitive JSON scalar. */ - fun visitJsonScalar(jsonScalar: Boolean): T + fun visitBool(bool: Boolean): T /** * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type @@ -1521,13 +1363,13 @@ private constructor( val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent1(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent1(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(jsonScalar = it, _json = json) + UnnamedSchemaWithArrayParent1(bool = it, _json = json) }, ) .filterNotNull() @@ -1558,9 +1400,9 @@ private constructor( provider: SerializerProvider, ) { when { - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) - value.jsonScalar != null -> generator.writeObject(value.jsonScalar) + 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") 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 428598e9..018fb8c6 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,10 +15,7 @@ internal class CustomMetadataFieldCreateParamsTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue( - CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -48,10 +45,7 @@ internal class CustomMetadataFieldCreateParamsTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue( - CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -85,10 +79,7 @@ internal class CustomMetadataFieldCreateParamsTest { .isEqualTo( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue( - CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt index 008a01f4..0fa0ea81 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt @@ -19,10 +19,7 @@ internal class CustomMetadataFieldCreateResponseTest { .schema( CustomMetadataFieldCreateResponse.Schema.builder() .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldCreateResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -59,10 +56,7 @@ internal class CustomMetadataFieldCreateResponseTest { .isEqualTo( CustomMetadataFieldCreateResponse.Schema.builder() .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldCreateResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -95,10 +89,7 @@ internal class CustomMetadataFieldCreateResponseTest { .schema( CustomMetadataFieldCreateResponse.Schema.builder() .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldCreateResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue("string") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt index ab06f21b..6dd28045 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt @@ -19,10 +19,7 @@ internal class CustomMetadataFieldListResponseTest { .schema( CustomMetadataFieldListResponse.Schema.builder() .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldListResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -55,10 +52,7 @@ internal class CustomMetadataFieldListResponseTest { .isEqualTo( CustomMetadataFieldListResponse.Schema.builder() .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldListResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -89,10 +83,7 @@ internal class CustomMetadataFieldListResponseTest { .schema( CustomMetadataFieldListResponse.Schema.builder() .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldListResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .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 eaf4ef8e..5611af8d 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,10 +14,7 @@ internal class CustomMetadataFieldUpdateParamsTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue( - CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -55,10 +52,7 @@ internal class CustomMetadataFieldUpdateParamsTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue( - CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -90,10 +84,7 @@ internal class CustomMetadataFieldUpdateParamsTest { assertThat(body.schema()) .contains( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue( - CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt index 1a9aa8cf..2ce6e88a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt @@ -19,10 +19,7 @@ internal class CustomMetadataFieldUpdateResponseTest { .schema( CustomMetadataFieldUpdateResponse.Schema.builder() .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldUpdateResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -59,10 +56,7 @@ internal class CustomMetadataFieldUpdateResponseTest { .isEqualTo( CustomMetadataFieldUpdateResponse.Schema.builder() .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldUpdateResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -95,10 +89,7 @@ internal class CustomMetadataFieldUpdateResponseTest { .schema( CustomMetadataFieldUpdateResponse.Schema.builder() .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue( - CustomMetadataFieldUpdateResponse.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue("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 a8296f21..bb8af989 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 @@ -33,10 +33,7 @@ internal class CustomMetadataFieldServiceAsyncTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue( - CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -89,10 +86,7 @@ internal class CustomMetadataFieldServiceAsyncTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue( - CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .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 168f3def..be0a158b 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 @@ -33,10 +33,7 @@ internal class CustomMetadataFieldServiceTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue( - CustomMetadataFieldCreateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -88,10 +85,7 @@ internal class CustomMetadataFieldServiceTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue( - CustomMetadataFieldUpdateParams.Schema.DefaultValue.UnionMember0 - .ofJsonScalar("Hello") - ) + .defaultValue("string") .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) From cf55395c5dc11bc4c44239c6d62d310ca1a5b63a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:36:29 +0000 Subject: [PATCH 028/125] feat(api): manual updates --- .stats.yml | 4 +- .../CustomMetadataFieldCreateParams.kt | 61 +++++++++---------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3ae65fac..1bb527b9 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-cb2369e849b98127ee6a2cbd01d928e4546d29c1a0a8e64e9b46f90189c1a992.yml -openapi_spec_hash: f8e732e88daf7c4bfbeb2bd2cdba2cec +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7da4f48715dfd85e3bbc25086d62dc4959fb6bd1a9c3fd3933cfe0e80f6ae244.yml +openapi_spec_hash: 260d09fbed77316aae394877e5239398 config_hash: c9b1142a72b93ad4d66f0433dca1392e 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 cdc7d3fb..8444c53e 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 @@ -855,13 +855,13 @@ private constructor( /** * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s)`. + * `DefaultValue.ofArrayForMultiSelectTypeFields(arrayForMultiSelectTypeFields)`. */ - fun defaultValueOfUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List + fun defaultValueOfArrayForMultiSelectTypeFields( + arrayForMultiSelectTypeFields: List ) = defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) + DefaultValue.ofArrayForMultiSelectTypeFields(arrayForMultiSelectTypeFields) ) /** @@ -1254,7 +1254,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val unnamedSchemaWithArrayParent3s: List? = null, + private val arrayForMultiSelectTypeFields: List? = null, private val _json: JsonValue? = null, ) { @@ -1268,8 +1268,8 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun unnamedSchemaWithArrayParent3s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent3s) + fun arrayForMultiSelectTypeFields(): Optional> = + Optional.ofNullable(arrayForMultiSelectTypeFields) fun isString(): Boolean = string != null @@ -1277,7 +1277,7 @@ private constructor( fun isBool(): Boolean = bool != null - fun isUnnamedSchemaWithArrayParent3s(): Boolean = unnamedSchemaWithArrayParent3s != null + fun isArrayForMultiSelectTypeFields(): Boolean = arrayForMultiSelectTypeFields != null fun asString(): String = string.getOrThrow("string") @@ -1289,8 +1289,8 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asUnnamedSchemaWithArrayParent3s(): List = - unnamedSchemaWithArrayParent3s.getOrThrow("unnamedSchemaWithArrayParent3s") + fun asArrayForMultiSelectTypeFields(): List = + arrayForMultiSelectTypeFields.getOrThrow("arrayForMultiSelectTypeFields") fun _json(): Optional = Optional.ofNullable(_json) @@ -1299,8 +1299,8 @@ private constructor( string != null -> visitor.visitString(string) number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) - unnamedSchemaWithArrayParent3s != null -> - visitor.visitUnnamedSchemaWithArrayParent3s(unnamedSchemaWithArrayParent3s) + arrayForMultiSelectTypeFields != null -> + visitor.visitArrayForMultiSelectTypeFields(arrayForMultiSelectTypeFields) else -> visitor.unknown(_json) } @@ -1319,10 +1319,10 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List + override fun visitArrayForMultiSelectTypeFields( + arrayForMultiSelectTypeFields: List ) { - unnamedSchemaWithArrayParent3s.forEach { it.validate() } + arrayForMultiSelectTypeFields.forEach { it.validate() } } } ) @@ -1353,9 +1353,9 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List - ) = unnamedSchemaWithArrayParent3s.sumOf { it.validity().toInt() } + override fun visitArrayForMultiSelectTypeFields( + arrayForMultiSelectTypeFields: List + ) = arrayForMultiSelectTypeFields.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1370,19 +1370,19 @@ private constructor( string == other.string && number == other.number && bool == other.bool && - unnamedSchemaWithArrayParent3s == other.unnamedSchemaWithArrayParent3s + arrayForMultiSelectTypeFields == other.arrayForMultiSelectTypeFields } override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent3s) + Objects.hash(string, number, bool, arrayForMultiSelectTypeFields) override fun toString(): String = when { string != null -> "DefaultValue{string=$string}" number != null -> "DefaultValue{number=$number}" bool != null -> "DefaultValue{bool=$bool}" - unnamedSchemaWithArrayParent3s != null -> - "DefaultValue{unnamedSchemaWithArrayParent3s=$unnamedSchemaWithArrayParent3s}" + arrayForMultiSelectTypeFields != null -> + "DefaultValue{arrayForMultiSelectTypeFields=$arrayForMultiSelectTypeFields}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } @@ -1400,12 +1400,11 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List + fun ofArrayForMultiSelectTypeFields( + arrayForMultiSelectTypeFields: List ) = DefaultValue( - unnamedSchemaWithArrayParent3s = - unnamedSchemaWithArrayParent3s.toImmutable() + arrayForMultiSelectTypeFields = arrayForMultiSelectTypeFields.toImmutable() ) } @@ -1425,8 +1424,8 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitUnnamedSchemaWithArrayParent3s( - unnamedSchemaWithArrayParent3s: List + fun visitArrayForMultiSelectTypeFields( + arrayForMultiSelectTypeFields: List ): T /** @@ -1466,7 +1465,7 @@ private constructor( ) ?.let { DefaultValue( - unnamedSchemaWithArrayParent3s = it, + arrayForMultiSelectTypeFields = it, _json = json, ) }, @@ -1498,8 +1497,8 @@ private constructor( value.string != null -> generator.writeObject(value.string) value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) - value.unnamedSchemaWithArrayParent3s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent3s) + value.arrayForMultiSelectTypeFields != null -> + generator.writeObject(value.arrayForMultiSelectTypeFields) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } From ce5e0556a8bab8c4bf0da360a409dfaf912cb82e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:38:53 +0000 Subject: [PATCH 029/125] feat(api): manual updates --- .stats.yml | 4 +- .../CustomMetadataFieldCreateParams.kt | 67 ++++++------------ .../CustomMetadataFieldCreateResponse.kt | 68 ++++++------------- .../CustomMetadataFieldListResponse.kt | 68 ++++++------------- .../CustomMetadataFieldUpdateParams.kt | 68 ++++++------------- .../CustomMetadataFieldUpdateResponse.kt | 68 ++++++------------- 6 files changed, 102 insertions(+), 241 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1bb527b9..825ee654 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-7da4f48715dfd85e3bbc25086d62dc4959fb6bd1a9c3fd3933cfe0e80f6ae244.yml -openapi_spec_hash: 260d09fbed77316aae394877e5239398 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-76afc867b06fdc43b339f2c7d19f25a46481b25e8264ca24ea43daa1ea9234fc.yml +openapi_spec_hash: a1455d2ab02c48a14551362dd8ec2261 config_hash: c9b1142a72b93ad4d66f0433dca1392e 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 8444c53e..2d9f5f1a 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 @@ -853,16 +853,9 @@ private constructor( /** Alias for calling [defaultValue] with `DefaultValue.ofBool(bool)`. */ fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) - /** - * Alias for calling [defaultValue] with - * `DefaultValue.ofArrayForMultiSelectTypeFields(arrayForMultiSelectTypeFields)`. - */ - fun defaultValueOfArrayForMultiSelectTypeFields( - arrayForMultiSelectTypeFields: List - ) = - defaultValue( - DefaultValue.ofArrayForMultiSelectTypeFields(arrayForMultiSelectTypeFields) - ) + /** 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 @@ -1254,7 +1247,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val arrayForMultiSelectTypeFields: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -1268,8 +1261,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun arrayForMultiSelectTypeFields(): Optional> = - Optional.ofNullable(arrayForMultiSelectTypeFields) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -1277,7 +1269,7 @@ private constructor( fun isBool(): Boolean = bool != null - fun isArrayForMultiSelectTypeFields(): Boolean = arrayForMultiSelectTypeFields != null + fun isMixed(): Boolean = mixed != null fun asString(): String = string.getOrThrow("string") @@ -1289,8 +1281,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asArrayForMultiSelectTypeFields(): List = - arrayForMultiSelectTypeFields.getOrThrow("arrayForMultiSelectTypeFields") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1299,8 +1290,7 @@ private constructor( string != null -> visitor.visitString(string) number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) - arrayForMultiSelectTypeFields != null -> - visitor.visitArrayForMultiSelectTypeFields(arrayForMultiSelectTypeFields) + mixed != null -> visitor.visitMixed(mixed) else -> visitor.unknown(_json) } @@ -1319,10 +1309,8 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitArrayForMultiSelectTypeFields( - arrayForMultiSelectTypeFields: List - ) { - arrayForMultiSelectTypeFields.forEach { it.validate() } + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } } } ) @@ -1353,9 +1341,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitArrayForMultiSelectTypeFields( - arrayForMultiSelectTypeFields: List - ) = arrayForMultiSelectTypeFields.sumOf { it.validity().toInt() } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1370,19 +1357,17 @@ private constructor( string == other.string && number == other.number && bool == other.bool && - arrayForMultiSelectTypeFields == other.arrayForMultiSelectTypeFields + mixed == other.mixed } - override fun hashCode(): Int = - Objects.hash(string, number, bool, arrayForMultiSelectTypeFields) + 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}" - arrayForMultiSelectTypeFields != null -> - "DefaultValue{arrayForMultiSelectTypeFields=$arrayForMultiSelectTypeFields}" + mixed != null -> "DefaultValue{mixed=$mixed}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } @@ -1400,12 +1385,8 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofArrayForMultiSelectTypeFields( - arrayForMultiSelectTypeFields: List - ) = - DefaultValue( - arrayForMultiSelectTypeFields = arrayForMultiSelectTypeFields.toImmutable() - ) + fun ofMixed(mixed: List) = + DefaultValue(mixed = mixed.toImmutable()) } /** @@ -1424,9 +1405,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitArrayForMultiSelectTypeFields( - arrayForMultiSelectTypeFields: List - ): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1463,12 +1442,7 @@ private constructor( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - arrayForMultiSelectTypeFields = it, - _json = json, - ) - }, + ?.let { DefaultValue(mixed = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1497,8 +1471,7 @@ private constructor( value.string != null -> generator.writeObject(value.string) value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) - value.arrayForMultiSelectTypeFields != null -> - generator.writeObject(value.arrayForMultiSelectTypeFields) + value.mixed != null -> generator.writeObject(value.mixed) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt index 0b38db4f..09699509 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt @@ -562,16 +562,9 @@ private constructor( /** Alias for calling [defaultValue] with `DefaultValue.ofBool(bool)`. */ fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) - /** - * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s)`. - */ - fun defaultValueOfUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) - ) + /** 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) = @@ -949,7 +942,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val unnamedSchemaWithArrayParent0s: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -963,8 +956,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun unnamedSchemaWithArrayParent0s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent0s) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -972,7 +964,7 @@ private constructor( fun isBool(): Boolean = bool != null - fun isUnnamedSchemaWithArrayParent0s(): Boolean = unnamedSchemaWithArrayParent0s != null + fun isMixed(): Boolean = mixed != null fun asString(): String = string.getOrThrow("string") @@ -984,8 +976,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asUnnamedSchemaWithArrayParent0s(): List = - unnamedSchemaWithArrayParent0s.getOrThrow("unnamedSchemaWithArrayParent0s") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -994,8 +985,7 @@ private constructor( string != null -> visitor.visitString(string) number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) - unnamedSchemaWithArrayParent0s != null -> - visitor.visitUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) + mixed != null -> visitor.visitMixed(mixed) else -> visitor.unknown(_json) } @@ -1014,10 +1004,8 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ) { - unnamedSchemaWithArrayParent0s.forEach { it.validate() } + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } } } ) @@ -1048,9 +1036,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ) = unnamedSchemaWithArrayParent0s.sumOf { it.validity().toInt() } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1065,19 +1052,17 @@ private constructor( string == other.string && number == other.number && bool == other.bool && - unnamedSchemaWithArrayParent0s == other.unnamedSchemaWithArrayParent0s + mixed == other.mixed } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent0s) + 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}" - unnamedSchemaWithArrayParent0s != null -> - "DefaultValue{unnamedSchemaWithArrayParent0s=$unnamedSchemaWithArrayParent0s}" + mixed != null -> "DefaultValue{mixed=$mixed}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } @@ -1095,13 +1080,8 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent0s = - unnamedSchemaWithArrayParent0s.toImmutable() - ) + fun ofMixed(mixed: List) = + DefaultValue(mixed = mixed.toImmutable()) } /** @@ -1120,9 +1100,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitUnnamedSchemaWithArrayParent0s( - unnamedSchemaWithArrayParent0s: List - ): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1159,12 +1137,7 @@ private constructor( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent0s = it, - _json = json, - ) - }, + ?.let { DefaultValue(mixed = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1193,8 +1166,7 @@ private constructor( value.string != null -> generator.writeObject(value.string) value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) - value.unnamedSchemaWithArrayParent0s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent0s) + value.mixed != null -> generator.writeObject(value.mixed) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt index 8e4fd30f..b3cb6e49 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt @@ -562,16 +562,9 @@ private constructor( /** Alias for calling [defaultValue] with `DefaultValue.ofBool(bool)`. */ fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) - /** - * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s)`. - */ - fun defaultValueOfUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) - ) + /** 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) = @@ -949,7 +942,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val unnamedSchemaWithArrayParent2s: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -963,8 +956,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun unnamedSchemaWithArrayParent2s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent2s) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -972,7 +964,7 @@ private constructor( fun isBool(): Boolean = bool != null - fun isUnnamedSchemaWithArrayParent2s(): Boolean = unnamedSchemaWithArrayParent2s != null + fun isMixed(): Boolean = mixed != null fun asString(): String = string.getOrThrow("string") @@ -984,8 +976,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asUnnamedSchemaWithArrayParent2s(): List = - unnamedSchemaWithArrayParent2s.getOrThrow("unnamedSchemaWithArrayParent2s") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -994,8 +985,7 @@ private constructor( string != null -> visitor.visitString(string) number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) - unnamedSchemaWithArrayParent2s != null -> - visitor.visitUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) + mixed != null -> visitor.visitMixed(mixed) else -> visitor.unknown(_json) } @@ -1014,10 +1004,8 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ) { - unnamedSchemaWithArrayParent2s.forEach { it.validate() } + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } } } ) @@ -1048,9 +1036,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ) = unnamedSchemaWithArrayParent2s.sumOf { it.validity().toInt() } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1065,19 +1052,17 @@ private constructor( string == other.string && number == other.number && bool == other.bool && - unnamedSchemaWithArrayParent2s == other.unnamedSchemaWithArrayParent2s + mixed == other.mixed } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent2s) + 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}" - unnamedSchemaWithArrayParent2s != null -> - "DefaultValue{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" + mixed != null -> "DefaultValue{mixed=$mixed}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } @@ -1095,13 +1080,8 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent2s = - unnamedSchemaWithArrayParent2s.toImmutable() - ) + fun ofMixed(mixed: List) = + DefaultValue(mixed = mixed.toImmutable()) } /** @@ -1120,9 +1100,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1159,12 +1137,7 @@ private constructor( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent2s = it, - _json = json, - ) - }, + ?.let { DefaultValue(mixed = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1193,8 +1166,7 @@ private constructor( value.string != null -> generator.writeObject(value.string) value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) - value.unnamedSchemaWithArrayParent2s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent2s) + value.mixed != null -> generator.writeObject(value.mixed) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } 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 d8f5d652..e74ec85e 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 @@ -743,16 +743,9 @@ private constructor( /** Alias for calling [defaultValue] with `DefaultValue.ofBool(bool)`. */ fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) - /** - * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s)`. - */ - fun defaultValueOfUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) - ) + /** 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 @@ -976,7 +969,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val unnamedSchemaWithArrayParent4s: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -990,8 +983,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun unnamedSchemaWithArrayParent4s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent4s) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -999,7 +991,7 @@ private constructor( fun isBool(): Boolean = bool != null - fun isUnnamedSchemaWithArrayParent4s(): Boolean = unnamedSchemaWithArrayParent4s != null + fun isMixed(): Boolean = mixed != null fun asString(): String = string.getOrThrow("string") @@ -1011,8 +1003,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asUnnamedSchemaWithArrayParent4s(): List = - unnamedSchemaWithArrayParent4s.getOrThrow("unnamedSchemaWithArrayParent4s") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1021,8 +1012,7 @@ private constructor( string != null -> visitor.visitString(string) number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) - unnamedSchemaWithArrayParent4s != null -> - visitor.visitUnnamedSchemaWithArrayParent4s(unnamedSchemaWithArrayParent4s) + mixed != null -> visitor.visitMixed(mixed) else -> visitor.unknown(_json) } @@ -1041,10 +1031,8 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ) { - unnamedSchemaWithArrayParent4s.forEach { it.validate() } + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } } } ) @@ -1075,9 +1063,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ) = unnamedSchemaWithArrayParent4s.sumOf { it.validity().toInt() } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1092,19 +1079,17 @@ private constructor( string == other.string && number == other.number && bool == other.bool && - unnamedSchemaWithArrayParent4s == other.unnamedSchemaWithArrayParent4s + mixed == other.mixed } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent4s) + 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}" - unnamedSchemaWithArrayParent4s != null -> - "DefaultValue{unnamedSchemaWithArrayParent4s=$unnamedSchemaWithArrayParent4s}" + mixed != null -> "DefaultValue{mixed=$mixed}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } @@ -1122,13 +1107,8 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent4s = - unnamedSchemaWithArrayParent4s.toImmutable() - ) + fun ofMixed(mixed: List) = + DefaultValue(mixed = mixed.toImmutable()) } /** @@ -1147,9 +1127,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitUnnamedSchemaWithArrayParent4s( - unnamedSchemaWithArrayParent4s: List - ): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1186,12 +1164,7 @@ private constructor( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent4s = it, - _json = json, - ) - }, + ?.let { DefaultValue(mixed = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1220,8 +1193,7 @@ private constructor( value.string != null -> generator.writeObject(value.string) value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) - value.unnamedSchemaWithArrayParent4s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent4s) + value.mixed != null -> generator.writeObject(value.mixed) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt index 29d241ff..bc45b595 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt @@ -562,16 +562,9 @@ private constructor( /** Alias for calling [defaultValue] with `DefaultValue.ofBool(bool)`. */ fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) - /** - * Alias for calling [defaultValue] with - * `DefaultValue.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s)`. - */ - fun defaultValueOfUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ) = - defaultValue( - DefaultValue.ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) - ) + /** 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) = @@ -949,7 +942,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val unnamedSchemaWithArrayParent1s: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -963,8 +956,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun unnamedSchemaWithArrayParent1s(): Optional> = - Optional.ofNullable(unnamedSchemaWithArrayParent1s) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -972,7 +964,7 @@ private constructor( fun isBool(): Boolean = bool != null - fun isUnnamedSchemaWithArrayParent1s(): Boolean = unnamedSchemaWithArrayParent1s != null + fun isMixed(): Boolean = mixed != null fun asString(): String = string.getOrThrow("string") @@ -984,8 +976,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asUnnamedSchemaWithArrayParent1s(): List = - unnamedSchemaWithArrayParent1s.getOrThrow("unnamedSchemaWithArrayParent1s") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -994,8 +985,7 @@ private constructor( string != null -> visitor.visitString(string) number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) - unnamedSchemaWithArrayParent1s != null -> - visitor.visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) + mixed != null -> visitor.visitMixed(mixed) else -> visitor.unknown(_json) } @@ -1014,10 +1004,8 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ) { - unnamedSchemaWithArrayParent1s.forEach { it.validate() } + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } } } ) @@ -1048,9 +1036,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ) = unnamedSchemaWithArrayParent1s.sumOf { it.validity().toInt() } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -1065,19 +1052,17 @@ private constructor( string == other.string && number == other.number && bool == other.bool && - unnamedSchemaWithArrayParent1s == other.unnamedSchemaWithArrayParent1s + mixed == other.mixed } - override fun hashCode(): Int = - Objects.hash(string, number, bool, unnamedSchemaWithArrayParent1s) + 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}" - unnamedSchemaWithArrayParent1s != null -> - "DefaultValue{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" + mixed != null -> "DefaultValue{mixed=$mixed}" _json != null -> "DefaultValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid DefaultValue") } @@ -1095,13 +1080,8 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ) = - DefaultValue( - unnamedSchemaWithArrayParent1s = - unnamedSchemaWithArrayParent1s.toImmutable() - ) + fun ofMixed(mixed: List) = + DefaultValue(mixed = mixed.toImmutable()) } /** @@ -1120,9 +1100,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1159,12 +1137,7 @@ private constructor( node, jacksonTypeRef>(), ) - ?.let { - DefaultValue( - unnamedSchemaWithArrayParent1s = it, - _json = json, - ) - }, + ?.let { DefaultValue(mixed = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1193,8 +1166,7 @@ private constructor( value.string != null -> generator.writeObject(value.string) value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) - value.unnamedSchemaWithArrayParent1s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent1s) + value.mixed != null -> generator.writeObject(value.mixed) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid DefaultValue") } From 9753e79c772527781214b2ae0070bbff1734d9d8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:48:16 +0000 Subject: [PATCH 030/125] feat(api): manual updates --- .stats.yml | 4 +- .../accounts/origins/OriginCreateParams.kt | 252 +++++++++--------- .../accounts/origins/OriginUpdateParams.kt | 251 +++++++++-------- 3 files changed, 251 insertions(+), 256 deletions(-) diff --git a/.stats.yml b/.stats.yml index 825ee654..aff1f7d8 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-76afc867b06fdc43b339f2c7d19f25a46481b25e8264ca24ea43daa1ea9234fc.yml -openapi_spec_hash: a1455d2ab02c48a14551362dd8ec2261 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d9f06036e82cb9fcefe298e18ab40671a4454cf02c433e42c7281391543fde39.yml +openapi_spec_hash: bfad95cff6d56f887ac5ecfa1ab2c7dd config_hash: c9b1142a72b93ad4d66f0433dca1392e 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 3329192a..3d1f7da0 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 @@ -20,7 +20,6 @@ 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.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers @@ -29,6 +28,7 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams @@ -95,13 +95,21 @@ private constructor( /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) - /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ - fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = - body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + /** + * Alias for calling [body] with the following: + * ```java + * Body.WebProxy.builder() + * .name(name) + * .build() + * ``` + */ + fun webProxyBody(name: String) = body(Body.WebProxy.builder().name(name).build()) - /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ - fun body(azureBlobStorage: Body.AzureBlobStorage) = - body(Body.ofAzureBlobStorage(azureBlobStorage)) + /** Alias for calling [body] with `Body.ofGcs(gcs)`. */ + fun body(gcs: Body.Gcs) = body(Body.ofGcs(gcs)) + + /** Alias for calling [body] with `Body.ofAzureBlob(azureBlob)`. */ + fun body(azureBlob: Body.AzureBlob) = body(Body.ofAzureBlob(azureBlob)) /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ fun body(akeneoPim: Body.AkeneoPim) = body(Body.ofAkeneoPim(akeneoPim)) @@ -240,8 +248,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -256,10 +264,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -273,9 +280,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -289,10 +296,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -305,9 +311,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -341,14 +346,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -389,12 +392,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -413,8 +413,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -425,8 +425,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -437,9 +437,8 @@ private constructor( cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "Body{webFolder=$webFolder}" webProxy != null -> "Body{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "Body{gcs=$gcs}" + azureBlob != null -> "Body{azureBlob=$azureBlob}" akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") @@ -460,13 +459,9 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - Body(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = Body(gcs = gcs) - @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - Body(azureBlobStorage = azureBlobStorage) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Body(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) } @@ -484,9 +479,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -508,47 +503,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Body { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPim = 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() + when (type) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3 = it, _json = json) + } ?: Body(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Compatible = it, _json = json) + } ?: Body(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackup = it, _json = json) + } ?: Body(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolder = it, _json = json) + } ?: Body(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxy = it, _json = json) + } ?: Body(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(gcs = it, _json = json) + } ?: Body(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlob = it, _json = json) + } ?: Body(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPim = it, _json = json) + } ?: Body(_json = json) + } } + + return Body(_json = json) } } @@ -565,9 +565,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 Body") @@ -2776,7 +2775,7 @@ private constructor( "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class Gcs private constructor( private val bucket: JsonField, private val clientEmail: JsonField, @@ -2962,8 +2961,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java @@ -2976,7 +2974,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [Gcs]. */ class Builder internal constructor() { private var bucket: JsonField? = null @@ -2990,16 +2988,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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)) @@ -3130,7 +3128,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [Gcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3144,8 +3142,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), checkRequired("name", name), @@ -3160,7 +3158,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } @@ -3210,7 +3208,7 @@ private constructor( return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && bucket == other.bucket && clientEmail == other.clientEmail && name == other.name && @@ -3239,10 +3237,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "Gcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlob private constructor( private val accountName: JsonField, private val container: JsonField, @@ -3429,7 +3427,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java @@ -3442,7 +3440,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlob]. */ class Builder internal constructor() { private var accountName: JsonField? = null @@ -3456,16 +3454,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + 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)) @@ -3594,7 +3592,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlob]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3608,8 +3606,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( checkRequired("accountName", accountName), checkRequired("container", container), checkRequired("name", name), @@ -3624,7 +3622,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } @@ -3674,7 +3672,7 @@ private constructor( return true } - return other is AzureBlobStorage && + return other is AzureBlob && accountName == other.accountName && container == other.container && name == other.name && @@ -3703,7 +3701,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "AzureBlob{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim 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 4f23d963..dfd72a2d 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 @@ -20,7 +20,6 @@ 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.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers @@ -116,13 +115,21 @@ private constructor( /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) - /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ - fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = - body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + /** + * Alias for calling [body] with the following: + * ```java + * Body.WebProxy.builder() + * .name(name) + * .build() + * ``` + */ + fun webProxyBody(name: String) = body(Body.WebProxy.builder().name(name).build()) - /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ - fun body(azureBlobStorage: Body.AzureBlobStorage) = - body(Body.ofAzureBlobStorage(azureBlobStorage)) + /** Alias for calling [body] with `Body.ofGcs(gcs)`. */ + fun body(gcs: Body.Gcs) = body(Body.ofGcs(gcs)) + + /** Alias for calling [body] with `Body.ofAzureBlob(azureBlob)`. */ + fun body(azureBlob: Body.AzureBlob) = body(Body.ofAzureBlob(azureBlob)) /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ fun body(akeneoPim: Body.AkeneoPim) = body(Body.ofAkeneoPim(akeneoPim)) @@ -268,8 +275,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -284,10 +291,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -301,9 +307,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -317,10 +323,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -333,9 +338,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -369,14 +373,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -417,12 +419,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -441,8 +440,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -453,8 +452,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -465,9 +464,8 @@ private constructor( cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "Body{webFolder=$webFolder}" webProxy != null -> "Body{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "Body{gcs=$gcs}" + azureBlob != null -> "Body{azureBlob=$azureBlob}" akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") @@ -488,13 +486,9 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - Body(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = Body(gcs = gcs) - @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - Body(azureBlobStorage = azureBlobStorage) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Body(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) } @@ -512,9 +506,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -536,47 +530,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Body { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPim = 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() + when (type) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3 = it, _json = json) + } ?: Body(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Compatible = it, _json = json) + } ?: Body(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackup = it, _json = json) + } ?: Body(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolder = it, _json = json) + } ?: Body(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxy = it, _json = json) + } ?: Body(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(gcs = it, _json = json) + } ?: Body(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlob = it, _json = json) + } ?: Body(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPim = it, _json = json) + } ?: Body(_json = json) + } } + + return Body(_json = json) } } @@ -593,9 +592,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 Body") @@ -2804,7 +2802,7 @@ private constructor( "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class Gcs private constructor( private val bucket: JsonField, private val clientEmail: JsonField, @@ -2990,8 +2988,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java @@ -3004,7 +3001,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [Gcs]. */ class Builder internal constructor() { private var bucket: JsonField? = null @@ -3018,16 +3015,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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)) @@ -3158,7 +3155,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [Gcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3172,8 +3169,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), checkRequired("name", name), @@ -3188,7 +3185,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } @@ -3238,7 +3235,7 @@ private constructor( return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && bucket == other.bucket && clientEmail == other.clientEmail && name == other.name && @@ -3267,10 +3264,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "Gcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlob private constructor( private val accountName: JsonField, private val container: JsonField, @@ -3457,7 +3454,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java @@ -3470,7 +3467,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlob]. */ class Builder internal constructor() { private var accountName: JsonField? = null @@ -3484,16 +3481,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + 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)) @@ -3622,7 +3619,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlob]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3636,8 +3633,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( checkRequired("accountName", accountName), checkRequired("container", container), checkRequired("name", name), @@ -3652,7 +3649,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } @@ -3702,7 +3699,7 @@ private constructor( return true } - return other is AzureBlobStorage && + return other is AzureBlob && accountName == other.accountName && container == other.container && name == other.name && @@ -3731,7 +3728,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "AzureBlob{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim From 5d7059aa8abeb4ffac989a67298fc075089b5d93 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:19:07 +0000 Subject: [PATCH 031/125] feat(api): manual updates --- .stats.yml | 6 +- .../accounts/origins/OriginUpdateParams.kt | 251 +++++++++--------- 2 files changed, 130 insertions(+), 127 deletions(-) diff --git a/.stats.yml b/.stats.yml index aff1f7d8..5a33818e 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-d9f06036e82cb9fcefe298e18ab40671a4454cf02c433e42c7281391543fde39.yml -openapi_spec_hash: bfad95cff6d56f887ac5ecfa1ab2c7dd -config_hash: c9b1142a72b93ad4d66f0433dca1392e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-ce1742072cca1d90af9b0be8cc75dac4f2d5b3258041c3cede545e6521f4d72a.yml +openapi_spec_hash: 5e896419003b5ef3728293241e9dd37e +config_hash: ecd4e1fc35135b5e53487ca547e46fd7 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 dfd72a2d..4f23d963 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 @@ -20,6 +20,7 @@ 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.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers @@ -115,21 +116,13 @@ private constructor( /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) - /** - * Alias for calling [body] with the following: - * ```java - * Body.WebProxy.builder() - * .name(name) - * .build() - * ``` - */ - fun webProxyBody(name: String) = body(Body.WebProxy.builder().name(name).build()) + /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ + fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = + body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) - /** Alias for calling [body] with `Body.ofGcs(gcs)`. */ - fun body(gcs: Body.Gcs) = body(Body.ofGcs(gcs)) - - /** Alias for calling [body] with `Body.ofAzureBlob(azureBlob)`. */ - fun body(azureBlob: Body.AzureBlob) = body(Body.ofAzureBlob(azureBlob)) + /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ + fun body(azureBlobStorage: Body.AzureBlobStorage) = + body(Body.ofAzureBlobStorage(azureBlobStorage)) /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ fun body(akeneoPim: Body.AkeneoPim) = body(Body.ofAkeneoPim(akeneoPim)) @@ -275,8 +268,8 @@ private constructor( 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -291,9 +284,10 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun gcs(): Optional = Optional.ofNullable(gcs) + fun googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) - fun azureBlob(): Optional = Optional.ofNullable(azureBlob) + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -307,9 +301,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGcs(): Boolean = gcs != null + fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null - fun isAzureBlob(): Boolean = azureBlob != null + fun isAzureBlobStorage(): Boolean = azureBlobStorage != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -323,9 +317,10 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGcs(): Gcs = gcs.getOrThrow("gcs") + fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") - fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -338,8 +333,9 @@ private constructor( 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -373,12 +369,14 @@ private constructor( webProxy.validate() } - override fun visitGcs(gcs: Gcs) { - gcs.validate() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() } - override fun visitAzureBlob(azureBlob: AzureBlob) { - azureBlob.validate() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -419,9 +417,12 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGcs(gcs: Gcs) = gcs.validity() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() - override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -440,8 +441,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - gcs == other.gcs && - azureBlob == other.azureBlob && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && akeneoPim == other.akeneoPim } @@ -452,8 +453,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - gcs, - azureBlob, + googleCloudStorageGcs, + azureBlobStorage, akeneoPim, ) @@ -464,8 +465,9 @@ private constructor( cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "Body{webFolder=$webFolder}" webProxy != null -> "Body{webProxy=$webProxy}" - gcs != null -> "Body{gcs=$gcs}" - azureBlob != null -> "Body{azureBlob=$azureBlob}" + googleCloudStorageGcs != null -> + "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") @@ -486,9 +488,13 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) - @JvmStatic fun ofGcs(gcs: Gcs) = Body(gcs = gcs) + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + Body(googleCloudStorageGcs = googleCloudStorageGcs) - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Body(azureBlob = azureBlob) + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + Body(azureBlobStorage = azureBlobStorage) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) } @@ -506,9 +512,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGcs(gcs: Gcs): T + fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T - fun visitAzureBlob(azureBlob: AzureBlob): T + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -530,52 +536,47 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Body { val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3 = it, _json = json) - } ?: Body(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Compatible = it, _json = json) - } ?: Body(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackup = it, _json = json) - } ?: Body(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolder = it, _json = json) - } ?: Body(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxy = it, _json = json) - } ?: Body(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(gcs = it, _json = json) - } ?: Body(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlob = it, _json = json) - } ?: Body(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPim = it, _json = json) - } ?: Body(_json = json) - } + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPim = 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() } - - return Body(_json = json) } } @@ -592,8 +593,9 @@ private constructor( 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) value.akeneoPim != null -> generator.writeObject(value.akeneoPim) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") @@ -2802,7 +2804,7 @@ private constructor( "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class Gcs + class GoogleCloudStorageGcs private constructor( private val bucket: JsonField, private val clientEmail: JsonField, @@ -2988,7 +2990,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Gcs]. + * Returns a mutable builder for constructing an instance of + * [GoogleCloudStorageGcs]. * * The following fields are required: * ```java @@ -3001,7 +3004,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [Gcs]. */ + /** A builder for [GoogleCloudStorageGcs]. */ class Builder internal constructor() { private var bucket: JsonField? = null @@ -3015,16 +3018,16 @@ private constructor( 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() + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() } fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -3155,7 +3158,7 @@ private constructor( } /** - * Returns an immutable instance of [Gcs]. + * Returns an immutable instance of [GoogleCloudStorageGcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3169,8 +3172,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Gcs = - Gcs( + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), checkRequired("name", name), @@ -3185,7 +3188,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Gcs = apply { + fun validate(): GoogleCloudStorageGcs = apply { if (validated) { return@apply } @@ -3235,7 +3238,7 @@ private constructor( return true } - return other is Gcs && + return other is GoogleCloudStorageGcs && bucket == other.bucket && clientEmail == other.clientEmail && name == other.name && @@ -3264,10 +3267,10 @@ private constructor( 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}" + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlob + class AzureBlobStorage private constructor( private val accountName: JsonField, private val container: JsonField, @@ -3454,7 +3457,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlob]. + * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. * * The following fields are required: * ```java @@ -3467,7 +3470,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlob]. */ + /** A builder for [AzureBlobStorage]. */ class Builder internal constructor() { private var accountName: JsonField? = null @@ -3481,16 +3484,16 @@ private constructor( 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() + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() } fun accountName(accountName: String) = accountName(JsonField.of(accountName)) @@ -3619,7 +3622,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlob]. + * Returns an immutable instance of [AzureBlobStorage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3633,8 +3636,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlob = - AzureBlob( + fun build(): AzureBlobStorage = + AzureBlobStorage( checkRequired("accountName", accountName), checkRequired("container", container), checkRequired("name", name), @@ -3649,7 +3652,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlob = apply { + fun validate(): AzureBlobStorage = apply { if (validated) { return@apply } @@ -3699,7 +3702,7 @@ private constructor( return true } - return other is AzureBlob && + return other is AzureBlobStorage && accountName == other.accountName && container == other.container && name == other.name && @@ -3728,7 +3731,7 @@ private constructor( 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}" + "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim From 4e1405adef30814cf68b0ca390d4555c7b5a28ba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:21:27 +0000 Subject: [PATCH 032/125] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5a33818e..ba9b6e53 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-ce1742072cca1d90af9b0be8cc75dac4f2d5b3258041c3cede545e6521f4d72a.yml -openapi_spec_hash: 5e896419003b5ef3728293241e9dd37e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-a49c22a93734b90653ada66f9b336a7da952642572330f9713282ea6fc06990a.yml +openapi_spec_hash: 7e0a9ea9ef3fad500e045c0c3bc69762 config_hash: ecd4e1fc35135b5e53487ca547e46fd7 From 6b8745c61d93490034a08690ca25080885ff4e3b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:31:00 +0000 Subject: [PATCH 033/125] feat(api): manual updates --- .stats.yml | 4 +- .../accounts/origins/OriginCreateParams.kt | 252 +++++++++--------- 2 files changed, 129 insertions(+), 127 deletions(-) diff --git a/.stats.yml b/.stats.yml index ba9b6e53..bdd3cece 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-a49c22a93734b90653ada66f9b336a7da952642572330f9713282ea6fc06990a.yml -openapi_spec_hash: 7e0a9ea9ef3fad500e045c0c3bc69762 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-76afc867b06fdc43b339f2c7d19f25a46481b25e8264ca24ea43daa1ea9234fc.yml +openapi_spec_hash: a1455d2ab02c48a14551362dd8ec2261 config_hash: ecd4e1fc35135b5e53487ca547e46fd7 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 3d1f7da0..3329192a 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 @@ -20,6 +20,7 @@ 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.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers @@ -28,7 +29,6 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams @@ -95,21 +95,13 @@ private constructor( /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) - /** - * Alias for calling [body] with the following: - * ```java - * Body.WebProxy.builder() - * .name(name) - * .build() - * ``` - */ - fun webProxyBody(name: String) = body(Body.WebProxy.builder().name(name).build()) + /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ + fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = + body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) - /** Alias for calling [body] with `Body.ofGcs(gcs)`. */ - fun body(gcs: Body.Gcs) = body(Body.ofGcs(gcs)) - - /** Alias for calling [body] with `Body.ofAzureBlob(azureBlob)`. */ - fun body(azureBlob: Body.AzureBlob) = body(Body.ofAzureBlob(azureBlob)) + /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ + fun body(azureBlobStorage: Body.AzureBlobStorage) = + body(Body.ofAzureBlobStorage(azureBlobStorage)) /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ fun body(akeneoPim: Body.AkeneoPim) = body(Body.ofAkeneoPim(akeneoPim)) @@ -248,8 +240,8 @@ private constructor( 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -264,9 +256,10 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun gcs(): Optional = Optional.ofNullable(gcs) + fun googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) - fun azureBlob(): Optional = Optional.ofNullable(azureBlob) + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -280,9 +273,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGcs(): Boolean = gcs != null + fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null - fun isAzureBlob(): Boolean = azureBlob != null + fun isAzureBlobStorage(): Boolean = azureBlobStorage != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -296,9 +289,10 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGcs(): Gcs = gcs.getOrThrow("gcs") + fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") - fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -311,8 +305,9 @@ private constructor( 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -346,12 +341,14 @@ private constructor( webProxy.validate() } - override fun visitGcs(gcs: Gcs) { - gcs.validate() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() } - override fun visitAzureBlob(azureBlob: AzureBlob) { - azureBlob.validate() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -392,9 +389,12 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGcs(gcs: Gcs) = gcs.validity() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() - override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -413,8 +413,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - gcs == other.gcs && - azureBlob == other.azureBlob && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && akeneoPim == other.akeneoPim } @@ -425,8 +425,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - gcs, - azureBlob, + googleCloudStorageGcs, + azureBlobStorage, akeneoPim, ) @@ -437,8 +437,9 @@ private constructor( cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "Body{webFolder=$webFolder}" webProxy != null -> "Body{webProxy=$webProxy}" - gcs != null -> "Body{gcs=$gcs}" - azureBlob != null -> "Body{azureBlob=$azureBlob}" + googleCloudStorageGcs != null -> + "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") @@ -459,9 +460,13 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) - @JvmStatic fun ofGcs(gcs: Gcs) = Body(gcs = gcs) + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + Body(googleCloudStorageGcs = googleCloudStorageGcs) - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Body(azureBlob = azureBlob) + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + Body(azureBlobStorage = azureBlobStorage) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) } @@ -479,9 +484,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGcs(gcs: Gcs): T + fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T - fun visitAzureBlob(azureBlob: AzureBlob): T + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -503,52 +508,47 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Body { val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3 = it, _json = json) - } ?: Body(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Compatible = it, _json = json) - } ?: Body(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackup = it, _json = json) - } ?: Body(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolder = it, _json = json) - } ?: Body(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxy = it, _json = json) - } ?: Body(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(gcs = it, _json = json) - } ?: Body(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlob = it, _json = json) - } ?: Body(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPim = it, _json = json) - } ?: Body(_json = json) - } + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPim = 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() } - - return Body(_json = json) } } @@ -565,8 +565,9 @@ private constructor( 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) value.akeneoPim != null -> generator.writeObject(value.akeneoPim) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") @@ -2775,7 +2776,7 @@ private constructor( "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class Gcs + class GoogleCloudStorageGcs private constructor( private val bucket: JsonField, private val clientEmail: JsonField, @@ -2961,7 +2962,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Gcs]. + * Returns a mutable builder for constructing an instance of + * [GoogleCloudStorageGcs]. * * The following fields are required: * ```java @@ -2974,7 +2976,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [Gcs]. */ + /** A builder for [GoogleCloudStorageGcs]. */ class Builder internal constructor() { private var bucket: JsonField? = null @@ -2988,16 +2990,16 @@ private constructor( 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() + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() } fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -3128,7 +3130,7 @@ private constructor( } /** - * Returns an immutable instance of [Gcs]. + * Returns an immutable instance of [GoogleCloudStorageGcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3142,8 +3144,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Gcs = - Gcs( + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), checkRequired("name", name), @@ -3158,7 +3160,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Gcs = apply { + fun validate(): GoogleCloudStorageGcs = apply { if (validated) { return@apply } @@ -3208,7 +3210,7 @@ private constructor( return true } - return other is Gcs && + return other is GoogleCloudStorageGcs && bucket == other.bucket && clientEmail == other.clientEmail && name == other.name && @@ -3237,10 +3239,10 @@ private constructor( 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}" + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlob + class AzureBlobStorage private constructor( private val accountName: JsonField, private val container: JsonField, @@ -3427,7 +3429,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlob]. + * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. * * The following fields are required: * ```java @@ -3440,7 +3442,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlob]. */ + /** A builder for [AzureBlobStorage]. */ class Builder internal constructor() { private var accountName: JsonField? = null @@ -3454,16 +3456,16 @@ private constructor( 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() + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() } fun accountName(accountName: String) = accountName(JsonField.of(accountName)) @@ -3592,7 +3594,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlob]. + * Returns an immutable instance of [AzureBlobStorage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3606,8 +3608,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlob = - AzureBlob( + fun build(): AzureBlobStorage = + AzureBlobStorage( checkRequired("accountName", accountName), checkRequired("container", container), checkRequired("name", name), @@ -3622,7 +3624,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlob = apply { + fun validate(): AzureBlobStorage = apply { if (validated) { return@apply } @@ -3672,7 +3674,7 @@ private constructor( return true } - return other is AzureBlob && + return other is AzureBlobStorage && accountName == other.accountName && container == other.container && name == other.name && @@ -3701,7 +3703,7 @@ private constructor( 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}" + "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim From 1573992cd2c6c7cbdc4874077d08a73be2b33c26 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:36:37 +0000 Subject: [PATCH 034/125] feat(api): manual updates --- .stats.yml | 4 +- .../accounts/origins/OriginCreateParams.kt | 2400 +++++++++++++---- .../accounts/origins/OriginUpdateParams.kt | 2399 ++++++++++++---- .../origins/OriginCreateParamsTest.kt | 65 +- .../origins/OriginUpdateParamsTest.kt | 76 +- .../async/accounts/OriginServiceAsyncTest.kt | 26 +- .../blocking/accounts/OriginServiceTest.kt | 26 +- 7 files changed, 3837 insertions(+), 1159 deletions(-) diff --git a/.stats.yml b/.stats.yml index bdd3cece..fbcd50b8 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-76afc867b06fdc43b339f2c7d19f25a46481b25e8264ca24ea43daa1ea9234fc.yml -openapi_spec_hash: a1455d2ab02c48a14551362dd8ec2261 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-4abcc684cb38a6caeb1d20789c3f42f050aa02a1e11cd15b56a758b269961368.yml +openapi_spec_hash: c197897c7befdd521213bdaabbf8b134 config_hash: ecd4e1fc35135b5e53487ca547e46fd7 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 3329192a..097f4f9b 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 @@ -15,6 +15,7 @@ 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 @@ -29,6 +30,7 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams @@ -79,32 +81,36 @@ private constructor( /** Schema for origin resources. */ fun body(body: Body) = apply { this.body = body } - /** Alias for calling [body] with `Body.ofS3(s3)`. */ - fun body(s3: Body.S3) = body(Body.ofS3(s3)) + /** Alias for calling [body] with `Body.ofS3Origin(s3Origin)`. */ + fun body(s3Origin: Body.S3Origin) = body(Body.ofS3Origin(s3Origin)) - /** Alias for calling [body] with `Body.ofS3Compatible(s3Compatible)`. */ - fun body(s3Compatible: Body.S3Compatible) = body(Body.ofS3Compatible(s3Compatible)) + /** Alias for calling [body] with `Body.ofS3CompatibleOrigin(s3CompatibleOrigin)`. */ + fun body(s3CompatibleOrigin: Body.S3CompatibleOrigin) = + body(Body.ofS3CompatibleOrigin(s3CompatibleOrigin)) - /** Alias for calling [body] with `Body.ofCloudinaryBackup(cloudinaryBackup)`. */ - fun body(cloudinaryBackup: Body.CloudinaryBackup) = - body(Body.ofCloudinaryBackup(cloudinaryBackup)) + /** + * Alias for calling [body] with `Body.ofCloudinaryBackupOrigin(cloudinaryBackupOrigin)`. + */ + fun body(cloudinaryBackupOrigin: Body.CloudinaryBackupOrigin) = + body(Body.ofCloudinaryBackupOrigin(cloudinaryBackupOrigin)) - /** Alias for calling [body] with `Body.ofWebFolder(webFolder)`. */ - fun body(webFolder: Body.WebFolder) = body(Body.ofWebFolder(webFolder)) + /** Alias for calling [body] with `Body.ofWebFolderOrigin(webFolderOrigin)`. */ + fun body(webFolderOrigin: Body.WebFolderOrigin) = + body(Body.ofWebFolderOrigin(webFolderOrigin)) - /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ - fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) + /** Alias for calling [body] with `Body.ofWebProxyOrigin(webProxyOrigin)`. */ + fun body(webProxyOrigin: Body.WebProxyOrigin) = body(Body.ofWebProxyOrigin(webProxyOrigin)) - /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ - fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = - body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + /** Alias for calling [body] with `Body.ofGcsOrigin(gcsOrigin)`. */ + fun body(gcsOrigin: Body.GcsOrigin) = body(Body.ofGcsOrigin(gcsOrigin)) - /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ - fun body(azureBlobStorage: Body.AzureBlobStorage) = - body(Body.ofAzureBlobStorage(azureBlobStorage)) + /** Alias for calling [body] with `Body.ofAzureBlobOrigin(azureBlobOrigin)`. */ + fun body(azureBlobOrigin: Body.AzureBlobOrigin) = + body(Body.ofAzureBlobOrigin(azureBlobOrigin)) - /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ - fun body(akeneoPim: Body.AkeneoPim) = body(Body.ofAkeneoPim(akeneoPim)) + /** Alias for calling [body] with `Body.ofAkeneoPimOrigin(akeneoPimOrigin)`. */ + fun body(akeneoPimOrigin: Body.AkeneoPimOrigin) = + body(Body.ofAkeneoPimOrigin(akeneoPimOrigin)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -235,80 +241,82 @@ private constructor( @JsonSerialize(using = Body.Serializer::class) class Body 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, - private val akeneoPim: AkeneoPim? = null, + private val s3Origin: S3Origin? = null, + private val s3CompatibleOrigin: S3CompatibleOrigin? = null, + private val cloudinaryBackupOrigin: CloudinaryBackupOrigin? = null, + private val webFolderOrigin: WebFolderOrigin? = null, + private val webProxyOrigin: WebProxyOrigin? = null, + private val gcsOrigin: GcsOrigin? = null, + private val azureBlobOrigin: AzureBlobOrigin? = null, + private val akeneoPimOrigin: AkeneoPimOrigin? = null, private val _json: JsonValue? = null, ) { - fun s3(): Optional = Optional.ofNullable(s3) + fun s3Origin(): Optional = Optional.ofNullable(s3Origin) - fun s3Compatible(): Optional = Optional.ofNullable(s3Compatible) + fun s3CompatibleOrigin(): Optional = + Optional.ofNullable(s3CompatibleOrigin) - fun cloudinaryBackup(): Optional = Optional.ofNullable(cloudinaryBackup) + fun cloudinaryBackupOrigin(): Optional = + Optional.ofNullable(cloudinaryBackupOrigin) - fun webFolder(): Optional = Optional.ofNullable(webFolder) + fun webFolderOrigin(): Optional = Optional.ofNullable(webFolderOrigin) - fun webProxy(): Optional = Optional.ofNullable(webProxy) + fun webProxyOrigin(): Optional = Optional.ofNullable(webProxyOrigin) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcsOrigin(): Optional = Optional.ofNullable(gcsOrigin) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlobOrigin(): Optional = Optional.ofNullable(azureBlobOrigin) - fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) + fun akeneoPimOrigin(): Optional = Optional.ofNullable(akeneoPimOrigin) - fun isS3(): Boolean = s3 != null + fun isS3Origin(): Boolean = s3Origin != null - fun isS3Compatible(): Boolean = s3Compatible != null + fun isS3CompatibleOrigin(): Boolean = s3CompatibleOrigin != null - fun isCloudinaryBackup(): Boolean = cloudinaryBackup != null + fun isCloudinaryBackupOrigin(): Boolean = cloudinaryBackupOrigin != null - fun isWebFolder(): Boolean = webFolder != null + fun isWebFolderOrigin(): Boolean = webFolderOrigin != null - fun isWebProxy(): Boolean = webProxy != null + fun isWebProxyOrigin(): Boolean = webProxyOrigin != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcsOrigin(): Boolean = gcsOrigin != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlobOrigin(): Boolean = azureBlobOrigin != null - fun isAkeneoPim(): Boolean = akeneoPim != null + fun isAkeneoPimOrigin(): Boolean = akeneoPimOrigin != null - fun asS3(): S3 = s3.getOrThrow("s3") + fun asS3Origin(): S3Origin = s3Origin.getOrThrow("s3Origin") - fun asS3Compatible(): S3Compatible = s3Compatible.getOrThrow("s3Compatible") + fun asS3CompatibleOrigin(): S3CompatibleOrigin = + s3CompatibleOrigin.getOrThrow("s3CompatibleOrigin") - fun asCloudinaryBackup(): CloudinaryBackup = cloudinaryBackup.getOrThrow("cloudinaryBackup") + fun asCloudinaryBackupOrigin(): CloudinaryBackupOrigin = + cloudinaryBackupOrigin.getOrThrow("cloudinaryBackupOrigin") - fun asWebFolder(): WebFolder = webFolder.getOrThrow("webFolder") + fun asWebFolderOrigin(): WebFolderOrigin = webFolderOrigin.getOrThrow("webFolderOrigin") - fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") + fun asWebProxyOrigin(): WebProxyOrigin = webProxyOrigin.getOrThrow("webProxyOrigin") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcsOrigin(): GcsOrigin = gcsOrigin.getOrThrow("gcsOrigin") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlobOrigin(): AzureBlobOrigin = azureBlobOrigin.getOrThrow("azureBlobOrigin") - fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") + fun asAkeneoPimOrigin(): AkeneoPimOrigin = akeneoPimOrigin.getOrThrow("akeneoPimOrigin") 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) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) - akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + s3Origin != null -> visitor.visitS3Origin(s3Origin) + s3CompatibleOrigin != null -> visitor.visitS3CompatibleOrigin(s3CompatibleOrigin) + cloudinaryBackupOrigin != null -> + visitor.visitCloudinaryBackupOrigin(cloudinaryBackupOrigin) + webFolderOrigin != null -> visitor.visitWebFolderOrigin(webFolderOrigin) + webProxyOrigin != null -> visitor.visitWebProxyOrigin(webProxyOrigin) + gcsOrigin != null -> visitor.visitGcsOrigin(gcsOrigin) + azureBlobOrigin != null -> visitor.visitAzureBlobOrigin(azureBlobOrigin) + akeneoPimOrigin != null -> visitor.visitAkeneoPimOrigin(akeneoPimOrigin) else -> visitor.unknown(_json) } @@ -321,38 +329,38 @@ private constructor( accept( object : Visitor { - override fun visitS3(s3: S3) { - s3.validate() + override fun visitS3Origin(s3Origin: S3Origin) { + s3Origin.validate() } - override fun visitS3Compatible(s3Compatible: S3Compatible) { - s3Compatible.validate() + override fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) { + s3CompatibleOrigin.validate() } - override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) { - cloudinaryBackup.validate() + override fun visitCloudinaryBackupOrigin( + cloudinaryBackupOrigin: CloudinaryBackupOrigin + ) { + cloudinaryBackupOrigin.validate() } - override fun visitWebFolder(webFolder: WebFolder) { - webFolder.validate() + override fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin) { + webFolderOrigin.validate() } - override fun visitWebProxy(webProxy: WebProxy) { - webProxy.validate() + override fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin) { + webProxyOrigin.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcsOrigin(gcsOrigin: GcsOrigin) { + gcsOrigin.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) { + azureBlobOrigin.validate() } - override fun visitAkeneoPim(akeneoPim: AkeneoPim) { - akeneoPim.validate() + override fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) { + akeneoPimOrigin.validate() } } ) @@ -377,26 +385,28 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitS3(s3: S3) = s3.validity() + override fun visitS3Origin(s3Origin: S3Origin) = s3Origin.validity() - override fun visitS3Compatible(s3Compatible: S3Compatible) = - s3Compatible.validity() + override fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) = + s3CompatibleOrigin.validity() - override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - cloudinaryBackup.validity() + override fun visitCloudinaryBackupOrigin( + cloudinaryBackupOrigin: CloudinaryBackupOrigin + ) = cloudinaryBackupOrigin.validity() - override fun visitWebFolder(webFolder: WebFolder) = webFolder.validity() + override fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin) = + webFolderOrigin.validity() - override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() + override fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin) = + webProxyOrigin.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcsOrigin(gcsOrigin: GcsOrigin) = gcsOrigin.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) = + azureBlobOrigin.validity() - override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() + override fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) = + akeneoPimOrigin.validity() override fun unknown(json: JsonValue?) = 0 } @@ -408,87 +418,92 @@ private constructor( } return other is Body && - s3 == other.s3 && - s3Compatible == other.s3Compatible && - cloudinaryBackup == other.cloudinaryBackup && - webFolder == other.webFolder && - webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && - akeneoPim == other.akeneoPim + s3Origin == other.s3Origin && + s3CompatibleOrigin == other.s3CompatibleOrigin && + cloudinaryBackupOrigin == other.cloudinaryBackupOrigin && + webFolderOrigin == other.webFolderOrigin && + webProxyOrigin == other.webProxyOrigin && + gcsOrigin == other.gcsOrigin && + azureBlobOrigin == other.azureBlobOrigin && + akeneoPimOrigin == other.akeneoPimOrigin } override fun hashCode(): Int = Objects.hash( - s3, - s3Compatible, - cloudinaryBackup, - webFolder, - webProxy, - googleCloudStorageGcs, - azureBlobStorage, - akeneoPim, + s3Origin, + s3CompatibleOrigin, + cloudinaryBackupOrigin, + webFolderOrigin, + webProxyOrigin, + gcsOrigin, + azureBlobOrigin, + akeneoPimOrigin, ) override fun toString(): String = when { - s3 != null -> "Body{s3=$s3}" - s3Compatible != null -> "Body{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "Body{webFolder=$webFolder}" - webProxy != null -> "Body{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" - akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" + s3Origin != null -> "Body{s3Origin=$s3Origin}" + s3CompatibleOrigin != null -> "Body{s3CompatibleOrigin=$s3CompatibleOrigin}" + cloudinaryBackupOrigin != null -> + "Body{cloudinaryBackupOrigin=$cloudinaryBackupOrigin}" + webFolderOrigin != null -> "Body{webFolderOrigin=$webFolderOrigin}" + webProxyOrigin != null -> "Body{webProxyOrigin=$webProxyOrigin}" + gcsOrigin != null -> "Body{gcsOrigin=$gcsOrigin}" + azureBlobOrigin != null -> "Body{azureBlobOrigin=$azureBlobOrigin}" + akeneoPimOrigin != null -> "Body{akeneoPimOrigin=$akeneoPimOrigin}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") } companion object { - @JvmStatic fun ofS3(s3: S3) = Body(s3 = s3) + @JvmStatic fun ofS3Origin(s3Origin: S3Origin) = Body(s3Origin = s3Origin) @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = Body(s3Compatible = s3Compatible) + fun ofS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) = + Body(s3CompatibleOrigin = s3CompatibleOrigin) @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - Body(cloudinaryBackup = cloudinaryBackup) + fun ofCloudinaryBackupOrigin(cloudinaryBackupOrigin: CloudinaryBackupOrigin) = + Body(cloudinaryBackupOrigin = cloudinaryBackupOrigin) - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Body(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) + @JvmStatic + fun ofWebFolderOrigin(webFolderOrigin: WebFolderOrigin) = + Body(webFolderOrigin = webFolderOrigin) @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - Body(googleCloudStorageGcs = googleCloudStorageGcs) + fun ofWebProxyOrigin(webProxyOrigin: WebProxyOrigin) = + Body(webProxyOrigin = webProxyOrigin) + + @JvmStatic fun ofGcsOrigin(gcsOrigin: GcsOrigin) = Body(gcsOrigin = gcsOrigin) @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - Body(azureBlobStorage = azureBlobStorage) + fun ofAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) = + Body(azureBlobOrigin = azureBlobOrigin) - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) + @JvmStatic + fun ofAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) = + Body(akeneoPimOrigin = akeneoPimOrigin) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ interface Visitor { - fun visitS3(s3: S3): T + fun visitS3Origin(s3Origin: S3Origin): T - fun visitS3Compatible(s3Compatible: S3Compatible): T + fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin): T - fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup): T + fun visitCloudinaryBackupOrigin(cloudinaryBackupOrigin: CloudinaryBackupOrigin): T - fun visitWebFolder(webFolder: WebFolder): T + fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin): T - fun visitWebProxy(webProxy: WebProxy): T + fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcsOrigin(gcsOrigin: GcsOrigin): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin): T - fun visitAkeneoPim(akeneoPim: AkeneoPim): T + fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin): T /** * Maps an unknown variant of [Body] to a value of type [T]. @@ -508,32 +523,35 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Body { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) {} val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3 = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Origin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Compatible = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3CompatibleOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackup = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackupOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolder = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolderOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxy = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxyOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(googleCloudStorageGcs = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(gcsOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlobStorage = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlobOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPim = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPimOrigin = it, _json = json) }, ) .filterNotNull() @@ -560,28 +578,29 @@ private constructor( 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.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) - value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value.s3Origin != null -> generator.writeObject(value.s3Origin) + value.s3CompatibleOrigin != null -> + generator.writeObject(value.s3CompatibleOrigin) + value.cloudinaryBackupOrigin != null -> + generator.writeObject(value.cloudinaryBackupOrigin) + value.webFolderOrigin != null -> generator.writeObject(value.webFolderOrigin) + value.webProxyOrigin != null -> generator.writeObject(value.webProxyOrigin) + value.gcsOrigin != null -> generator.writeObject(value.gcsOrigin) + value.azureBlobOrigin != null -> generator.writeObject(value.azureBlobOrigin) + value.akeneoPimOrigin != null -> generator.writeObject(value.akeneoPimOrigin) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") } } } - class S3 + class S3Origin private constructor( private val accessKey: JsonField, private val bucket: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -600,7 +619,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -657,15 +676,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -727,6 +742,13 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -769,7 +791,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [S3]. + * Returns a mutable builder for constructing an instance of [S3Origin]. * * The following fields are required: * ```java @@ -777,35 +799,36 @@ private constructor( * .bucket() * .name() * .secretKey() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [S3]. */ + /** A builder for [S3Origin]. */ 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 type: JsonField? = null 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() + internal fun from(s3Origin: S3Origin) = apply { + accessKey = s3Origin.accessKey + bucket = s3Origin.bucket + name = s3Origin.name + secretKey = s3Origin.secretKey + type = s3Origin.type + baseUrlForCanonicalHeader = s3Origin.baseUrlForCanonicalHeader + includeCanonicalHeader = s3Origin.includeCanonicalHeader + prefix = s3Origin.prefix + additionalProperties = s3Origin.additionalProperties.toMutableMap() } /** Access key for the bucket. */ @@ -856,19 +879,16 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun type(type: Type) = type(JsonField.of(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("S3") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -936,7 +956,7 @@ private constructor( } /** - * Returns an immutable instance of [S3]. + * Returns an immutable instance of [S3Origin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -946,17 +966,18 @@ private constructor( * .bucket() * .name() * .secretKey() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): S3 = - S3( + fun build(): S3Origin = + S3Origin( checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("name", name), checkRequired("secretKey", secretKey), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -966,7 +987,7 @@ private constructor( private var validated: Boolean = false - fun validate(): S3 = apply { + fun validate(): S3Origin = apply { if (validated) { return@apply } @@ -975,11 +996,7 @@ private constructor( bucket() name() secretKey() - _type().let { - if (it != JsonValue.from("S3")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1006,17 +1023,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + 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 S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 S3 && + return other is S3Origin && accessKey == other.accessKey && bucket == other.bucket && name == other.name && @@ -1045,17 +1228,17 @@ private constructor( 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}" + "S3Origin{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class S3Compatible + class S3CompatibleOrigin 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 type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1078,7 +1261,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1151,15 +1334,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -1238,6 +1417,13 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -1290,7 +1476,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [S3Compatible]. + * Returns a mutable builder for constructing an instance of [S3CompatibleOrigin]. * * The following fields are required: * ```java @@ -1299,12 +1485,13 @@ private constructor( * .endpoint() * .name() * .secretKey() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [S3Compatible]. */ + /** A builder for [S3CompatibleOrigin]. */ class Builder internal constructor() { private var accessKey: JsonField? = null @@ -1312,7 +1499,7 @@ private constructor( 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 type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var prefix: JsonField = JsonMissing.of() @@ -1320,18 +1507,18 @@ private constructor( 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() + internal fun from(s3CompatibleOrigin: S3CompatibleOrigin) = apply { + accessKey = s3CompatibleOrigin.accessKey + bucket = s3CompatibleOrigin.bucket + endpoint = s3CompatibleOrigin.endpoint + name = s3CompatibleOrigin.name + secretKey = s3CompatibleOrigin.secretKey + type = s3CompatibleOrigin.type + baseUrlForCanonicalHeader = s3CompatibleOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = s3CompatibleOrigin.includeCanonicalHeader + prefix = s3CompatibleOrigin.prefix + s3ForcePathStyle = s3CompatibleOrigin.s3ForcePathStyle + additionalProperties = s3CompatibleOrigin.additionalProperties.toMutableMap() } /** Access key for the bucket. */ @@ -1394,19 +1581,16 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun type(type: Type) = type(JsonField.of(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("S3_COMPATIBLE") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1489,7 +1673,7 @@ private constructor( } /** - * Returns an immutable instance of [S3Compatible]. + * Returns an immutable instance of [S3CompatibleOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -1500,18 +1684,19 @@ private constructor( * .endpoint() * .name() * .secretKey() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): S3Compatible = - S3Compatible( + fun build(): S3CompatibleOrigin = + S3CompatibleOrigin( checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), checkRequired("name", name), checkRequired("secretKey", secretKey), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1522,7 +1707,7 @@ private constructor( private var validated: Boolean = false - fun validate(): S3Compatible = apply { + fun validate(): S3CompatibleOrigin = apply { if (validated) { return@apply } @@ -1532,11 +1717,7 @@ private constructor( endpoint() name() secretKey() - _type().let { - if (it != JsonValue.from("S3_COMPATIBLE")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1565,18 +1746,184 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 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) + 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 S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val S3 = of("S3") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3_COMPATIBLE, + S3, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + S3_COMPATIBLE, + S3, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + S3_COMPATIBLE -> Value.S3_COMPATIBLE + S3 -> Value.S3 + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3_COMPATIBLE -> Known.S3_COMPATIBLE + S3 -> Known.S3 + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 S3Compatible && + return other is S3CompatibleOrigin && accessKey == other.accessKey && bucket == other.bucket && endpoint == other.endpoint && @@ -1609,16 +1956,16 @@ private constructor( 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}" + "S3CompatibleOrigin{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" } - class CloudinaryBackup + class CloudinaryBackupOrigin private constructor( private val accessKey: JsonField, private val bucket: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1637,7 +1984,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1694,15 +2041,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -1764,6 +2107,13 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -1806,7 +2156,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CloudinaryBackup]. + * Returns a mutable builder for constructing an instance of + * [CloudinaryBackupOrigin]. * * The following fields are required: * ```java @@ -1814,35 +2165,37 @@ private constructor( * .bucket() * .name() * .secretKey() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CloudinaryBackup]. */ + /** A builder for [CloudinaryBackupOrigin]. */ 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 type: JsonField? = null 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() + internal fun from(cloudinaryBackupOrigin: CloudinaryBackupOrigin) = apply { + accessKey = cloudinaryBackupOrigin.accessKey + bucket = cloudinaryBackupOrigin.bucket + name = cloudinaryBackupOrigin.name + secretKey = cloudinaryBackupOrigin.secretKey + type = cloudinaryBackupOrigin.type + baseUrlForCanonicalHeader = cloudinaryBackupOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = cloudinaryBackupOrigin.includeCanonicalHeader + prefix = cloudinaryBackupOrigin.prefix + additionalProperties = + cloudinaryBackupOrigin.additionalProperties.toMutableMap() } /** Access key for the bucket. */ @@ -1893,19 +2246,16 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun type(type: Type) = type(JsonField.of(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("CLOUDINARY_BACKUP") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1973,7 +2323,7 @@ private constructor( } /** - * Returns an immutable instance of [CloudinaryBackup]. + * Returns an immutable instance of [CloudinaryBackupOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -1983,17 +2333,18 @@ private constructor( * .bucket() * .name() * .secretKey() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CloudinaryBackup = - CloudinaryBackup( + fun build(): CloudinaryBackupOrigin = + CloudinaryBackupOrigin( checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("name", name), checkRequired("secretKey", secretKey), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -2003,7 +2354,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CloudinaryBackup = apply { + fun validate(): CloudinaryBackupOrigin = apply { if (validated) { return@apply } @@ -2012,11 +2363,7 @@ private constructor( bucket() name() secretKey() - _type().let { - if (it != JsonValue.from("CLOUDINARY_BACKUP")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -2043,17 +2390,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY_BACKUP, + S3, + S3_COMPATIBLE, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + CLOUDINARY_BACKUP, + S3, + S3_COMPATIBLE, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 CloudinaryBackup && + return other is CloudinaryBackupOrigin && accessKey == other.accessKey && bucket == other.bucket && name == other.name && @@ -2082,14 +2595,14 @@ private constructor( 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}" + "CloudinaryBackupOrigin{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class WebFolder + class WebFolderOrigin private constructor( private val baseUrl: JsonField, private val name: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, @@ -2102,7 +2615,7 @@ private constructor( @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2141,15 +2654,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -2192,6 +2701,13 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2237,37 +2753,38 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [WebFolder]. + * Returns a mutable builder for constructing an instance of [WebFolderOrigin]. * * The following fields are required: * ```java * .baseUrl() * .name() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [WebFolder]. */ + /** A builder for [WebFolderOrigin]. */ class Builder internal constructor() { private var baseUrl: JsonField? = null private var name: JsonField? = null - private var type: JsonValue = JsonValue.from("WEB_FOLDER") + private var type: JsonField? = null 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() + internal fun from(webFolderOrigin: WebFolderOrigin) = apply { + baseUrl = webFolderOrigin.baseUrl + name = webFolderOrigin.name + type = webFolderOrigin.type + baseUrlForCanonicalHeader = webFolderOrigin.baseUrlForCanonicalHeader + forwardHostHeaderToOrigin = webFolderOrigin.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolderOrigin.includeCanonicalHeader + additionalProperties = webFolderOrigin.additionalProperties.toMutableMap() } /** Root URL for the web folder origin. */ @@ -2294,19 +2811,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(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("WEB_FOLDER") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2378,7 +2892,7 @@ private constructor( } /** - * Returns an immutable instance of [WebFolder]. + * Returns an immutable instance of [WebFolderOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2386,15 +2900,16 @@ private constructor( * ```java * .baseUrl() * .name() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): WebFolder = - WebFolder( + fun build(): WebFolderOrigin = + WebFolderOrigin( checkRequired("baseUrl", baseUrl), checkRequired("name", name), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, forwardHostHeaderToOrigin, includeCanonicalHeader, @@ -2404,18 +2919,14 @@ private constructor( private var validated: Boolean = false - fun validate(): WebFolder = apply { + fun validate(): WebFolderOrigin = apply { if (validated) { return@apply } baseUrl() name() - _type().let { - if (it != JsonValue.from("WEB_FOLDER")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() forwardHostHeaderToOrigin() includeCanonicalHeader() @@ -2440,27 +2951,193 @@ private constructor( 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 } + + (type.asKnown().getOrNull()?.validity() ?: 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 - } + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { - 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 - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { + companion object { + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_FOLDER, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + WEB_FOLDER, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + WEB_FOLDER -> Value.WEB_FOLDER + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_FOLDER -> Known.WEB_FOLDER + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 WebFolderOrigin && + 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, @@ -2475,13 +3152,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebFolderOrigin{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class WebProxy + class WebProxyOrigin private constructor( private val name: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -2490,7 +3167,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2509,15 +3186,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -2544,6 +3217,13 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2579,32 +3259,33 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [WebProxy]. + * Returns a mutable builder for constructing an instance of [WebProxyOrigin]. * * The following fields are required: * ```java * .name() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [WebProxy]. */ + /** A builder for [WebProxyOrigin]. */ class Builder internal constructor() { private var name: JsonField? = null - private var type: JsonValue = JsonValue.from("WEB_PROXY") + private var type: JsonField? = null 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() + internal fun from(webProxyOrigin: WebProxyOrigin) = apply { + name = webProxyOrigin.name + type = webProxyOrigin.type + baseUrlForCanonicalHeader = webProxyOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = webProxyOrigin.includeCanonicalHeader + additionalProperties = webProxyOrigin.additionalProperties.toMutableMap() } /** Display name of the origin. */ @@ -2619,19 +3300,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(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("WEB_PROXY") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2687,21 +3365,22 @@ private constructor( } /** - * Returns an immutable instance of [WebProxy]. + * Returns an immutable instance of [WebProxyOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .name() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): WebProxy = - WebProxy( + fun build(): WebProxyOrigin = + WebProxyOrigin( checkRequired("name", name), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, additionalProperties.toMutableMap(), @@ -2710,17 +3389,13 @@ private constructor( private var validated: Boolean = false - fun validate(): WebProxy = apply { + fun validate(): WebProxyOrigin = apply { if (validated) { return@apply } name() - _type().let { - if (it != JsonValue.from("WEB_PROXY")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() validated = true @@ -2743,16 +3418,182 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + 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 WEB_PROXY = of("WEB_PROXY") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_PROXY, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + WEB_PROXY, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + WEB_PROXY -> Value.WEB_PROXY + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_PROXY -> Known.WEB_PROXY + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 WebProxy && + return other is WebProxyOrigin && name == other.name && type == other.type && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && @@ -2773,16 +3614,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxyOrigin{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class GcsOrigin private constructor( private val bucket: JsonField, private val clientEmail: JsonField, private val name: JsonField, private val privateKey: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -2801,7 +3642,7 @@ private constructor( @JsonProperty("privateKey") @ExcludeMissing privateKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2852,15 +3693,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -2920,6 +3757,13 @@ private constructor( @ExcludeMissing fun _privateKey(): JsonField = privateKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -2962,8 +3806,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [GcsOrigin]. * * The following fields are required: * ```java @@ -2971,35 +3814,36 @@ private constructor( * .clientEmail() * .name() * .privateKey() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [GcsOrigin]. */ 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 type: JsonField? = null 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + internal fun from(gcsOrigin: GcsOrigin) = apply { + bucket = gcsOrigin.bucket + clientEmail = gcsOrigin.clientEmail + name = gcsOrigin.name + privateKey = gcsOrigin.privateKey + type = gcsOrigin.type + baseUrlForCanonicalHeader = gcsOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = gcsOrigin.includeCanonicalHeader + prefix = gcsOrigin.prefix + additionalProperties = gcsOrigin.additionalProperties.toMutableMap() } fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -3051,19 +3895,16 @@ private constructor( this.privateKey = privateKey } + fun type(type: Type) = type(JsonField.of(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("GCS") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3130,7 +3971,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [GcsOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3140,17 +3981,18 @@ private constructor( * .clientEmail() * .name() * .privateKey() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): GcsOrigin = + GcsOrigin( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), checkRequired("name", name), checkRequired("privateKey", privateKey), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3160,7 +4002,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): GcsOrigin = apply { if (validated) { return@apply } @@ -3169,11 +4011,7 @@ private constructor( clientEmail() name() privateKey() - _type().let { - if (it != JsonValue.from("GCS")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -3200,17 +4038,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + 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 GCS = of("GCS") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GCS, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + GCS, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + GCS -> Value.GCS + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GCS -> Known.GCS + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 GoogleCloudStorageGcs && + return other is GcsOrigin && bucket == other.bucket && clientEmail == other.clientEmail && name == other.name && @@ -3239,16 +4243,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "GcsOrigin{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlobOrigin private constructor( private val accountName: JsonField, private val container: JsonField, private val name: JsonField, private val sasToken: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -3267,7 +4271,7 @@ private constructor( @JsonProperty("sasToken") @ExcludeMissing sasToken: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3318,15 +4322,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -3387,6 +4387,13 @@ private constructor( */ @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -3429,7 +4436,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlobOrigin]. * * The following fields are required: * ```java @@ -3437,35 +4444,36 @@ private constructor( * .container() * .name() * .sasToken() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlobOrigin]. */ 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 type: JsonField? = null 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(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + internal fun from(azureBlobOrigin: AzureBlobOrigin) = apply { + accountName = azureBlobOrigin.accountName + container = azureBlobOrigin.container + name = azureBlobOrigin.name + sasToken = azureBlobOrigin.sasToken + type = azureBlobOrigin.type + baseUrlForCanonicalHeader = azureBlobOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobOrigin.includeCanonicalHeader + prefix = azureBlobOrigin.prefix + additionalProperties = azureBlobOrigin.additionalProperties.toMutableMap() } fun accountName(accountName: String) = accountName(JsonField.of(accountName)) @@ -3515,19 +4523,16 @@ private constructor( */ fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + fun type(type: Type) = type(JsonField.of(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("AZURE_BLOB") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3594,7 +4599,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlobOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3604,17 +4609,18 @@ private constructor( * .container() * .name() * .sasToken() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlobOrigin = + AzureBlobOrigin( checkRequired("accountName", accountName), checkRequired("container", container), checkRequired("name", name), checkRequired("sasToken", sasToken), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3624,7 +4630,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlobOrigin = apply { if (validated) { return@apply } @@ -3633,11 +4639,7 @@ private constructor( container() name() sasToken() - _type().let { - if (it != JsonValue.from("AZURE_BLOB")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -3664,17 +4666,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + 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 AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AZURE_BLOB, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AKENEO_PIM, + } + + /** + * 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 { + AZURE_BLOB, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AKENEO_PIM, + /** + * 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) { + AZURE_BLOB -> Value.AZURE_BLOB + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AZURE_BLOB -> Known.AZURE_BLOB + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AKENEO_PIM -> Known.AKENEO_PIM + 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 AzureBlobStorage && + return other is AzureBlobOrigin && accountName == other.accountName && container == other.container && name == other.name && @@ -3703,17 +4871,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "AzureBlobOrigin{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AkeneoPim + class AkeneoPimOrigin 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 type: JsonField, private val username: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, @@ -3735,7 +4903,7 @@ private constructor( @JsonProperty("password") @ExcludeMissing password: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), @@ -3804,15 +4972,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * Akeneo API username. @@ -3881,6 +5045,13 @@ private constructor( */ @JsonProperty("password") @ExcludeMissing fun _password(): JsonField = password + /** + * 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 [username]. * @@ -3924,7 +5095,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AkeneoPim]. + * Returns a mutable builder for constructing an instance of [AkeneoPimOrigin]. * * The following fields are required: * ```java @@ -3933,13 +5104,14 @@ private constructor( * .clientSecret() * .name() * .password() + * .type() * .username() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AkeneoPim]. */ + /** A builder for [AkeneoPimOrigin]. */ class Builder internal constructor() { private var baseUrl: JsonField? = null @@ -3947,24 +5119,24 @@ private constructor( 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 type: JsonField? = null 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() + internal fun from(akeneoPimOrigin: AkeneoPimOrigin) = apply { + baseUrl = akeneoPimOrigin.baseUrl + clientId = akeneoPimOrigin.clientId + clientSecret = akeneoPimOrigin.clientSecret + name = akeneoPimOrigin.name + password = akeneoPimOrigin.password + type = akeneoPimOrigin.type + username = akeneoPimOrigin.username + baseUrlForCanonicalHeader = akeneoPimOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = akeneoPimOrigin.includeCanonicalHeader + additionalProperties = akeneoPimOrigin.additionalProperties.toMutableMap() } /** Akeneo instance base URL. */ @@ -4029,19 +5201,16 @@ private constructor( */ fun password(password: JsonField) = apply { this.password = password } + fun type(type: Type) = type(JsonField.of(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("AKENEO_PIM") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** Akeneo API username. */ fun username(username: String) = username(JsonField.of(username)) @@ -4109,7 +5278,7 @@ private constructor( } /** - * Returns an immutable instance of [AkeneoPim]. + * Returns an immutable instance of [AkeneoPimOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4120,19 +5289,20 @@ private constructor( * .clientSecret() * .name() * .password() + * .type() * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AkeneoPim = - AkeneoPim( + fun build(): AkeneoPimOrigin = + AkeneoPimOrigin( checkRequired("baseUrl", baseUrl), checkRequired("clientId", clientId), checkRequired("clientSecret", clientSecret), checkRequired("name", name), checkRequired("password", password), - type, + checkRequired("type", type), checkRequired("username", username), baseUrlForCanonicalHeader, includeCanonicalHeader, @@ -4142,7 +5312,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AkeneoPim = apply { + fun validate(): AkeneoPimOrigin = apply { if (validated) { return@apply } @@ -4152,11 +5322,7 @@ private constructor( clientSecret() name() password() - _type().let { - if (it != JsonValue.from("AKENEO_PIM")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() username() baseUrlForCanonicalHeader() includeCanonicalHeader() @@ -4184,17 +5350,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (username.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + 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 AKENEO_PIM = of("AKENEO_PIM") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKENEO_PIM, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + } + + /** + * 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 { + AKENEO_PIM, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + /** + * 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) { + AKENEO_PIM -> Value.AKENEO_PIM + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKENEO_PIM -> Known.AKENEO_PIM + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + 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 AkeneoPim && + return other is AkeneoPimOrigin && baseUrl == other.baseUrl && clientId == other.clientId && clientSecret == other.clientSecret && @@ -4225,7 +5557,7 @@ private constructor( 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}" + "AkeneoPimOrigin{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/OriginUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt index 4f23d963..7ca71491 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 @@ -15,6 +15,7 @@ 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 @@ -100,32 +101,36 @@ private constructor( /** Schema for origin resources. */ fun body(body: Body) = apply { this.body = body } - /** Alias for calling [body] with `Body.ofS3(s3)`. */ - fun body(s3: Body.S3) = body(Body.ofS3(s3)) + /** Alias for calling [body] with `Body.ofS3Origin(s3Origin)`. */ + fun body(s3Origin: Body.S3Origin) = body(Body.ofS3Origin(s3Origin)) - /** Alias for calling [body] with `Body.ofS3Compatible(s3Compatible)`. */ - fun body(s3Compatible: Body.S3Compatible) = body(Body.ofS3Compatible(s3Compatible)) + /** Alias for calling [body] with `Body.ofS3CompatibleOrigin(s3CompatibleOrigin)`. */ + fun body(s3CompatibleOrigin: Body.S3CompatibleOrigin) = + body(Body.ofS3CompatibleOrigin(s3CompatibleOrigin)) - /** Alias for calling [body] with `Body.ofCloudinaryBackup(cloudinaryBackup)`. */ - fun body(cloudinaryBackup: Body.CloudinaryBackup) = - body(Body.ofCloudinaryBackup(cloudinaryBackup)) + /** + * Alias for calling [body] with `Body.ofCloudinaryBackupOrigin(cloudinaryBackupOrigin)`. + */ + fun body(cloudinaryBackupOrigin: Body.CloudinaryBackupOrigin) = + body(Body.ofCloudinaryBackupOrigin(cloudinaryBackupOrigin)) - /** Alias for calling [body] with `Body.ofWebFolder(webFolder)`. */ - fun body(webFolder: Body.WebFolder) = body(Body.ofWebFolder(webFolder)) + /** Alias for calling [body] with `Body.ofWebFolderOrigin(webFolderOrigin)`. */ + fun body(webFolderOrigin: Body.WebFolderOrigin) = + body(Body.ofWebFolderOrigin(webFolderOrigin)) - /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ - fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) + /** Alias for calling [body] with `Body.ofWebProxyOrigin(webProxyOrigin)`. */ + fun body(webProxyOrigin: Body.WebProxyOrigin) = body(Body.ofWebProxyOrigin(webProxyOrigin)) - /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ - fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = - body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + /** Alias for calling [body] with `Body.ofGcsOrigin(gcsOrigin)`. */ + fun body(gcsOrigin: Body.GcsOrigin) = body(Body.ofGcsOrigin(gcsOrigin)) - /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ - fun body(azureBlobStorage: Body.AzureBlobStorage) = - body(Body.ofAzureBlobStorage(azureBlobStorage)) + /** Alias for calling [body] with `Body.ofAzureBlobOrigin(azureBlobOrigin)`. */ + fun body(azureBlobOrigin: Body.AzureBlobOrigin) = + body(Body.ofAzureBlobOrigin(azureBlobOrigin)) - /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ - fun body(akeneoPim: Body.AkeneoPim) = body(Body.ofAkeneoPim(akeneoPim)) + /** Alias for calling [body] with `Body.ofAkeneoPimOrigin(akeneoPimOrigin)`. */ + fun body(akeneoPimOrigin: Body.AkeneoPimOrigin) = + body(Body.ofAkeneoPimOrigin(akeneoPimOrigin)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -263,80 +268,82 @@ private constructor( @JsonSerialize(using = Body.Serializer::class) class Body 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, - private val akeneoPim: AkeneoPim? = null, + private val s3Origin: S3Origin? = null, + private val s3CompatibleOrigin: S3CompatibleOrigin? = null, + private val cloudinaryBackupOrigin: CloudinaryBackupOrigin? = null, + private val webFolderOrigin: WebFolderOrigin? = null, + private val webProxyOrigin: WebProxyOrigin? = null, + private val gcsOrigin: GcsOrigin? = null, + private val azureBlobOrigin: AzureBlobOrigin? = null, + private val akeneoPimOrigin: AkeneoPimOrigin? = null, private val _json: JsonValue? = null, ) { - fun s3(): Optional = Optional.ofNullable(s3) + fun s3Origin(): Optional = Optional.ofNullable(s3Origin) - fun s3Compatible(): Optional = Optional.ofNullable(s3Compatible) + fun s3CompatibleOrigin(): Optional = + Optional.ofNullable(s3CompatibleOrigin) - fun cloudinaryBackup(): Optional = Optional.ofNullable(cloudinaryBackup) + fun cloudinaryBackupOrigin(): Optional = + Optional.ofNullable(cloudinaryBackupOrigin) - fun webFolder(): Optional = Optional.ofNullable(webFolder) + fun webFolderOrigin(): Optional = Optional.ofNullable(webFolderOrigin) - fun webProxy(): Optional = Optional.ofNullable(webProxy) + fun webProxyOrigin(): Optional = Optional.ofNullable(webProxyOrigin) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcsOrigin(): Optional = Optional.ofNullable(gcsOrigin) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlobOrigin(): Optional = Optional.ofNullable(azureBlobOrigin) - fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) + fun akeneoPimOrigin(): Optional = Optional.ofNullable(akeneoPimOrigin) - fun isS3(): Boolean = s3 != null + fun isS3Origin(): Boolean = s3Origin != null - fun isS3Compatible(): Boolean = s3Compatible != null + fun isS3CompatibleOrigin(): Boolean = s3CompatibleOrigin != null - fun isCloudinaryBackup(): Boolean = cloudinaryBackup != null + fun isCloudinaryBackupOrigin(): Boolean = cloudinaryBackupOrigin != null - fun isWebFolder(): Boolean = webFolder != null + fun isWebFolderOrigin(): Boolean = webFolderOrigin != null - fun isWebProxy(): Boolean = webProxy != null + fun isWebProxyOrigin(): Boolean = webProxyOrigin != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcsOrigin(): Boolean = gcsOrigin != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlobOrigin(): Boolean = azureBlobOrigin != null - fun isAkeneoPim(): Boolean = akeneoPim != null + fun isAkeneoPimOrigin(): Boolean = akeneoPimOrigin != null - fun asS3(): S3 = s3.getOrThrow("s3") + fun asS3Origin(): S3Origin = s3Origin.getOrThrow("s3Origin") - fun asS3Compatible(): S3Compatible = s3Compatible.getOrThrow("s3Compatible") + fun asS3CompatibleOrigin(): S3CompatibleOrigin = + s3CompatibleOrigin.getOrThrow("s3CompatibleOrigin") - fun asCloudinaryBackup(): CloudinaryBackup = cloudinaryBackup.getOrThrow("cloudinaryBackup") + fun asCloudinaryBackupOrigin(): CloudinaryBackupOrigin = + cloudinaryBackupOrigin.getOrThrow("cloudinaryBackupOrigin") - fun asWebFolder(): WebFolder = webFolder.getOrThrow("webFolder") + fun asWebFolderOrigin(): WebFolderOrigin = webFolderOrigin.getOrThrow("webFolderOrigin") - fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") + fun asWebProxyOrigin(): WebProxyOrigin = webProxyOrigin.getOrThrow("webProxyOrigin") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcsOrigin(): GcsOrigin = gcsOrigin.getOrThrow("gcsOrigin") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlobOrigin(): AzureBlobOrigin = azureBlobOrigin.getOrThrow("azureBlobOrigin") - fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") + fun asAkeneoPimOrigin(): AkeneoPimOrigin = akeneoPimOrigin.getOrThrow("akeneoPimOrigin") 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) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) - akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + s3Origin != null -> visitor.visitS3Origin(s3Origin) + s3CompatibleOrigin != null -> visitor.visitS3CompatibleOrigin(s3CompatibleOrigin) + cloudinaryBackupOrigin != null -> + visitor.visitCloudinaryBackupOrigin(cloudinaryBackupOrigin) + webFolderOrigin != null -> visitor.visitWebFolderOrigin(webFolderOrigin) + webProxyOrigin != null -> visitor.visitWebProxyOrigin(webProxyOrigin) + gcsOrigin != null -> visitor.visitGcsOrigin(gcsOrigin) + azureBlobOrigin != null -> visitor.visitAzureBlobOrigin(azureBlobOrigin) + akeneoPimOrigin != null -> visitor.visitAkeneoPimOrigin(akeneoPimOrigin) else -> visitor.unknown(_json) } @@ -349,38 +356,38 @@ private constructor( accept( object : Visitor { - override fun visitS3(s3: S3) { - s3.validate() + override fun visitS3Origin(s3Origin: S3Origin) { + s3Origin.validate() } - override fun visitS3Compatible(s3Compatible: S3Compatible) { - s3Compatible.validate() + override fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) { + s3CompatibleOrigin.validate() } - override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) { - cloudinaryBackup.validate() + override fun visitCloudinaryBackupOrigin( + cloudinaryBackupOrigin: CloudinaryBackupOrigin + ) { + cloudinaryBackupOrigin.validate() } - override fun visitWebFolder(webFolder: WebFolder) { - webFolder.validate() + override fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin) { + webFolderOrigin.validate() } - override fun visitWebProxy(webProxy: WebProxy) { - webProxy.validate() + override fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin) { + webProxyOrigin.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcsOrigin(gcsOrigin: GcsOrigin) { + gcsOrigin.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) { + azureBlobOrigin.validate() } - override fun visitAkeneoPim(akeneoPim: AkeneoPim) { - akeneoPim.validate() + override fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) { + akeneoPimOrigin.validate() } } ) @@ -405,26 +412,28 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitS3(s3: S3) = s3.validity() + override fun visitS3Origin(s3Origin: S3Origin) = s3Origin.validity() - override fun visitS3Compatible(s3Compatible: S3Compatible) = - s3Compatible.validity() + override fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) = + s3CompatibleOrigin.validity() - override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - cloudinaryBackup.validity() + override fun visitCloudinaryBackupOrigin( + cloudinaryBackupOrigin: CloudinaryBackupOrigin + ) = cloudinaryBackupOrigin.validity() - override fun visitWebFolder(webFolder: WebFolder) = webFolder.validity() + override fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin) = + webFolderOrigin.validity() - override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() + override fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin) = + webProxyOrigin.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcsOrigin(gcsOrigin: GcsOrigin) = gcsOrigin.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) = + azureBlobOrigin.validity() - override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() + override fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) = + akeneoPimOrigin.validity() override fun unknown(json: JsonValue?) = 0 } @@ -436,87 +445,92 @@ private constructor( } return other is Body && - s3 == other.s3 && - s3Compatible == other.s3Compatible && - cloudinaryBackup == other.cloudinaryBackup && - webFolder == other.webFolder && - webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && - akeneoPim == other.akeneoPim + s3Origin == other.s3Origin && + s3CompatibleOrigin == other.s3CompatibleOrigin && + cloudinaryBackupOrigin == other.cloudinaryBackupOrigin && + webFolderOrigin == other.webFolderOrigin && + webProxyOrigin == other.webProxyOrigin && + gcsOrigin == other.gcsOrigin && + azureBlobOrigin == other.azureBlobOrigin && + akeneoPimOrigin == other.akeneoPimOrigin } override fun hashCode(): Int = Objects.hash( - s3, - s3Compatible, - cloudinaryBackup, - webFolder, - webProxy, - googleCloudStorageGcs, - azureBlobStorage, - akeneoPim, + s3Origin, + s3CompatibleOrigin, + cloudinaryBackupOrigin, + webFolderOrigin, + webProxyOrigin, + gcsOrigin, + azureBlobOrigin, + akeneoPimOrigin, ) override fun toString(): String = when { - s3 != null -> "Body{s3=$s3}" - s3Compatible != null -> "Body{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "Body{webFolder=$webFolder}" - webProxy != null -> "Body{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" - akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" + s3Origin != null -> "Body{s3Origin=$s3Origin}" + s3CompatibleOrigin != null -> "Body{s3CompatibleOrigin=$s3CompatibleOrigin}" + cloudinaryBackupOrigin != null -> + "Body{cloudinaryBackupOrigin=$cloudinaryBackupOrigin}" + webFolderOrigin != null -> "Body{webFolderOrigin=$webFolderOrigin}" + webProxyOrigin != null -> "Body{webProxyOrigin=$webProxyOrigin}" + gcsOrigin != null -> "Body{gcsOrigin=$gcsOrigin}" + azureBlobOrigin != null -> "Body{azureBlobOrigin=$azureBlobOrigin}" + akeneoPimOrigin != null -> "Body{akeneoPimOrigin=$akeneoPimOrigin}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") } companion object { - @JvmStatic fun ofS3(s3: S3) = Body(s3 = s3) + @JvmStatic fun ofS3Origin(s3Origin: S3Origin) = Body(s3Origin = s3Origin) @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = Body(s3Compatible = s3Compatible) + fun ofS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) = + Body(s3CompatibleOrigin = s3CompatibleOrigin) @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - Body(cloudinaryBackup = cloudinaryBackup) + fun ofCloudinaryBackupOrigin(cloudinaryBackupOrigin: CloudinaryBackupOrigin) = + Body(cloudinaryBackupOrigin = cloudinaryBackupOrigin) - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Body(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) + @JvmStatic + fun ofWebFolderOrigin(webFolderOrigin: WebFolderOrigin) = + Body(webFolderOrigin = webFolderOrigin) @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - Body(googleCloudStorageGcs = googleCloudStorageGcs) + fun ofWebProxyOrigin(webProxyOrigin: WebProxyOrigin) = + Body(webProxyOrigin = webProxyOrigin) + + @JvmStatic fun ofGcsOrigin(gcsOrigin: GcsOrigin) = Body(gcsOrigin = gcsOrigin) @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - Body(azureBlobStorage = azureBlobStorage) + fun ofAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) = + Body(azureBlobOrigin = azureBlobOrigin) - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) + @JvmStatic + fun ofAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) = + Body(akeneoPimOrigin = akeneoPimOrigin) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ interface Visitor { - fun visitS3(s3: S3): T + fun visitS3Origin(s3Origin: S3Origin): T - fun visitS3Compatible(s3Compatible: S3Compatible): T + fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin): T - fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup): T + fun visitCloudinaryBackupOrigin(cloudinaryBackupOrigin: CloudinaryBackupOrigin): T - fun visitWebFolder(webFolder: WebFolder): T + fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin): T - fun visitWebProxy(webProxy: WebProxy): T + fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcsOrigin(gcsOrigin: GcsOrigin): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin): T - fun visitAkeneoPim(akeneoPim: AkeneoPim): T + fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin): T /** * Maps an unknown variant of [Body] to a value of type [T]. @@ -536,32 +550,35 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Body { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) {} val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3 = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Origin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Compatible = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3CompatibleOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackup = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackupOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolder = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolderOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxy = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxyOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(googleCloudStorageGcs = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(gcsOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlobStorage = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlobOrigin = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPim = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPimOrigin = it, _json = json) }, ) .filterNotNull() @@ -588,28 +605,29 @@ private constructor( 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.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) - value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value.s3Origin != null -> generator.writeObject(value.s3Origin) + value.s3CompatibleOrigin != null -> + generator.writeObject(value.s3CompatibleOrigin) + value.cloudinaryBackupOrigin != null -> + generator.writeObject(value.cloudinaryBackupOrigin) + value.webFolderOrigin != null -> generator.writeObject(value.webFolderOrigin) + value.webProxyOrigin != null -> generator.writeObject(value.webProxyOrigin) + value.gcsOrigin != null -> generator.writeObject(value.gcsOrigin) + value.azureBlobOrigin != null -> generator.writeObject(value.azureBlobOrigin) + value.akeneoPimOrigin != null -> generator.writeObject(value.akeneoPimOrigin) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") } } } - class S3 + class S3Origin private constructor( private val accessKey: JsonField, private val bucket: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -628,7 +646,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -685,15 +703,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -755,6 +769,13 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -797,7 +818,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [S3]. + * Returns a mutable builder for constructing an instance of [S3Origin]. * * The following fields are required: * ```java @@ -805,35 +826,36 @@ private constructor( * .bucket() * .name() * .secretKey() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [S3]. */ + /** A builder for [S3Origin]. */ 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 type: JsonField? = null 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() + internal fun from(s3Origin: S3Origin) = apply { + accessKey = s3Origin.accessKey + bucket = s3Origin.bucket + name = s3Origin.name + secretKey = s3Origin.secretKey + type = s3Origin.type + baseUrlForCanonicalHeader = s3Origin.baseUrlForCanonicalHeader + includeCanonicalHeader = s3Origin.includeCanonicalHeader + prefix = s3Origin.prefix + additionalProperties = s3Origin.additionalProperties.toMutableMap() } /** Access key for the bucket. */ @@ -884,19 +906,16 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun type(type: Type) = type(JsonField.of(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("S3") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -964,7 +983,7 @@ private constructor( } /** - * Returns an immutable instance of [S3]. + * Returns an immutable instance of [S3Origin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -974,17 +993,18 @@ private constructor( * .bucket() * .name() * .secretKey() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): S3 = - S3( + fun build(): S3Origin = + S3Origin( checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("name", name), checkRequired("secretKey", secretKey), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -994,7 +1014,7 @@ private constructor( private var validated: Boolean = false - fun validate(): S3 = apply { + fun validate(): S3Origin = apply { if (validated) { return@apply } @@ -1003,11 +1023,7 @@ private constructor( bucket() name() secretKey() - _type().let { - if (it != JsonValue.from("S3")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1034,17 +1050,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + 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 S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 S3 && + return other is S3Origin && accessKey == other.accessKey && bucket == other.bucket && name == other.name && @@ -1073,17 +1255,17 @@ private constructor( 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}" + "S3Origin{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class S3Compatible + class S3CompatibleOrigin 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 type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1106,7 +1288,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1179,15 +1361,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -1266,6 +1444,13 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -1318,7 +1503,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [S3Compatible]. + * Returns a mutable builder for constructing an instance of [S3CompatibleOrigin]. * * The following fields are required: * ```java @@ -1327,12 +1512,13 @@ private constructor( * .endpoint() * .name() * .secretKey() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [S3Compatible]. */ + /** A builder for [S3CompatibleOrigin]. */ class Builder internal constructor() { private var accessKey: JsonField? = null @@ -1340,7 +1526,7 @@ private constructor( 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 type: JsonField? = null private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var prefix: JsonField = JsonMissing.of() @@ -1348,18 +1534,18 @@ private constructor( 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() + internal fun from(s3CompatibleOrigin: S3CompatibleOrigin) = apply { + accessKey = s3CompatibleOrigin.accessKey + bucket = s3CompatibleOrigin.bucket + endpoint = s3CompatibleOrigin.endpoint + name = s3CompatibleOrigin.name + secretKey = s3CompatibleOrigin.secretKey + type = s3CompatibleOrigin.type + baseUrlForCanonicalHeader = s3CompatibleOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = s3CompatibleOrigin.includeCanonicalHeader + prefix = s3CompatibleOrigin.prefix + s3ForcePathStyle = s3CompatibleOrigin.s3ForcePathStyle + additionalProperties = s3CompatibleOrigin.additionalProperties.toMutableMap() } /** Access key for the bucket. */ @@ -1422,19 +1608,16 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun type(type: Type) = type(JsonField.of(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("S3_COMPATIBLE") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -1517,7 +1700,7 @@ private constructor( } /** - * Returns an immutable instance of [S3Compatible]. + * Returns an immutable instance of [S3CompatibleOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -1528,18 +1711,19 @@ private constructor( * .endpoint() * .name() * .secretKey() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): S3Compatible = - S3Compatible( + fun build(): S3CompatibleOrigin = + S3CompatibleOrigin( checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), checkRequired("name", name), checkRequired("secretKey", secretKey), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1550,7 +1734,7 @@ private constructor( private var validated: Boolean = false - fun validate(): S3Compatible = apply { + fun validate(): S3CompatibleOrigin = apply { if (validated) { return@apply } @@ -1560,11 +1744,7 @@ private constructor( endpoint() name() secretKey() - _type().let { - if (it != JsonValue.from("S3_COMPATIBLE")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1593,18 +1773,184 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 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) + 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 S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val S3 = of("S3") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + S3_COMPATIBLE, + S3, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + S3_COMPATIBLE, + S3, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + S3_COMPATIBLE -> Value.S3_COMPATIBLE + S3 -> Value.S3 + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3_COMPATIBLE -> Known.S3_COMPATIBLE + S3 -> Known.S3 + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 S3Compatible && + return other is S3CompatibleOrigin && accessKey == other.accessKey && bucket == other.bucket && endpoint == other.endpoint && @@ -1637,16 +1983,16 @@ private constructor( 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}" + "S3CompatibleOrigin{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" } - class CloudinaryBackup + class CloudinaryBackupOrigin private constructor( private val accessKey: JsonField, private val bucket: JsonField, private val name: JsonField, private val secretKey: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1665,7 +2011,7 @@ private constructor( @JsonProperty("secretKey") @ExcludeMissing secretKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1722,15 +2068,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -1792,6 +2134,13 @@ private constructor( @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -1834,7 +2183,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CloudinaryBackup]. + * Returns a mutable builder for constructing an instance of + * [CloudinaryBackupOrigin]. * * The following fields are required: * ```java @@ -1842,35 +2192,37 @@ private constructor( * .bucket() * .name() * .secretKey() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [CloudinaryBackup]. */ + /** A builder for [CloudinaryBackupOrigin]. */ 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 type: JsonField? = null 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() + internal fun from(cloudinaryBackupOrigin: CloudinaryBackupOrigin) = apply { + accessKey = cloudinaryBackupOrigin.accessKey + bucket = cloudinaryBackupOrigin.bucket + name = cloudinaryBackupOrigin.name + secretKey = cloudinaryBackupOrigin.secretKey + type = cloudinaryBackupOrigin.type + baseUrlForCanonicalHeader = cloudinaryBackupOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = cloudinaryBackupOrigin.includeCanonicalHeader + prefix = cloudinaryBackupOrigin.prefix + additionalProperties = + cloudinaryBackupOrigin.additionalProperties.toMutableMap() } /** Access key for the bucket. */ @@ -1921,19 +2273,16 @@ private constructor( */ fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun type(type: Type) = type(JsonField.of(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("CLOUDINARY_BACKUP") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2001,7 +2350,7 @@ private constructor( } /** - * Returns an immutable instance of [CloudinaryBackup]. + * Returns an immutable instance of [CloudinaryBackupOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2011,17 +2360,18 @@ private constructor( * .bucket() * .name() * .secretKey() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): CloudinaryBackup = - CloudinaryBackup( + fun build(): CloudinaryBackupOrigin = + CloudinaryBackupOrigin( checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("name", name), checkRequired("secretKey", secretKey), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -2031,7 +2381,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CloudinaryBackup = apply { + fun validate(): CloudinaryBackupOrigin = apply { if (validated) { return@apply } @@ -2040,11 +2390,7 @@ private constructor( bucket() name() secretKey() - _type().let { - if (it != JsonValue.from("CLOUDINARY_BACKUP")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -2071,17 +2417,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CLOUDINARY_BACKUP, + S3, + S3_COMPATIBLE, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + CLOUDINARY_BACKUP, + S3, + S3_COMPATIBLE, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 CloudinaryBackup && + return other is CloudinaryBackupOrigin && accessKey == other.accessKey && bucket == other.bucket && name == other.name && @@ -2110,14 +2622,14 @@ private constructor( 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}" + "CloudinaryBackupOrigin{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class WebFolder + class WebFolderOrigin private constructor( private val baseUrl: JsonField, private val name: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, @@ -2130,7 +2642,7 @@ private constructor( @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2169,15 +2681,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -2220,6 +2728,13 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2265,37 +2780,38 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [WebFolder]. + * Returns a mutable builder for constructing an instance of [WebFolderOrigin]. * * The following fields are required: * ```java * .baseUrl() * .name() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [WebFolder]. */ + /** A builder for [WebFolderOrigin]. */ class Builder internal constructor() { private var baseUrl: JsonField? = null private var name: JsonField? = null - private var type: JsonValue = JsonValue.from("WEB_FOLDER") + private var type: JsonField? = null 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() + internal fun from(webFolderOrigin: WebFolderOrigin) = apply { + baseUrl = webFolderOrigin.baseUrl + name = webFolderOrigin.name + type = webFolderOrigin.type + baseUrlForCanonicalHeader = webFolderOrigin.baseUrlForCanonicalHeader + forwardHostHeaderToOrigin = webFolderOrigin.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolderOrigin.includeCanonicalHeader + additionalProperties = webFolderOrigin.additionalProperties.toMutableMap() } /** Root URL for the web folder origin. */ @@ -2322,19 +2838,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(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("WEB_FOLDER") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2406,7 +2919,7 @@ private constructor( } /** - * Returns an immutable instance of [WebFolder]. + * Returns an immutable instance of [WebFolderOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2414,15 +2927,16 @@ private constructor( * ```java * .baseUrl() * .name() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): WebFolder = - WebFolder( + fun build(): WebFolderOrigin = + WebFolderOrigin( checkRequired("baseUrl", baseUrl), checkRequired("name", name), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, forwardHostHeaderToOrigin, includeCanonicalHeader, @@ -2432,18 +2946,14 @@ private constructor( private var validated: Boolean = false - fun validate(): WebFolder = apply { + fun validate(): WebFolderOrigin = apply { if (validated) { return@apply } baseUrl() name() - _type().let { - if (it != JsonValue.from("WEB_FOLDER")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() forwardHostHeaderToOrigin() includeCanonicalHeader() @@ -2468,27 +2978,193 @@ private constructor( 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 } + + (type.asKnown().getOrNull()?.validity() ?: 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 - } + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { - 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 - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { + companion object { + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_FOLDER, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + WEB_FOLDER, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_PROXY, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + WEB_FOLDER -> Value.WEB_FOLDER + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_FOLDER -> Known.WEB_FOLDER + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 WebFolderOrigin && + 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, @@ -2503,13 +3179,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebFolderOrigin{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class WebProxy + class WebProxyOrigin private constructor( private val name: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -2518,7 +3194,7 @@ private constructor( @JsonCreator private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2537,15 +3213,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -2572,6 +3244,13 @@ private constructor( */ @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 [baseUrlForCanonicalHeader]. * @@ -2607,32 +3286,33 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [WebProxy]. + * Returns a mutable builder for constructing an instance of [WebProxyOrigin]. * * The following fields are required: * ```java * .name() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [WebProxy]. */ + /** A builder for [WebProxyOrigin]. */ class Builder internal constructor() { private var name: JsonField? = null - private var type: JsonValue = JsonValue.from("WEB_PROXY") + private var type: JsonField? = null 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() + internal fun from(webProxyOrigin: WebProxyOrigin) = apply { + name = webProxyOrigin.name + type = webProxyOrigin.type + baseUrlForCanonicalHeader = webProxyOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = webProxyOrigin.includeCanonicalHeader + additionalProperties = webProxyOrigin.additionalProperties.toMutableMap() } /** Display name of the origin. */ @@ -2647,19 +3327,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(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("WEB_PROXY") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -2715,21 +3392,22 @@ private constructor( } /** - * Returns an immutable instance of [WebProxy]. + * Returns an immutable instance of [WebProxyOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .name() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): WebProxy = - WebProxy( + fun build(): WebProxyOrigin = + WebProxyOrigin( checkRequired("name", name), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, additionalProperties.toMutableMap(), @@ -2738,17 +3416,13 @@ private constructor( private var validated: Boolean = false - fun validate(): WebProxy = apply { + fun validate(): WebProxyOrigin = apply { if (validated) { return@apply } name() - _type().let { - if (it != JsonValue.from("WEB_PROXY")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() validated = true @@ -2771,16 +3445,182 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + 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 WEB_PROXY = of("WEB_PROXY") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEB_PROXY, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + GCS, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + WEB_PROXY, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + GCS, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + WEB_PROXY -> Value.WEB_PROXY + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + WEB_PROXY -> Known.WEB_PROXY + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 WebProxy && + return other is WebProxyOrigin && name == other.name && type == other.type && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && @@ -2801,16 +3641,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxyOrigin{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class GcsOrigin private constructor( private val bucket: JsonField, private val clientEmail: JsonField, private val name: JsonField, private val privateKey: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -2829,7 +3669,7 @@ private constructor( @JsonProperty("privateKey") @ExcludeMissing privateKey: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2880,15 +3720,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -2948,6 +3784,13 @@ private constructor( @ExcludeMissing fun _privateKey(): JsonField = privateKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -2990,8 +3833,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [GcsOrigin]. * * The following fields are required: * ```java @@ -2999,35 +3841,36 @@ private constructor( * .clientEmail() * .name() * .privateKey() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [GcsOrigin]. */ 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 type: JsonField? = null 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + internal fun from(gcsOrigin: GcsOrigin) = apply { + bucket = gcsOrigin.bucket + clientEmail = gcsOrigin.clientEmail + name = gcsOrigin.name + privateKey = gcsOrigin.privateKey + type = gcsOrigin.type + baseUrlForCanonicalHeader = gcsOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = gcsOrigin.includeCanonicalHeader + prefix = gcsOrigin.prefix + additionalProperties = gcsOrigin.additionalProperties.toMutableMap() } fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -3079,19 +3922,16 @@ private constructor( this.privateKey = privateKey } + fun type(type: Type) = type(JsonField.of(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("GCS") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3158,7 +3998,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [GcsOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3168,17 +4008,18 @@ private constructor( * .clientEmail() * .name() * .privateKey() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): GcsOrigin = + GcsOrigin( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), checkRequired("name", name), checkRequired("privateKey", privateKey), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3188,7 +4029,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): GcsOrigin = apply { if (validated) { return@apply } @@ -3197,11 +4038,7 @@ private constructor( clientEmail() name() privateKey() - _type().let { - if (it != JsonValue.from("GCS")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -3228,17 +4065,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + 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 GCS = of("GCS") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GCS, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + AZURE_BLOB, + AKENEO_PIM, + } + + /** + * 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 { + GCS, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + AZURE_BLOB, + AKENEO_PIM, + /** + * 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) { + GCS -> Value.GCS + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + AZURE_BLOB -> Value.AZURE_BLOB + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + GCS -> Known.GCS + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + AZURE_BLOB -> Known.AZURE_BLOB + AKENEO_PIM -> Known.AKENEO_PIM + 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 GoogleCloudStorageGcs && + return other is GcsOrigin && bucket == other.bucket && clientEmail == other.clientEmail && name == other.name && @@ -3267,16 +4270,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "GcsOrigin{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlobOrigin private constructor( private val accountName: JsonField, private val container: JsonField, private val name: JsonField, private val sasToken: JsonField, - private val type: JsonValue, + private val type: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -3295,7 +4298,7 @@ private constructor( @JsonProperty("sasToken") @ExcludeMissing sasToken: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3346,15 +4349,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * URL used in the Canonical header (if enabled). @@ -3415,6 +4414,13 @@ private constructor( */ @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -3457,7 +4463,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlobOrigin]. * * The following fields are required: * ```java @@ -3465,35 +4471,36 @@ private constructor( * .container() * .name() * .sasToken() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlobOrigin]. */ 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 type: JsonField? = null 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(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + internal fun from(azureBlobOrigin: AzureBlobOrigin) = apply { + accountName = azureBlobOrigin.accountName + container = azureBlobOrigin.container + name = azureBlobOrigin.name + sasToken = azureBlobOrigin.sasToken + type = azureBlobOrigin.type + baseUrlForCanonicalHeader = azureBlobOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobOrigin.includeCanonicalHeader + prefix = azureBlobOrigin.prefix + additionalProperties = azureBlobOrigin.additionalProperties.toMutableMap() } fun accountName(accountName: String) = accountName(JsonField.of(accountName)) @@ -3543,19 +4550,16 @@ private constructor( */ fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + fun type(type: Type) = type(JsonField.of(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("AZURE_BLOB") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = @@ -3622,7 +4626,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlobOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3632,17 +4636,18 @@ private constructor( * .container() * .name() * .sasToken() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlobOrigin = + AzureBlobOrigin( checkRequired("accountName", accountName), checkRequired("container", container), checkRequired("name", name), checkRequired("sasToken", sasToken), - type, + checkRequired("type", type), baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3652,7 +4657,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlobOrigin = apply { if (validated) { return@apply } @@ -3661,11 +4666,7 @@ private constructor( container() name() sasToken() - _type().let { - if (it != JsonValue.from("AZURE_BLOB")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -3692,17 +4693,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + 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 AZURE_BLOB = of("AZURE_BLOB") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AKENEO_PIM = of("AKENEO_PIM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AZURE_BLOB, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AKENEO_PIM, + } + + /** + * 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 { + AZURE_BLOB, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AKENEO_PIM, + /** + * 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) { + AZURE_BLOB -> Value.AZURE_BLOB + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AZURE_BLOB -> Known.AZURE_BLOB + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AKENEO_PIM -> Known.AKENEO_PIM + 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 AzureBlobStorage && + return other is AzureBlobOrigin && accountName == other.accountName && container == other.container && name == other.name && @@ -3731,17 +4898,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "AzureBlobOrigin{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AkeneoPim + class AkeneoPimOrigin 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 type: JsonField, private val username: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, @@ -3763,7 +4930,7 @@ private constructor( @JsonProperty("password") @ExcludeMissing password: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), @@ -3832,15 +4999,11 @@ private constructor( 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). + * @throws ImageKitInvalidDataException 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("type") @ExcludeMissing fun _type(): JsonValue = type + fun type(): Type = type.getRequired("type") /** * Akeneo API username. @@ -3909,6 +5072,13 @@ private constructor( */ @JsonProperty("password") @ExcludeMissing fun _password(): JsonField = password + /** + * 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 [username]. * @@ -3952,7 +5122,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AkeneoPim]. + * Returns a mutable builder for constructing an instance of [AkeneoPimOrigin]. * * The following fields are required: * ```java @@ -3961,13 +5131,14 @@ private constructor( * .clientSecret() * .name() * .password() + * .type() * .username() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AkeneoPim]. */ + /** A builder for [AkeneoPimOrigin]. */ class Builder internal constructor() { private var baseUrl: JsonField? = null @@ -3975,24 +5146,24 @@ private constructor( 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 type: JsonField? = null 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() + internal fun from(akeneoPimOrigin: AkeneoPimOrigin) = apply { + baseUrl = akeneoPimOrigin.baseUrl + clientId = akeneoPimOrigin.clientId + clientSecret = akeneoPimOrigin.clientSecret + name = akeneoPimOrigin.name + password = akeneoPimOrigin.password + type = akeneoPimOrigin.type + username = akeneoPimOrigin.username + baseUrlForCanonicalHeader = akeneoPimOrigin.baseUrlForCanonicalHeader + includeCanonicalHeader = akeneoPimOrigin.includeCanonicalHeader + additionalProperties = akeneoPimOrigin.additionalProperties.toMutableMap() } /** Akeneo instance base URL. */ @@ -4057,19 +5228,16 @@ private constructor( */ fun password(password: JsonField) = apply { this.password = password } + fun type(type: Type) = type(JsonField.of(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("AKENEO_PIM") - * ``` + * 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: JsonValue) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** Akeneo API username. */ fun username(username: String) = username(JsonField.of(username)) @@ -4137,7 +5305,7 @@ private constructor( } /** - * Returns an immutable instance of [AkeneoPim]. + * Returns an immutable instance of [AkeneoPimOrigin]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4148,19 +5316,20 @@ private constructor( * .clientSecret() * .name() * .password() + * .type() * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AkeneoPim = - AkeneoPim( + fun build(): AkeneoPimOrigin = + AkeneoPimOrigin( checkRequired("baseUrl", baseUrl), checkRequired("clientId", clientId), checkRequired("clientSecret", clientSecret), checkRequired("name", name), checkRequired("password", password), - type, + checkRequired("type", type), checkRequired("username", username), baseUrlForCanonicalHeader, includeCanonicalHeader, @@ -4170,7 +5339,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AkeneoPim = apply { + fun validate(): AkeneoPimOrigin = apply { if (validated) { return@apply } @@ -4180,11 +5349,7 @@ private constructor( clientSecret() name() password() - _type().let { - if (it != JsonValue.from("AKENEO_PIM")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } + type().validate() username() baseUrlForCanonicalHeader() includeCanonicalHeader() @@ -4212,17 +5377,183 @@ private constructor( (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 } + + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (username.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + 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 AKENEO_PIM = of("AKENEO_PIM") + + @JvmField val S3 = of("S3") + + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + + @JvmField val WEB_FOLDER = of("WEB_FOLDER") + + @JvmField val WEB_PROXY = of("WEB_PROXY") + + @JvmField val GCS = of("GCS") + + @JvmField val AZURE_BLOB = of("AZURE_BLOB") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AKENEO_PIM, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + } + + /** + * 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 { + AKENEO_PIM, + S3, + S3_COMPATIBLE, + CLOUDINARY_BACKUP, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + /** + * 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) { + AKENEO_PIM -> Value.AKENEO_PIM + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + AKENEO_PIM -> Known.AKENEO_PIM + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + 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 AkeneoPim && + return other is AkeneoPimOrigin && baseUrl == other.baseUrl && clientId == other.clientId && clientSecret == other.clientSecret && @@ -4253,7 +5584,7 @@ private constructor( 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}" + "AkeneoPimOrigin{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/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 f6d962db..0ba87a93 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 @@ -11,14 +11,15 @@ internal class OriginCreateParamsTest { fun create() { OriginCreateParams.builder() .body( - OriginCreateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginCreateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginCreateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) .build() @@ -29,14 +30,15 @@ internal class OriginCreateParamsTest { val params = OriginCreateParams.builder() .body( - OriginCreateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginCreateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginCreateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) .build() @@ -45,15 +47,16 @@ internal class OriginCreateParamsTest { assertThat(body) .isEqualTo( - OriginCreateParams.Body.ofS3( - OriginCreateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginCreateParams.Body.ofS3Origin( + OriginCreateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginCreateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) ) @@ -64,11 +67,12 @@ internal class OriginCreateParamsTest { val params = OriginCreateParams.builder() .body( - OriginCreateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginCreateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginCreateParams.Body.S3Origin.Type.S3) .build() ) .build() @@ -77,12 +81,13 @@ internal class OriginCreateParamsTest { assertThat(body) .isEqualTo( - OriginCreateParams.Body.ofS3( - OriginCreateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginCreateParams.Body.ofS3Origin( + OriginCreateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginCreateParams.Body.S3Origin.Type.S3) .build() ) ) 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 ac041a2b..6391ae85 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 @@ -12,14 +12,15 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .body( - OriginUpdateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginUpdateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginUpdateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) .build() @@ -31,11 +32,12 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .body( - OriginUpdateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginUpdateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginUpdateParams.Body.S3Origin.Type.S3) .build() ) .build() @@ -51,14 +53,15 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .body( - OriginUpdateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginUpdateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginUpdateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) .build() @@ -67,15 +70,16 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - OriginUpdateParams.Body.ofS3( - OriginUpdateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginUpdateParams.Body.ofS3Origin( + OriginUpdateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginUpdateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) ) @@ -87,11 +91,12 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .body( - OriginUpdateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginUpdateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginUpdateParams.Body.S3Origin.Type.S3) .build() ) .build() @@ -100,12 +105,13 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - OriginUpdateParams.Body.ofS3( - OriginUpdateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginUpdateParams.Body.ofS3Origin( + OriginUpdateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginUpdateParams.Body.S3Origin.Type.S3) .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 f22eb5c1..b44f2580 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,14 +28,15 @@ internal class OriginServiceAsyncTest { originServiceAsync.create( OriginCreateParams.builder() .body( - OriginCreateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginCreateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginCreateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) .build() @@ -61,14 +62,15 @@ internal class OriginServiceAsyncTest { OriginUpdateParams.builder() .id("id") .body( - OriginUpdateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginUpdateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginUpdateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .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 07729640..48cfe1d6 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,14 +28,15 @@ internal class OriginServiceTest { originService.create( OriginCreateParams.builder() .body( - OriginCreateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginCreateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginCreateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) .build() @@ -60,14 +61,15 @@ internal class OriginServiceTest { OriginUpdateParams.builder() .id("id") .body( - OriginUpdateParams.Body.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") + OriginUpdateParams.Body.S3Origin.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .type(OriginUpdateParams.Body.S3Origin.Type.S3) .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) - .prefix("images") + .prefix("raw-assets") .build() ) .build() From 4b4d0cb6e27d4d8212fb65573aca3af4022a1be4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:45:10 +0000 Subject: [PATCH 035/125] feat(api): manual updates --- .stats.yml | 4 +- .../accounts/origins/OriginCreateParams.kt | 6526 ++++------------ .../accounts/origins/OriginUpdateParams.kt | 6552 ++++------------- .../origins/OriginCreateParamsTest.kt | 128 +- .../origins/OriginUpdateParamsTest.kt | 138 +- .../async/accounts/OriginServiceAsyncTest.kt | 66 +- .../blocking/accounts/OriginServiceTest.kt | 66 +- 7 files changed, 3022 insertions(+), 10458 deletions(-) diff --git a/.stats.yml b/.stats.yml index fbcd50b8..0604c950 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-4abcc684cb38a6caeb1d20789c3f42f050aa02a1e11cd15b56a758b269961368.yml -openapi_spec_hash: c197897c7befdd521213bdaabbf8b134 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3fced4085838ae20641cfa2775c6d36757bbaae28415892b2e9ee438e3b56a85.yml +openapi_spec_hash: 58327d97499fdad00856caa35ca3f16a config_hash: ecd4e1fc35135b5e53487ca547e46fd7 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 097f4f9b..b56e665c 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 @@ -6,24 +6,13 @@ import 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.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.errors.ImageKitInvalidDataException @@ -40,8 +29,284 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Schema for origin resources. */ - fun body(): Body = body + /** + * @throws ImageKitInvalidDataException if the 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 type(): Type = body.type() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accessKey(): Optional = body.accessKey() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountName(): Optional = body.accountName() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun baseUrl(): Optional = body.baseUrl() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = body.baseUrlForCanonicalHeader() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bucket(): Optional = body.bucket() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientEmail(): Optional = body.clientEmail() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientId(): Optional = body.clientId() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientSecret(): Optional = body.clientSecret() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun container(): Optional = body.container() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endpoint(): Optional = body.endpoint() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun forwardHostHeaderToOrigin(): Optional = body.forwardHostHeaderToOrigin() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = body.includeCanonicalHeader() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun password(): Optional = body.password() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prefix(): Optional = body.prefix() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun privateKey(): Optional = body.privateKey() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun s3ForcePathStyle(): Optional = body.s3ForcePathStyle() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sasToken(): Optional = body.sasToken() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secretKey(): Optional = body.secretKey() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun username(): Optional = body.username() + + /** + * 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 [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _type(): JsonField = body._type() + + /** + * Returns the raw JSON value of [accessKey]. + * + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _accessKey(): JsonField = body._accessKey() + + /** + * Returns the raw JSON value of [accountName]. + * + * Unlike [accountName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _accountName(): JsonField = body._accountName() + + /** + * Returns the raw JSON value of [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _baseUrl(): JsonField = body._baseUrl() + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _baseUrlForCanonicalHeader(): JsonField = body._baseUrlForCanonicalHeader() + + /** + * Returns the raw JSON value of [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _bucket(): JsonField = body._bucket() + + /** + * Returns the raw JSON value of [clientEmail]. + * + * Unlike [clientEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _clientEmail(): JsonField = body._clientEmail() + + /** + * Returns the raw JSON value of [clientId]. + * + * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _clientId(): JsonField = body._clientId() + + /** + * Returns the raw JSON value of [clientSecret]. + * + * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _clientSecret(): JsonField = body._clientSecret() + + /** + * Returns the raw JSON value of [container]. + * + * Unlike [container], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _container(): JsonField = body._container() + + /** + * Returns the raw JSON value of [endpoint]. + * + * Unlike [endpoint], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endpoint(): JsonField = body._endpoint() + + /** + * Returns the raw JSON value of [forwardHostHeaderToOrigin]. + * + * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _forwardHostHeaderToOrigin(): JsonField = body._forwardHostHeaderToOrigin() + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _includeCanonicalHeader(): JsonField = body._includeCanonicalHeader() + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _password(): JsonField = body._password() + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _prefix(): JsonField = body._prefix() + + /** + * Returns the raw JSON value of [privateKey]. + * + * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _privateKey(): JsonField = body._privateKey() + + /** + * Returns the raw JSON value of [s3ForcePathStyle]. + * + * Unlike [s3ForcePathStyle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _s3ForcePathStyle(): JsonField = body._s3ForcePathStyle() + + /** + * Returns the raw JSON value of [sasToken]. + * + * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sasToken(): JsonField = body._sasToken() + + /** + * Returns the raw JSON value of [secretKey]. + * + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _secretKey(): JsonField = body._secretKey() + + /** + * Returns the raw JSON value of [username]. + * + * Unlike [username], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _username(): JsonField = body._username() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -58,7 +323,8 @@ private constructor( * * The following fields are required: * ```java - * .body() + * .name() + * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -67,50 +333,288 @@ private constructor( /** A builder for [OriginCreateParams]. */ class Builder internal constructor() { - private var body: Body? = 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(originCreateParams: OriginCreateParams) = apply { - body = originCreateParams.body + body = originCreateParams.body.toBuilder() additionalHeaders = originCreateParams.additionalHeaders.toBuilder() additionalQueryParams = originCreateParams.additionalQueryParams.toBuilder() } - /** Schema for origin resources. */ - fun body(body: Body) = apply { this.body = body } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [type] + * - [accessKey] + * - [accountName] + * - [baseUrl] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + 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 type(type: Type) = apply { body.type(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 { body.type(type) } + + fun accessKey(accessKey: String) = apply { body.accessKey(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 { body.accessKey(accessKey) } + + fun accountName(accountName: String) = apply { body.accountName(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 { body.accountName(accountName) } + + fun baseUrl(baseUrl: String) = apply { body.baseUrl(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 { body.baseUrl(baseUrl) } + + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = apply { + body.baseUrlForCanonicalHeader(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 { + body.baseUrlForCanonicalHeader(baseUrlForCanonicalHeader) + } + + fun bucket(bucket: String) = apply { body.bucket(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 { body.bucket(bucket) } + + fun clientEmail(clientEmail: String) = apply { body.clientEmail(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 { body.clientEmail(clientEmail) } + + fun clientId(clientId: String) = apply { body.clientId(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 { body.clientId(clientId) } + + fun clientSecret(clientSecret: String) = apply { body.clientSecret(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 { + body.clientSecret(clientSecret) + } + + fun container(container: String) = apply { body.container(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 { body.container(container) } + + fun endpoint(endpoint: String) = apply { body.endpoint(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 { body.endpoint(endpoint) } + + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = apply { + body.forwardHostHeaderToOrigin(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 { + body.forwardHostHeaderToOrigin(forwardHostHeaderToOrigin) + } + + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = apply { + body.includeCanonicalHeader(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 { + body.includeCanonicalHeader(includeCanonicalHeader) + } + + fun password(password: String) = apply { body.password(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 { body.password(password) } + + fun prefix(prefix: String) = apply { body.prefix(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 { body.prefix(prefix) } + + fun privateKey(privateKey: String) = apply { body.privateKey(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 { body.privateKey(privateKey) } + + fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = apply { + body.s3ForcePathStyle(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 { + body.s3ForcePathStyle(s3ForcePathStyle) + } + + fun sasToken(sasToken: String) = apply { body.sasToken(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 { body.sasToken(sasToken) } + + fun secretKey(secretKey: String) = apply { body.secretKey(secretKey) } - /** Alias for calling [body] with `Body.ofS3Origin(s3Origin)`. */ - fun body(s3Origin: Body.S3Origin) = body(Body.ofS3Origin(s3Origin)) + /** + * 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 { body.secretKey(secretKey) } - /** Alias for calling [body] with `Body.ofS3CompatibleOrigin(s3CompatibleOrigin)`. */ - fun body(s3CompatibleOrigin: Body.S3CompatibleOrigin) = - body(Body.ofS3CompatibleOrigin(s3CompatibleOrigin)) + fun username(username: String) = apply { body.username(username) } /** - * Alias for calling [body] with `Body.ofCloudinaryBackupOrigin(cloudinaryBackupOrigin)`. + * 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 body(cloudinaryBackupOrigin: Body.CloudinaryBackupOrigin) = - body(Body.ofCloudinaryBackupOrigin(cloudinaryBackupOrigin)) + fun username(username: JsonField) = apply { body.username(username) } - /** Alias for calling [body] with `Body.ofWebFolderOrigin(webFolderOrigin)`. */ - fun body(webFolderOrigin: Body.WebFolderOrigin) = - body(Body.ofWebFolderOrigin(webFolderOrigin)) + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - /** Alias for calling [body] with `Body.ofWebProxyOrigin(webProxyOrigin)`. */ - fun body(webProxyOrigin: Body.WebProxyOrigin) = body(Body.ofWebProxyOrigin(webProxyOrigin)) + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } - /** Alias for calling [body] with `Body.ofGcsOrigin(gcsOrigin)`. */ - fun body(gcsOrigin: Body.GcsOrigin) = body(Body.ofGcsOrigin(gcsOrigin)) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } - /** Alias for calling [body] with `Body.ofAzureBlobOrigin(azureBlobOrigin)`. */ - fun body(azureBlobOrigin: Body.AzureBlobOrigin) = - body(Body.ofAzureBlobOrigin(azureBlobOrigin)) + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - /** Alias for calling [body] with `Body.ofAkeneoPimOrigin(akeneoPimOrigin)`. */ - fun body(akeneoPimOrigin: Body.AkeneoPimOrigin) = - body(Body.ofAkeneoPimOrigin(akeneoPimOrigin)) + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -217,14 +721,15 @@ private constructor( * * The following fields are required: * ```java - * .body() + * .name() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): OriginCreateParams = OriginCreateParams( - checkRequired("body", body), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), ) @@ -236,5329 +741,1086 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - /** Schema for origin resources. */ - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) class Body private constructor( - private val s3Origin: S3Origin? = null, - private val s3CompatibleOrigin: S3CompatibleOrigin? = null, - private val cloudinaryBackupOrigin: CloudinaryBackupOrigin? = null, - private val webFolderOrigin: WebFolderOrigin? = null, - private val webProxyOrigin: WebProxyOrigin? = null, - private val gcsOrigin: GcsOrigin? = null, - private val azureBlobOrigin: AzureBlobOrigin? = null, - private val akeneoPimOrigin: AkeneoPimOrigin? = null, - private val _json: JsonValue? = null, + private val name: JsonField, + private val type: JsonField, + private val accessKey: JsonField, + private val accountName: JsonField, + private val baseUrl: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val bucket: JsonField, + private val clientEmail: JsonField, + private val clientId: JsonField, + private val clientSecret: JsonField, + private val container: JsonField, + private val endpoint: JsonField, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, + private val password: JsonField, + private val prefix: JsonField, + private val privateKey: JsonField, + private val s3ForcePathStyle: JsonField, + private val sasToken: JsonField, + private val secretKey: JsonField, + private val username: JsonField, + private val additionalProperties: MutableMap, ) { - fun s3Origin(): Optional = Optional.ofNullable(s3Origin) + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("accessKey") + @ExcludeMissing + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("accountName") + @ExcludeMissing + accountName: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("clientEmail") + @ExcludeMissing + clientEmail: JsonField = JsonMissing.of(), + @JsonProperty("clientId") + @ExcludeMissing + clientId: JsonField = JsonMissing.of(), + @JsonProperty("clientSecret") + @ExcludeMissing + clientSecret: JsonField = JsonMissing.of(), + @JsonProperty("container") + @ExcludeMissing + container: JsonField = JsonMissing.of(), + @JsonProperty("endpoint") + @ExcludeMissing + endpoint: JsonField = JsonMissing.of(), + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("password") + @ExcludeMissing + password: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("privateKey") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + s3ForcePathStyle: JsonField = JsonMissing.of(), + @JsonProperty("sasToken") + @ExcludeMissing + sasToken: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), + @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), + ) : this( + name, + type, + accessKey, + accountName, + baseUrl, + baseUrlForCanonicalHeader, + bucket, + clientEmail, + clientId, + clientSecret, + container, + endpoint, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + password, + prefix, + privateKey, + s3ForcePathStyle, + sasToken, + secretKey, + username, + mutableMapOf(), + ) - fun s3CompatibleOrigin(): Optional = - Optional.ofNullable(s3CompatibleOrigin) + /** + * @throws ImageKitInvalidDataException if the 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") - fun cloudinaryBackupOrigin(): Optional = - Optional.ofNullable(cloudinaryBackupOrigin) + /** + * @throws ImageKitInvalidDataException if 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") - fun webFolderOrigin(): Optional = Optional.ofNullable(webFolderOrigin) + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessKey(): Optional = accessKey.getOptional("accessKey") - fun webProxyOrigin(): Optional = Optional.ofNullable(webProxyOrigin) + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accountName(): Optional = accountName.getOptional("accountName") - fun gcsOrigin(): Optional = Optional.ofNullable(gcsOrigin) + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrl(): Optional = baseUrl.getOptional("baseUrl") - fun azureBlobOrigin(): Optional = Optional.ofNullable(azureBlobOrigin) + /** + * @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") - fun akeneoPimOrigin(): Optional = Optional.ofNullable(akeneoPimOrigin) + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun bucket(): Optional = bucket.getOptional("bucket") - fun isS3Origin(): Boolean = s3Origin != null + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun clientEmail(): Optional = clientEmail.getOptional("clientEmail") - fun isS3CompatibleOrigin(): Boolean = s3CompatibleOrigin != null + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun clientId(): Optional = clientId.getOptional("clientId") - fun isCloudinaryBackupOrigin(): Boolean = cloudinaryBackupOrigin != null + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun clientSecret(): Optional = clientSecret.getOptional("clientSecret") - fun isWebFolderOrigin(): Boolean = webFolderOrigin != null + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun container(): Optional = container.getOptional("container") - fun isWebProxyOrigin(): Boolean = webProxyOrigin != null + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endpoint(): Optional = endpoint.getOptional("endpoint") - fun isGcsOrigin(): Boolean = gcsOrigin != null + /** + * @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") - fun isAzureBlobOrigin(): Boolean = azureBlobOrigin != null + /** + * @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") - fun isAkeneoPimOrigin(): Boolean = akeneoPimOrigin != null + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional = password.getOptional("password") - fun asS3Origin(): S3Origin = s3Origin.getOrThrow("s3Origin") + /** + * @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") - fun asS3CompatibleOrigin(): S3CompatibleOrigin = - s3CompatibleOrigin.getOrThrow("s3CompatibleOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun privateKey(): Optional = privateKey.getOptional("privateKey") - fun asCloudinaryBackupOrigin(): CloudinaryBackupOrigin = - cloudinaryBackupOrigin.getOrThrow("cloudinaryBackupOrigin") + /** + * @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") - fun asWebFolderOrigin(): WebFolderOrigin = webFolderOrigin.getOrThrow("webFolderOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sasToken(): Optional = sasToken.getOptional("sasToken") - fun asWebProxyOrigin(): WebProxyOrigin = webProxyOrigin.getOrThrow("webProxyOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun secretKey(): Optional = secretKey.getOptional("secretKey") - fun asGcsOrigin(): GcsOrigin = gcsOrigin.getOrThrow("gcsOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun username(): Optional = username.getOptional("username") - fun asAzureBlobOrigin(): AzureBlobOrigin = azureBlobOrigin.getOrThrow("azureBlobOrigin") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun asAkeneoPimOrigin(): AkeneoPimOrigin = akeneoPimOrigin.getOrThrow("akeneoPimOrigin") + /** + * 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 - fun _json(): Optional = Optional.ofNullable(_json) + /** + * 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 - fun accept(visitor: Visitor): T = - when { - s3Origin != null -> visitor.visitS3Origin(s3Origin) - s3CompatibleOrigin != null -> visitor.visitS3CompatibleOrigin(s3CompatibleOrigin) - cloudinaryBackupOrigin != null -> - visitor.visitCloudinaryBackupOrigin(cloudinaryBackupOrigin) - webFolderOrigin != null -> visitor.visitWebFolderOrigin(webFolderOrigin) - webProxyOrigin != null -> visitor.visitWebProxyOrigin(webProxyOrigin) - gcsOrigin != null -> visitor.visitGcsOrigin(gcsOrigin) - azureBlobOrigin != null -> visitor.visitAzureBlobOrigin(azureBlobOrigin) - akeneoPimOrigin != null -> visitor.visitAkeneoPimOrigin(akeneoPimOrigin) - else -> visitor.unknown(_json) - } + /** + * 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 - private var validated: Boolean = false + /** + * 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 - fun validate(): Body = apply { - if (validated) { - return@apply - } + /** + * 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 - accept( - object : Visitor { - override fun visitS3Origin(s3Origin: S3Origin) { - s3Origin.validate() - } - - override fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) { - s3CompatibleOrigin.validate() - } - - override fun visitCloudinaryBackupOrigin( - cloudinaryBackupOrigin: CloudinaryBackupOrigin - ) { - cloudinaryBackupOrigin.validate() - } - - override fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin) { - webFolderOrigin.validate() - } - - override fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin) { - webProxyOrigin.validate() - } - - override fun visitGcsOrigin(gcsOrigin: GcsOrigin) { - gcsOrigin.validate() - } - - override fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) { - azureBlobOrigin.validate() - } - - override fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) { - akeneoPimOrigin.validate() - } - } - ) - validated = true - } + /** + * 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 - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * 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 a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [clientId]. * - * Used for best match union deserialization. + * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitS3Origin(s3Origin: S3Origin) = s3Origin.validity() + @JsonProperty("clientId") @ExcludeMissing fun _clientId(): JsonField = clientId - override fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) = - s3CompatibleOrigin.validity() + /** + * 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 - override fun visitCloudinaryBackupOrigin( - cloudinaryBackupOrigin: CloudinaryBackupOrigin - ) = cloudinaryBackupOrigin.validity() + /** + * 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 - override fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin) = - webFolderOrigin.validity() + /** + * 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 - override fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin) = - webProxyOrigin.validity() + /** + * 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 - override fun visitGcsOrigin(gcsOrigin: GcsOrigin) = gcsOrigin.validity() + /** + * 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 - override fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) = - azureBlobOrigin.validity() + /** + * 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 - override fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) = - akeneoPimOrigin.validity() + /** + * 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 - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - s3Origin == other.s3Origin && - s3CompatibleOrigin == other.s3CompatibleOrigin && - cloudinaryBackupOrigin == other.cloudinaryBackupOrigin && - webFolderOrigin == other.webFolderOrigin && - webProxyOrigin == other.webProxyOrigin && - gcsOrigin == other.gcsOrigin && - azureBlobOrigin == other.azureBlobOrigin && - akeneoPimOrigin == other.akeneoPimOrigin - } - - override fun hashCode(): Int = - Objects.hash( - s3Origin, - s3CompatibleOrigin, - cloudinaryBackupOrigin, - webFolderOrigin, - webProxyOrigin, - gcsOrigin, - azureBlobOrigin, - akeneoPimOrigin, - ) - - override fun toString(): String = - when { - s3Origin != null -> "Body{s3Origin=$s3Origin}" - s3CompatibleOrigin != null -> "Body{s3CompatibleOrigin=$s3CompatibleOrigin}" - cloudinaryBackupOrigin != null -> - "Body{cloudinaryBackupOrigin=$cloudinaryBackupOrigin}" - webFolderOrigin != null -> "Body{webFolderOrigin=$webFolderOrigin}" - webProxyOrigin != null -> "Body{webProxyOrigin=$webProxyOrigin}" - gcsOrigin != null -> "Body{gcsOrigin=$gcsOrigin}" - azureBlobOrigin != null -> "Body{azureBlobOrigin=$azureBlobOrigin}" - akeneoPimOrigin != null -> "Body{akeneoPimOrigin=$akeneoPimOrigin}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") - } - - companion object { - - @JvmStatic fun ofS3Origin(s3Origin: S3Origin) = Body(s3Origin = s3Origin) - - @JvmStatic - fun ofS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) = - Body(s3CompatibleOrigin = s3CompatibleOrigin) - - @JvmStatic - fun ofCloudinaryBackupOrigin(cloudinaryBackupOrigin: CloudinaryBackupOrigin) = - Body(cloudinaryBackupOrigin = cloudinaryBackupOrigin) - - @JvmStatic - fun ofWebFolderOrigin(webFolderOrigin: WebFolderOrigin) = - Body(webFolderOrigin = webFolderOrigin) + /** + * 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 - @JvmStatic - fun ofWebProxyOrigin(webProxyOrigin: WebProxyOrigin) = - Body(webProxyOrigin = webProxyOrigin) + /** + * 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 - @JvmStatic fun ofGcsOrigin(gcsOrigin: GcsOrigin) = Body(gcsOrigin = gcsOrigin) + /** + * 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 - @JvmStatic - fun ofAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) = - Body(azureBlobOrigin = azureBlobOrigin) + /** + * 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 - @JvmStatic - fun ofAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) = - Body(akeneoPimOrigin = akeneoPimOrigin) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ - interface Visitor { - - fun visitS3Origin(s3Origin: S3Origin): T - - fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitCloudinaryBackupOrigin(cloudinaryBackupOrigin: CloudinaryBackupOrigin): T + fun toBuilder() = Builder().from(this) - fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin): T - - fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin): T - - fun visitGcsOrigin(gcsOrigin: GcsOrigin): T - - fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin): T - - fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin): T + companion object { /** - * 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. + * Returns a mutable builder for constructing an instance of [Body]. * - * @throws ImageKitInvalidDataException in the default implementation. + * The following fields are required: + * ```java + * .name() + * .type() + * ``` */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Body: $json") - } + @JvmStatic fun builder() = Builder() } - internal class Deserializer : BaseDeserializer(Body::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Body { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) {} - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Origin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3CompatibleOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackupOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolderOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxyOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(gcsOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlobOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPimOrigin = 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() - } - } - } + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var type: JsonField? = null + private var accessKey: JsonField = JsonMissing.of() + private var accountName: JsonField = JsonMissing.of() + private var baseUrl: JsonField = JsonMissing.of() + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var bucket: JsonField = JsonMissing.of() + private var clientEmail: JsonField = JsonMissing.of() + private var clientId: JsonField = JsonMissing.of() + private var clientSecret: JsonField = JsonMissing.of() + private var container: JsonField = JsonMissing.of() + private var endpoint: JsonField = JsonMissing.of() + private var forwardHostHeaderToOrigin: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var password: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var privateKey: JsonField = JsonMissing.of() + private var s3ForcePathStyle: JsonField = JsonMissing.of() + private var sasToken: JsonField = JsonMissing.of() + private var secretKey: JsonField = JsonMissing.of() + private var username: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - internal class Serializer : BaseSerializer(Body::class) { - - override fun serialize( - value: Body, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.s3Origin != null -> generator.writeObject(value.s3Origin) - value.s3CompatibleOrigin != null -> - generator.writeObject(value.s3CompatibleOrigin) - value.cloudinaryBackupOrigin != null -> - generator.writeObject(value.cloudinaryBackupOrigin) - value.webFolderOrigin != null -> generator.writeObject(value.webFolderOrigin) - value.webProxyOrigin != null -> generator.writeObject(value.webProxyOrigin) - value.gcsOrigin != null -> generator.writeObject(value.gcsOrigin) - value.azureBlobOrigin != null -> generator.writeObject(value.azureBlobOrigin) - value.akeneoPimOrigin != null -> generator.writeObject(value.akeneoPimOrigin) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") - } + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + type = body.type + accessKey = body.accessKey + accountName = body.accountName + baseUrl = body.baseUrl + baseUrlForCanonicalHeader = body.baseUrlForCanonicalHeader + bucket = body.bucket + clientEmail = body.clientEmail + clientId = body.clientId + clientSecret = body.clientSecret + container = body.container + endpoint = body.endpoint + forwardHostHeaderToOrigin = body.forwardHostHeaderToOrigin + includeCanonicalHeader = body.includeCanonicalHeader + password = body.password + prefix = body.prefix + privateKey = body.privateKey + s3ForcePathStyle = body.s3ForcePathStyle + sasToken = body.sasToken + secretKey = body.secretKey + username = body.username + additionalProperties = body.additionalProperties.toMutableMap() } - } - class S3Origin - private constructor( - private val accessKey: JsonField, - private val bucket: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonField, - 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: JsonField = 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(), - ) + fun name(name: String) = name(JsonField.of(name)) /** - * Access key for the bucket. + * Sets [Builder.name] to an arbitrary JSON 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.name] 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(): String = accessKey.getRequired("accessKey") + fun name(name: JsonField) = apply { this.name = name } - /** - * 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") + fun type(type: Type) = type(JsonField.of(type)) /** - * Display name of the origin. + * Sets [Builder.type] to an arbitrary JSON 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.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 name(): String = name.getRequired("name") + fun type(type: JsonField) = apply { this.type = type } + + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Secret key for the bucket. + * Sets [Builder.accessKey] to an arbitrary JSON 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.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 secretKey(): String = secretKey.getRequired("secretKey") + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } - /** - * @throws ImageKitInvalidDataException if 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") + fun accountName(accountName: String) = accountName(JsonField.of(accountName)) /** - * URL used in the Canonical header (if enabled). + * Sets [Builder.accountName] to an arbitrary JSON 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.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 baseUrlForCanonicalHeader(): Optional = - baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + fun accountName(accountName: JsonField) = apply { + this.accountName = accountName + } - /** - * 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") + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) /** - * Path prefix inside the bucket. + * Sets [Builder.baseUrl] to an arbitrary JSON 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.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 prefix(): Optional = prefix.getOptional("prefix") + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** - * 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 + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) /** - * Returns the raw JSON value of [bucket]. + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. * - * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) /** - * Returns the raw JSON value of [secretKey]. + * Sets [Builder.bucket] to an arbitrary JSON value. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected - * type. + * 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. */ - @JsonProperty("secretKey") - @ExcludeMissing - fun _secretKey(): JsonField = secretKey + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } - /** - * 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 + fun clientEmail(clientEmail: String) = clientEmail(JsonField.of(clientEmail)) /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Sets [Builder.clientEmail] to an arbitrary JSON value. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has - * an unexpected type. + * 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. */ - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + fun clientEmail(clientEmail: JsonField) = apply { + this.clientEmail = 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 + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) /** - * Returns the raw JSON value of [prefix]. + * Sets [Builder.clientId] to an arbitrary JSON value. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun clientId(clientId: JsonField) = apply { this.clientId = clientId } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [S3Origin]. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .name() - * .secretKey() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [S3Origin]. */ - 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: JsonField? = null - 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(s3Origin: S3Origin) = apply { - accessKey = s3Origin.accessKey - bucket = s3Origin.bucket - name = s3Origin.name - secretKey = s3Origin.secretKey - type = s3Origin.type - baseUrlForCanonicalHeader = s3Origin.baseUrlForCanonicalHeader - includeCanonicalHeader = s3Origin.includeCanonicalHeader - prefix = s3Origin.prefix - additionalProperties = s3Origin.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 } - - 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 } - - /** 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 [S3Origin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .name() - * .secretKey() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): S3Origin = - S3Origin( - checkRequired("accessKey", accessKey), - checkRequired("bucket", bucket), - checkRequired("name", name), - checkRequired("secretKey", secretKey), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): S3Origin = apply { - if (validated) { - return@apply - } - - accessKey() - bucket() - name() - secretKey() - type().validate() - baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.clientSecret] to an arbitrary JSON value. * - * Used for best match union deserialization. + * 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. */ - @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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) - - 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 S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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 S3Origin && - 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, - ) + fun clientSecret(clientSecret: JsonField) = apply { + this.clientSecret = clientSecret } - override fun hashCode(): Int = hashCode - - override fun toString() = - "S3Origin{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" - } - - class S3CompatibleOrigin - 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: JsonField, - 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: JsonField = 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(), - ) + fun container(container: String) = container(JsonField.of(container)) /** - * Access key for the bucket. + * Sets [Builder.container] to an arbitrary JSON 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.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 accessKey(): String = accessKey.getRequired("accessKey") + fun container(container: JsonField) = apply { this.container = container } - /** - * 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") + fun endpoint(endpoint: String) = endpoint(JsonField.of(endpoint)) /** - * Custom S3-compatible endpoint. + * Sets [Builder.endpoint] to an arbitrary JSON 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.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(): String = endpoint.getRequired("endpoint") + fun endpoint(endpoint: JsonField) = apply { this.endpoint = 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") + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = + forwardHostHeaderToOrigin(JsonField.of(forwardHostHeaderToOrigin)) /** - * Secret key for the bucket. + * Sets [Builder.forwardHostHeaderToOrigin] to an arbitrary JSON 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.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 secretKey(): String = secretKey.getRequired("secretKey") + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: JsonField) = apply { + this.forwardHostHeaderToOrigin = forwardHostHeaderToOrigin + } - /** - * @throws ImageKitInvalidDataException if 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") + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) /** - * URL used in the Canonical header (if enabled). + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON 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.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 baseUrlForCanonicalHeader(): Optional = - baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } - /** - * 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") + fun password(password: String) = password(JsonField.of(password)) /** - * Path prefix inside the bucket. + * Sets [Builder.password] to an arbitrary JSON 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.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 prefix(): Optional = prefix.getOptional("prefix") + fun password(password: JsonField) = apply { this.password = password } - /** - * 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") + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Returns the raw JSON value of [accessKey]. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected - * type. + * 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. */ - @JsonProperty("accessKey") - @ExcludeMissing - fun _accessKey(): JsonField = accessKey + fun prefix(prefix: JsonField) = apply { this.prefix = 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 + fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) /** - * Returns the raw JSON value of [endpoint]. + * Sets [Builder.privateKey] to an arbitrary JSON value. * - * Unlike [endpoint], this method doesn't throw if the JSON field has an unexpected - * type. + * 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. */ - @JsonProperty("endpoint") @ExcludeMissing fun _endpoint(): JsonField = endpoint + fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = + s3ForcePathStyle(JsonField.of(s3ForcePathStyle)) /** - * Returns the raw JSON value of [secretKey]. + * Sets [Builder.s3ForcePathStyle] to an arbitrary JSON value. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected - * type. + * 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. */ - @JsonProperty("secretKey") - @ExcludeMissing - fun _secretKey(): JsonField = secretKey + fun s3ForcePathStyle(s3ForcePathStyle: JsonField) = apply { + this.s3ForcePathStyle = s3ForcePathStyle + } - /** - * 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 + fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Sets [Builder.sasToken] to an arbitrary JSON value. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has - * an unexpected type. + * 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. */ - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } - /** - * 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 + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Returns the raw JSON value of [prefix]. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + + fun username(username: String) = username(JsonField.of(username)) /** - * Returns the raw JSON value of [s3ForcePathStyle]. + * Sets [Builder.username] to an arbitrary JSON value. * - * Unlike [s3ForcePathStyle], this method doesn't throw if the JSON field has an - * unexpected type. + * 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. */ - @JsonProperty("s3ForcePathStyle") - @ExcludeMissing - fun _s3ForcePathStyle(): JsonField = s3ForcePathStyle + fun username(username: JsonField) = apply { this.username = username } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(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 [S3CompatibleOrigin]. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .endpoint() - * .name() - * .secretKey() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** A builder for [S3CompatibleOrigin]. */ - 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: JsonField? = null - 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(s3CompatibleOrigin: S3CompatibleOrigin) = apply { - accessKey = s3CompatibleOrigin.accessKey - bucket = s3CompatibleOrigin.bucket - endpoint = s3CompatibleOrigin.endpoint - name = s3CompatibleOrigin.name - secretKey = s3CompatibleOrigin.secretKey - type = s3CompatibleOrigin.type - baseUrlForCanonicalHeader = s3CompatibleOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = s3CompatibleOrigin.includeCanonicalHeader - prefix = s3CompatibleOrigin.prefix - s3ForcePathStyle = s3CompatibleOrigin.s3ForcePathStyle - additionalProperties = s3CompatibleOrigin.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 } - - 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 } - - /** 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 [S3CompatibleOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .endpoint() - * .name() - * .secretKey() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): S3CompatibleOrigin = - S3CompatibleOrigin( - checkRequired("accessKey", accessKey), - checkRequired("bucket", bucket), - checkRequired("endpoint", endpoint), - checkRequired("name", name), - checkRequired("secretKey", secretKey), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - s3ForcePathStyle, - additionalProperties.toMutableMap(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - private var validated: Boolean = false - - fun validate(): S3CompatibleOrigin = apply { - if (validated) { - return@apply - } - - accessKey() - bucket() - endpoint() - name() - secretKey() - type().validate() - baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - s3ForcePathStyle() - validated = true - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [Body]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @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.asKnown().getOrNull()?.validity() ?: 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) - - 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 S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val S3 = of("S3") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3_COMPATIBLE, - S3, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - S3_COMPATIBLE, - S3, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - S3_COMPATIBLE -> Value.S3_COMPATIBLE - S3 -> Value.S3 - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3_COMPATIBLE -> Known.S3_COMPATIBLE - S3 -> Known.S3 - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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 S3CompatibleOrigin && - 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( + fun build(): Body = + Body( + checkRequired("name", name), + checkRequired("type", type), accessKey, + accountName, + baseUrl, + baseUrlForCanonicalHeader, bucket, + clientEmail, + clientId, + clientSecret, + container, endpoint, - name, - secretKey, - type, - baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, includeCanonicalHeader, + password, prefix, + privateKey, s3ForcePathStyle, - additionalProperties, + sasToken, + secretKey, + username, + additionalProperties.toMutableMap(), ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + type().validate() + accessKey() + accountName() + baseUrl() + baseUrlForCanonicalHeader() + bucket() + clientEmail() + clientId() + clientSecret() + container() + endpoint() + forwardHostHeaderToOrigin() + includeCanonicalHeader() + password() + prefix() + privateKey() + s3ForcePathStyle() + sasToken() + secretKey() + username() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - override fun hashCode(): Int = hashCode + /** + * Returns a 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (accessKey.asKnown().isPresent) 1 else 0) + + (if (accountName.asKnown().isPresent) 1 else 0) + + (if (baseUrl.asKnown().isPresent) 1 else 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (bucket.asKnown().isPresent) 1 else 0) + + (if (clientEmail.asKnown().isPresent) 1 else 0) + + (if (clientId.asKnown().isPresent) 1 else 0) + + (if (clientSecret.asKnown().isPresent) 1 else 0) + + (if (container.asKnown().isPresent) 1 else 0) + + (if (endpoint.asKnown().isPresent) 1 else 0) + + (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + (if (privateKey.asKnown().isPresent) 1 else 0) + + (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + + (if (sasToken.asKnown().isPresent) 1 else 0) + + (if (secretKey.asKnown().isPresent) 1 else 0) + + (if (username.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun toString() = - "S3CompatibleOrigin{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" + return other is Body && + name == other.name && + type == other.type && + accessKey == other.accessKey && + accountName == other.accountName && + baseUrl == other.baseUrl && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + bucket == other.bucket && + clientEmail == other.clientEmail && + clientId == other.clientId && + clientSecret == other.clientSecret && + container == other.container && + endpoint == other.endpoint && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && + password == other.password && + prefix == other.prefix && + privateKey == other.privateKey && + s3ForcePathStyle == other.s3ForcePathStyle && + sasToken == other.sasToken && + secretKey == other.secretKey && + username == other.username && + additionalProperties == other.additionalProperties } - class CloudinaryBackupOrigin - private constructor( - private val accessKey: JsonField, - private val bucket: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonField, - 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: JsonField = 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, + private val hashCode: Int by lazy { + Objects.hash( name, - secretKey, type, + accessKey, + accountName, + baseUrl, baseUrlForCanonicalHeader, + bucket, + clientEmail, + clientId, + clientSecret, + container, + endpoint, + forwardHostHeaderToOrigin, includeCanonicalHeader, + password, prefix, - mutableMapOf(), + privateKey, + s3ForcePathStyle, + sasToken, + secretKey, + username, + additionalProperties, ) + } - /** - * 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") + override fun hashCode(): Int = hashCode - /** - * 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") + override fun toString() = + "Body{name=$name, type=$type, accessKey=$accessKey, accountName=$accountName, baseUrl=$baseUrl, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, bucket=$bucket, clientEmail=$clientEmail, clientId=$clientId, clientSecret=$clientSecret, container=$container, endpoint=$endpoint, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, password=$password, prefix=$prefix, privateKey=$privateKey, s3ForcePathStyle=$s3ForcePathStyle, sasToken=$sasToken, secretKey=$secretKey, username=$username, additionalProperties=$additionalProperties}" + } - /** - * 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw JSON value 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 [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 [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 this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @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) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [CloudinaryBackupOrigin]. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .name() - * .secretKey() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmField val S3 = of("S3") - /** A builder for [CloudinaryBackupOrigin]. */ - 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: JsonField? = null - 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(cloudinaryBackupOrigin: CloudinaryBackupOrigin) = apply { - accessKey = cloudinaryBackupOrigin.accessKey - bucket = cloudinaryBackupOrigin.bucket - name = cloudinaryBackupOrigin.name - secretKey = cloudinaryBackupOrigin.secretKey - type = cloudinaryBackupOrigin.type - baseUrlForCanonicalHeader = cloudinaryBackupOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = cloudinaryBackupOrigin.includeCanonicalHeader - prefix = cloudinaryBackupOrigin.prefix - additionalProperties = - cloudinaryBackupOrigin.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 } - - 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 } - - /** 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 [CloudinaryBackupOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .name() - * .secretKey() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CloudinaryBackupOrigin = - CloudinaryBackupOrigin( - checkRequired("accessKey", accessKey), - checkRequired("bucket", bucket), - checkRequired("name", name), - checkRequired("secretKey", secretKey), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties.toMutableMap(), - ) - } + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - private var validated: Boolean = false - - fun validate(): CloudinaryBackupOrigin = apply { - if (validated) { - return@apply - } - - accessKey() - bucket() - name() - secretKey() - type().validate() - baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - validated = true - } + @JvmField val WEB_FOLDER = of("WEB_FOLDER") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + @JvmField val WEB_PROXY = of("WEB_PROXY") - /** - * Returns a 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) - - 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY_BACKUP, - S3, - S3_COMPATIBLE, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - CLOUDINARY_BACKUP, - S3, - S3_COMPATIBLE, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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() - } + @JvmField val GCS = of("GCS") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CloudinaryBackupOrigin && - 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 - } + @JvmField val AZURE_BLOB = of("AZURE_BLOB") - private val hashCode: Int by lazy { - Objects.hash( - accessKey, - bucket, - name, - secretKey, - type, - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties, - ) - } + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - override fun hashCode(): Int = hashCode + @JvmField val AKENEO_PIM = of("AKENEO_PIM") - override fun toString() = - "CloudinaryBackupOrigin{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - class WebFolderOrigin - private constructor( - private val baseUrl: JsonField, - private val name: JsonField, - private val type: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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) - } + /** An enum containing [Type]'s known values. */ + enum class Known { + S3, + S3_COMPATIBLE, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + CLOUDINARY_BACKUP, + AKENEO_PIM, + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [WebFolderOrigin]. - * - * The following fields are required: - * ```java - * .baseUrl() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * 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 { + S3, + S3_COMPATIBLE, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + CLOUDINARY_BACKUP, + AKENEO_PIM, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } - /** A builder for [WebFolderOrigin]. */ - class Builder internal constructor() { - - private var baseUrl: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - 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(webFolderOrigin: WebFolderOrigin) = apply { - baseUrl = webFolderOrigin.baseUrl - name = webFolderOrigin.name - type = webFolderOrigin.type - baseUrlForCanonicalHeader = webFolderOrigin.baseUrlForCanonicalHeader - forwardHostHeaderToOrigin = webFolderOrigin.forwardHostHeaderToOrigin - includeCanonicalHeader = webFolderOrigin.includeCanonicalHeader - additionalProperties = webFolderOrigin.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 } - - 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 } - - /** 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 [WebFolderOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .baseUrl() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): WebFolderOrigin = - WebFolderOrigin( - checkRequired("baseUrl", baseUrl), - checkRequired("name", name), - checkRequired("type", type), - baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, - additionalProperties.toMutableMap(), - ) + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN } - private var validated: Boolean = false - - fun validate(): WebFolderOrigin = apply { - if (validated) { - return@apply - } - - baseUrl() - name() - type().validate() - baseUrlForCanonicalHeader() - forwardHostHeaderToOrigin() - includeCanonicalHeader() - validated = 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) { + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + AKENEO_PIM -> Known.AKENEO_PIM + else -> throw ImageKitInvalidDataException("Unknown Type: $value") } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_FOLDER, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - WEB_FOLDER, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - WEB_FOLDER -> Value.WEB_FOLDER - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_FOLDER -> Known.WEB_FOLDER - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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() + /** + * Returns this class 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 WebFolderOrigin && - baseUrl == other.baseUrl && - name == other.name && - type == other.type && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && - additionalProperties == other.additionalProperties - } + private var validated: Boolean = false - private val hashCode: Int by lazy { - Objects.hash( - baseUrl, - name, - type, - baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, - additionalProperties, - ) + fun validate(): Type = apply { + if (validated) { + return@apply } - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebFolderOrigin{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + known() + validated = true } - class WebProxyOrigin - private constructor( - private val name: JsonField, - private val type: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [WebProxyOrigin]. - * - * The following fields are required: - * ```java - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebProxyOrigin]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var type: JsonField? = null - private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(webProxyOrigin: WebProxyOrigin) = apply { - name = webProxyOrigin.name - type = webProxyOrigin.type - baseUrlForCanonicalHeader = webProxyOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = webProxyOrigin.includeCanonicalHeader - additionalProperties = webProxyOrigin.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 } - - 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 } - - /** 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 [WebProxyOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): WebProxyOrigin = - WebProxyOrigin( - checkRequired("name", name), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - additionalProperties.toMutableMap(), - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - private var validated: Boolean = false - - fun validate(): WebProxyOrigin = apply { - if (validated) { - return@apply - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - name() - type().validate() - baseUrlForCanonicalHeader() - includeCanonicalHeader() - validated = true + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 WEB_PROXY = of("WEB_PROXY") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_PROXY, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - WEB_PROXY, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - WEB_PROXY -> Value.WEB_PROXY - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_PROXY -> Known.WEB_PROXY - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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() - } + return other is Type && value == other.value + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is WebProxyOrigin && - name == other.name && - type == other.type && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - additionalProperties == other.additionalProperties - } + override fun hashCode() = value.hashCode() - private val hashCode: Int by lazy { - Objects.hash( - name, - type, - baseUrlForCanonicalHeader, - includeCanonicalHeader, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebProxyOrigin{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" - } - - class GcsOrigin - private constructor( - private val bucket: JsonField, - private val clientEmail: JsonField, - private val name: JsonField, - private val privateKey: JsonField, - private val type: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [GcsOrigin]. - * - * The following fields are required: - * ```java - * .bucket() - * .clientEmail() - * .name() - * .privateKey() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GcsOrigin]. */ - 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: JsonField? = null - 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(gcsOrigin: GcsOrigin) = apply { - bucket = gcsOrigin.bucket - clientEmail = gcsOrigin.clientEmail - name = gcsOrigin.name - privateKey = gcsOrigin.privateKey - type = gcsOrigin.type - baseUrlForCanonicalHeader = gcsOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = gcsOrigin.includeCanonicalHeader - prefix = gcsOrigin.prefix - additionalProperties = gcsOrigin.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 - } - - 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 } - - /** 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 [GcsOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .bucket() - * .clientEmail() - * .name() - * .privateKey() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GcsOrigin = - GcsOrigin( - checkRequired("bucket", bucket), - checkRequired("clientEmail", clientEmail), - checkRequired("name", name), - checkRequired("privateKey", privateKey), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GcsOrigin = apply { - if (validated) { - return@apply - } - - bucket() - clientEmail() - name() - privateKey() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) - - 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 GCS = of("GCS") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GCS, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - GCS, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - GCS -> Value.GCS - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GCS -> Known.GCS - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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 GcsOrigin && - 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() = - "GcsOrigin{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" - } - - class AzureBlobOrigin - private constructor( - private val accountName: JsonField, - private val container: JsonField, - private val name: JsonField, - private val sasToken: JsonField, - private val type: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [AzureBlobOrigin]. - * - * The following fields are required: - * ```java - * .accountName() - * .container() - * .name() - * .sasToken() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AzureBlobOrigin]. */ - 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: JsonField? = null - 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(azureBlobOrigin: AzureBlobOrigin) = apply { - accountName = azureBlobOrigin.accountName - container = azureBlobOrigin.container - name = azureBlobOrigin.name - sasToken = azureBlobOrigin.sasToken - type = azureBlobOrigin.type - baseUrlForCanonicalHeader = azureBlobOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobOrigin.includeCanonicalHeader - prefix = azureBlobOrigin.prefix - additionalProperties = azureBlobOrigin.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 } - - 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 } - - /** 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 [AzureBlobOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accountName() - * .container() - * .name() - * .sasToken() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AzureBlobOrigin = - AzureBlobOrigin( - checkRequired("accountName", accountName), - checkRequired("container", container), - checkRequired("name", name), - checkRequired("sasToken", sasToken), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AzureBlobOrigin = apply { - if (validated) { - return@apply - } - - accountName() - container() - name() - sasToken() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) - - 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 AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AZURE_BLOB, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AKENEO_PIM, - } - - /** - * 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 { - AZURE_BLOB, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AKENEO_PIM, - /** - * 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) { - AZURE_BLOB -> Value.AZURE_BLOB - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AZURE_BLOB -> Known.AZURE_BLOB - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AKENEO_PIM -> Known.AKENEO_PIM - 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 AzureBlobOrigin && - 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() = - "AzureBlobOrigin{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" - } - - class AkeneoPimOrigin - 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: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [AkeneoPimOrigin]. - * - * The following fields are required: - * ```java - * .baseUrl() - * .clientId() - * .clientSecret() - * .name() - * .password() - * .type() - * .username() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AkeneoPimOrigin]. */ - 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: JsonField? = null - 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(akeneoPimOrigin: AkeneoPimOrigin) = apply { - baseUrl = akeneoPimOrigin.baseUrl - clientId = akeneoPimOrigin.clientId - clientSecret = akeneoPimOrigin.clientSecret - name = akeneoPimOrigin.name - password = akeneoPimOrigin.password - type = akeneoPimOrigin.type - username = akeneoPimOrigin.username - baseUrlForCanonicalHeader = akeneoPimOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = akeneoPimOrigin.includeCanonicalHeader - additionalProperties = akeneoPimOrigin.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 } - - 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 } - - /** 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 [AkeneoPimOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .baseUrl() - * .clientId() - * .clientSecret() - * .name() - * .password() - * .type() - * .username() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AkeneoPimOrigin = - AkeneoPimOrigin( - checkRequired("baseUrl", baseUrl), - checkRequired("clientId", clientId), - checkRequired("clientSecret", clientSecret), - checkRequired("name", name), - checkRequired("password", password), - checkRequired("type", type), - checkRequired("username", username), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AkeneoPimOrigin = apply { - if (validated) { - return@apply - } - - baseUrl() - clientId() - clientSecret() - name() - password() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (username.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 AKENEO_PIM = of("AKENEO_PIM") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKENEO_PIM, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - } - - /** - * 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 { - AKENEO_PIM, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - /** - * 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) { - AKENEO_PIM -> Value.AKENEO_PIM - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKENEO_PIM -> Known.AKENEO_PIM - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - 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 AkeneoPimOrigin && - 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() = - "AkeneoPimOrigin{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" - } + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { 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 7ca71491..9ab81213 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 @@ -6,24 +6,13 @@ import 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.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.errors.ImageKitInvalidDataException @@ -49,8 +38,284 @@ private constructor( */ fun id(): Optional = Optional.ofNullable(id) - /** Schema for origin resources. */ - fun body(): Body = body + /** + * @throws ImageKitInvalidDataException if the 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 type(): Type = body.type() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accessKey(): Optional = body.accessKey() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountName(): Optional = body.accountName() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun baseUrl(): Optional = body.baseUrl() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = body.baseUrlForCanonicalHeader() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bucket(): Optional = body.bucket() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientEmail(): Optional = body.clientEmail() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientId(): Optional = body.clientId() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientSecret(): Optional = body.clientSecret() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun container(): Optional = body.container() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endpoint(): Optional = body.endpoint() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun forwardHostHeaderToOrigin(): Optional = body.forwardHostHeaderToOrigin() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = body.includeCanonicalHeader() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun password(): Optional = body.password() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prefix(): Optional = body.prefix() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun privateKey(): Optional = body.privateKey() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun s3ForcePathStyle(): Optional = body.s3ForcePathStyle() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sasToken(): Optional = body.sasToken() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secretKey(): Optional = body.secretKey() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun username(): Optional = body.username() + + /** + * 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 [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _type(): JsonField = body._type() + + /** + * Returns the raw JSON value of [accessKey]. + * + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _accessKey(): JsonField = body._accessKey() + + /** + * Returns the raw JSON value of [accountName]. + * + * Unlike [accountName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _accountName(): JsonField = body._accountName() + + /** + * Returns the raw JSON value of [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _baseUrl(): JsonField = body._baseUrl() + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _baseUrlForCanonicalHeader(): JsonField = body._baseUrlForCanonicalHeader() + + /** + * Returns the raw JSON value of [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _bucket(): JsonField = body._bucket() + + /** + * Returns the raw JSON value of [clientEmail]. + * + * Unlike [clientEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _clientEmail(): JsonField = body._clientEmail() + + /** + * Returns the raw JSON value of [clientId]. + * + * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _clientId(): JsonField = body._clientId() + + /** + * Returns the raw JSON value of [clientSecret]. + * + * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _clientSecret(): JsonField = body._clientSecret() + + /** + * Returns the raw JSON value of [container]. + * + * Unlike [container], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _container(): JsonField = body._container() + + /** + * Returns the raw JSON value of [endpoint]. + * + * Unlike [endpoint], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endpoint(): JsonField = body._endpoint() + + /** + * Returns the raw JSON value of [forwardHostHeaderToOrigin]. + * + * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _forwardHostHeaderToOrigin(): JsonField = body._forwardHostHeaderToOrigin() + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _includeCanonicalHeader(): JsonField = body._includeCanonicalHeader() + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _password(): JsonField = body._password() + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _prefix(): JsonField = body._prefix() + + /** + * Returns the raw JSON value of [privateKey]. + * + * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _privateKey(): JsonField = body._privateKey() + + /** + * Returns the raw JSON value of [s3ForcePathStyle]. + * + * Unlike [s3ForcePathStyle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _s3ForcePathStyle(): JsonField = body._s3ForcePathStyle() + + /** + * Returns the raw JSON value of [sasToken]. + * + * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sasToken(): JsonField = body._sasToken() + + /** + * Returns the raw JSON value of [secretKey]. + * + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _secretKey(): JsonField = body._secretKey() + + /** + * Returns the raw JSON value of [username]. + * + * Unlike [username], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _username(): JsonField = body._username() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -67,7 +332,8 @@ private constructor( * * The following fields are required: * ```java - * .body() + * .name() + * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -77,14 +343,14 @@ private constructor( class Builder internal constructor() { private var id: String? = null - private var body: Body? = 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(originUpdateParams: OriginUpdateParams) = apply { id = originUpdateParams.id - body = originUpdateParams.body + body = originUpdateParams.body.toBuilder() additionalHeaders = originUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = originUpdateParams.additionalQueryParams.toBuilder() } @@ -98,39 +364,277 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Schema for origin resources. */ - fun body(body: Body) = apply { this.body = body } + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [type] + * - [accessKey] + * - [accountName] + * - [baseUrl] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + 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 type(type: Type) = apply { body.type(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 { body.type(type) } + + fun accessKey(accessKey: String) = apply { body.accessKey(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 { body.accessKey(accessKey) } + + fun accountName(accountName: String) = apply { body.accountName(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 { body.accountName(accountName) } + + fun baseUrl(baseUrl: String) = apply { body.baseUrl(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 { body.baseUrl(baseUrl) } + + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = apply { + body.baseUrlForCanonicalHeader(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 { + body.baseUrlForCanonicalHeader(baseUrlForCanonicalHeader) + } + + fun bucket(bucket: String) = apply { body.bucket(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 { body.bucket(bucket) } + + fun clientEmail(clientEmail: String) = apply { body.clientEmail(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 { body.clientEmail(clientEmail) } + + fun clientId(clientId: String) = apply { body.clientId(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 { body.clientId(clientId) } + + fun clientSecret(clientSecret: String) = apply { body.clientSecret(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 { + body.clientSecret(clientSecret) + } + + fun container(container: String) = apply { body.container(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 { body.container(container) } + + fun endpoint(endpoint: String) = apply { body.endpoint(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 { body.endpoint(endpoint) } + + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = apply { + body.forwardHostHeaderToOrigin(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 { + body.forwardHostHeaderToOrigin(forwardHostHeaderToOrigin) + } + + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = apply { + body.includeCanonicalHeader(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 { + body.includeCanonicalHeader(includeCanonicalHeader) + } + + fun password(password: String) = apply { body.password(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 { body.password(password) } + + fun prefix(prefix: String) = apply { body.prefix(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 { body.prefix(prefix) } + + fun privateKey(privateKey: String) = apply { body.privateKey(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 { body.privateKey(privateKey) } + + fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = apply { + body.s3ForcePathStyle(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 { + body.s3ForcePathStyle(s3ForcePathStyle) + } + + fun sasToken(sasToken: String) = apply { body.sasToken(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 { body.sasToken(sasToken) } + + fun secretKey(secretKey: String) = apply { body.secretKey(secretKey) } - /** Alias for calling [body] with `Body.ofS3Origin(s3Origin)`. */ - fun body(s3Origin: Body.S3Origin) = body(Body.ofS3Origin(s3Origin)) + /** + * 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 { body.secretKey(secretKey) } - /** Alias for calling [body] with `Body.ofS3CompatibleOrigin(s3CompatibleOrigin)`. */ - fun body(s3CompatibleOrigin: Body.S3CompatibleOrigin) = - body(Body.ofS3CompatibleOrigin(s3CompatibleOrigin)) + fun username(username: String) = apply { body.username(username) } /** - * Alias for calling [body] with `Body.ofCloudinaryBackupOrigin(cloudinaryBackupOrigin)`. + * 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 body(cloudinaryBackupOrigin: Body.CloudinaryBackupOrigin) = - body(Body.ofCloudinaryBackupOrigin(cloudinaryBackupOrigin)) + fun username(username: JsonField) = apply { body.username(username) } - /** Alias for calling [body] with `Body.ofWebFolderOrigin(webFolderOrigin)`. */ - fun body(webFolderOrigin: Body.WebFolderOrigin) = - body(Body.ofWebFolderOrigin(webFolderOrigin)) + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - /** Alias for calling [body] with `Body.ofWebProxyOrigin(webProxyOrigin)`. */ - fun body(webProxyOrigin: Body.WebProxyOrigin) = body(Body.ofWebProxyOrigin(webProxyOrigin)) + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } - /** Alias for calling [body] with `Body.ofGcsOrigin(gcsOrigin)`. */ - fun body(gcsOrigin: Body.GcsOrigin) = body(Body.ofGcsOrigin(gcsOrigin)) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } - /** Alias for calling [body] with `Body.ofAzureBlobOrigin(azureBlobOrigin)`. */ - fun body(azureBlobOrigin: Body.AzureBlobOrigin) = - body(Body.ofAzureBlobOrigin(azureBlobOrigin)) + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - /** Alias for calling [body] with `Body.ofAkeneoPimOrigin(akeneoPimOrigin)`. */ - fun body(akeneoPimOrigin: Body.AkeneoPimOrigin) = - body(Body.ofAkeneoPimOrigin(akeneoPimOrigin)) + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -237,7 +741,8 @@ private constructor( * * The following fields are required: * ```java - * .body() + * .name() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -245,7 +750,7 @@ private constructor( fun build(): OriginUpdateParams = OriginUpdateParams( id, - checkRequired("body", body), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), ) @@ -263,5329 +768,1086 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - /** Schema for origin resources. */ - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) class Body private constructor( - private val s3Origin: S3Origin? = null, - private val s3CompatibleOrigin: S3CompatibleOrigin? = null, - private val cloudinaryBackupOrigin: CloudinaryBackupOrigin? = null, - private val webFolderOrigin: WebFolderOrigin? = null, - private val webProxyOrigin: WebProxyOrigin? = null, - private val gcsOrigin: GcsOrigin? = null, - private val azureBlobOrigin: AzureBlobOrigin? = null, - private val akeneoPimOrigin: AkeneoPimOrigin? = null, - private val _json: JsonValue? = null, + private val name: JsonField, + private val type: JsonField, + private val accessKey: JsonField, + private val accountName: JsonField, + private val baseUrl: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val bucket: JsonField, + private val clientEmail: JsonField, + private val clientId: JsonField, + private val clientSecret: JsonField, + private val container: JsonField, + private val endpoint: JsonField, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, + private val password: JsonField, + private val prefix: JsonField, + private val privateKey: JsonField, + private val s3ForcePathStyle: JsonField, + private val sasToken: JsonField, + private val secretKey: JsonField, + private val username: JsonField, + private val additionalProperties: MutableMap, ) { - fun s3Origin(): Optional = Optional.ofNullable(s3Origin) - - fun s3CompatibleOrigin(): Optional = - Optional.ofNullable(s3CompatibleOrigin) - - fun cloudinaryBackupOrigin(): Optional = - Optional.ofNullable(cloudinaryBackupOrigin) - - fun webFolderOrigin(): Optional = Optional.ofNullable(webFolderOrigin) - - fun webProxyOrigin(): Optional = Optional.ofNullable(webProxyOrigin) - - fun gcsOrigin(): Optional = Optional.ofNullable(gcsOrigin) - - fun azureBlobOrigin(): Optional = Optional.ofNullable(azureBlobOrigin) - - fun akeneoPimOrigin(): Optional = Optional.ofNullable(akeneoPimOrigin) - - fun isS3Origin(): Boolean = s3Origin != null - - fun isS3CompatibleOrigin(): Boolean = s3CompatibleOrigin != null - - fun isCloudinaryBackupOrigin(): Boolean = cloudinaryBackupOrigin != null - - fun isWebFolderOrigin(): Boolean = webFolderOrigin != null - - fun isWebProxyOrigin(): Boolean = webProxyOrigin != null - - fun isGcsOrigin(): Boolean = gcsOrigin != null - - fun isAzureBlobOrigin(): Boolean = azureBlobOrigin != null + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("accessKey") + @ExcludeMissing + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("accountName") + @ExcludeMissing + accountName: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("clientEmail") + @ExcludeMissing + clientEmail: JsonField = JsonMissing.of(), + @JsonProperty("clientId") + @ExcludeMissing + clientId: JsonField = JsonMissing.of(), + @JsonProperty("clientSecret") + @ExcludeMissing + clientSecret: JsonField = JsonMissing.of(), + @JsonProperty("container") + @ExcludeMissing + container: JsonField = JsonMissing.of(), + @JsonProperty("endpoint") + @ExcludeMissing + endpoint: JsonField = JsonMissing.of(), + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("password") + @ExcludeMissing + password: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("privateKey") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + s3ForcePathStyle: JsonField = JsonMissing.of(), + @JsonProperty("sasToken") + @ExcludeMissing + sasToken: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), + @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), + ) : this( + name, + type, + accessKey, + accountName, + baseUrl, + baseUrlForCanonicalHeader, + bucket, + clientEmail, + clientId, + clientSecret, + container, + endpoint, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + password, + prefix, + privateKey, + s3ForcePathStyle, + sasToken, + secretKey, + username, + mutableMapOf(), + ) - fun isAkeneoPimOrigin(): Boolean = akeneoPimOrigin != null + /** + * @throws ImageKitInvalidDataException if the 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") - fun asS3Origin(): S3Origin = s3Origin.getOrThrow("s3Origin") + /** + * @throws ImageKitInvalidDataException if 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") - fun asS3CompatibleOrigin(): S3CompatibleOrigin = - s3CompatibleOrigin.getOrThrow("s3CompatibleOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accessKey(): Optional = accessKey.getOptional("accessKey") - fun asCloudinaryBackupOrigin(): CloudinaryBackupOrigin = - cloudinaryBackupOrigin.getOrThrow("cloudinaryBackupOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun accountName(): Optional = accountName.getOptional("accountName") - fun asWebFolderOrigin(): WebFolderOrigin = webFolderOrigin.getOrThrow("webFolderOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrl(): Optional = baseUrl.getOptional("baseUrl") - fun asWebProxyOrigin(): WebProxyOrigin = webProxyOrigin.getOrThrow("webProxyOrigin") + /** + * @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") - fun asGcsOrigin(): GcsOrigin = gcsOrigin.getOrThrow("gcsOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun bucket(): Optional = bucket.getOptional("bucket") - fun asAzureBlobOrigin(): AzureBlobOrigin = azureBlobOrigin.getOrThrow("azureBlobOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun clientEmail(): Optional = clientEmail.getOptional("clientEmail") - fun asAkeneoPimOrigin(): AkeneoPimOrigin = akeneoPimOrigin.getOrThrow("akeneoPimOrigin") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun clientId(): Optional = clientId.getOptional("clientId") - fun _json(): Optional = Optional.ofNullable(_json) + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun clientSecret(): Optional = clientSecret.getOptional("clientSecret") - fun accept(visitor: Visitor): T = - when { - s3Origin != null -> visitor.visitS3Origin(s3Origin) - s3CompatibleOrigin != null -> visitor.visitS3CompatibleOrigin(s3CompatibleOrigin) - cloudinaryBackupOrigin != null -> - visitor.visitCloudinaryBackupOrigin(cloudinaryBackupOrigin) - webFolderOrigin != null -> visitor.visitWebFolderOrigin(webFolderOrigin) - webProxyOrigin != null -> visitor.visitWebProxyOrigin(webProxyOrigin) - gcsOrigin != null -> visitor.visitGcsOrigin(gcsOrigin) - azureBlobOrigin != null -> visitor.visitAzureBlobOrigin(azureBlobOrigin) - akeneoPimOrigin != null -> visitor.visitAkeneoPimOrigin(akeneoPimOrigin) - else -> visitor.unknown(_json) - } + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun container(): Optional = container.getOptional("container") - private var validated: Boolean = false + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endpoint(): Optional = endpoint.getOptional("endpoint") - fun validate(): Body = apply { - if (validated) { - return@apply - } + /** + * @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") - accept( - object : Visitor { - override fun visitS3Origin(s3Origin: S3Origin) { - s3Origin.validate() - } - - override fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) { - s3CompatibleOrigin.validate() - } - - override fun visitCloudinaryBackupOrigin( - cloudinaryBackupOrigin: CloudinaryBackupOrigin - ) { - cloudinaryBackupOrigin.validate() - } - - override fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin) { - webFolderOrigin.validate() - } - - override fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin) { - webProxyOrigin.validate() - } - - override fun visitGcsOrigin(gcsOrigin: GcsOrigin) { - gcsOrigin.validate() - } - - override fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) { - azureBlobOrigin.validate() - } - - override fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) { - akeneoPimOrigin.validate() - } - } - ) - validated = true - } + /** + * @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") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional = password.getOptional("password") /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitS3Origin(s3Origin: S3Origin) = s3Origin.validity() + fun prefix(): Optional = prefix.getOptional("prefix") - override fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) = - s3CompatibleOrigin.validity() + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun privateKey(): Optional = privateKey.getOptional("privateKey") - override fun visitCloudinaryBackupOrigin( - cloudinaryBackupOrigin: CloudinaryBackupOrigin - ) = cloudinaryBackupOrigin.validity() + /** + * @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") - override fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin) = - webFolderOrigin.validity() + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sasToken(): Optional = sasToken.getOptional("sasToken") - override fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin) = - webProxyOrigin.validity() + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun secretKey(): Optional = secretKey.getOptional("secretKey") - override fun visitGcsOrigin(gcsOrigin: GcsOrigin) = gcsOrigin.validity() + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun username(): Optional = username.getOptional("username") - override fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) = - azureBlobOrigin.validity() + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) = - akeneoPimOrigin.validity() + /** + * 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 - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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 - return other is Body && - s3Origin == other.s3Origin && - s3CompatibleOrigin == other.s3CompatibleOrigin && - cloudinaryBackupOrigin == other.cloudinaryBackupOrigin && - webFolderOrigin == other.webFolderOrigin && - webProxyOrigin == other.webProxyOrigin && - gcsOrigin == other.gcsOrigin && - azureBlobOrigin == other.azureBlobOrigin && - akeneoPimOrigin == other.akeneoPimOrigin - } + /** + * 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 - override fun hashCode(): Int = - Objects.hash( - s3Origin, - s3CompatibleOrigin, - cloudinaryBackupOrigin, - webFolderOrigin, - webProxyOrigin, - gcsOrigin, - azureBlobOrigin, - akeneoPimOrigin, - ) + /** + * 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 - override fun toString(): String = - when { - s3Origin != null -> "Body{s3Origin=$s3Origin}" - s3CompatibleOrigin != null -> "Body{s3CompatibleOrigin=$s3CompatibleOrigin}" - cloudinaryBackupOrigin != null -> - "Body{cloudinaryBackupOrigin=$cloudinaryBackupOrigin}" - webFolderOrigin != null -> "Body{webFolderOrigin=$webFolderOrigin}" - webProxyOrigin != null -> "Body{webProxyOrigin=$webProxyOrigin}" - gcsOrigin != null -> "Body{gcsOrigin=$gcsOrigin}" - azureBlobOrigin != null -> "Body{azureBlobOrigin=$azureBlobOrigin}" - akeneoPimOrigin != null -> "Body{akeneoPimOrigin=$akeneoPimOrigin}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") - } + /** + * 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 - companion object { + /** + * 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 - @JvmStatic fun ofS3Origin(s3Origin: S3Origin) = Body(s3Origin = s3Origin) + /** + * 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 - @JvmStatic - fun ofS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin) = - Body(s3CompatibleOrigin = s3CompatibleOrigin) + /** + * 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 - @JvmStatic - fun ofCloudinaryBackupOrigin(cloudinaryBackupOrigin: CloudinaryBackupOrigin) = - Body(cloudinaryBackupOrigin = cloudinaryBackupOrigin) + /** + * 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 - @JvmStatic - fun ofWebFolderOrigin(webFolderOrigin: WebFolderOrigin) = - Body(webFolderOrigin = webFolderOrigin) + /** + * 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 - @JvmStatic - fun ofWebProxyOrigin(webProxyOrigin: WebProxyOrigin) = - Body(webProxyOrigin = webProxyOrigin) + /** + * 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 - @JvmStatic fun ofGcsOrigin(gcsOrigin: GcsOrigin) = Body(gcsOrigin = gcsOrigin) + /** + * 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 - @JvmStatic - fun ofAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin) = - Body(azureBlobOrigin = azureBlobOrigin) + /** + * 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 - @JvmStatic - fun ofAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin) = - Body(akeneoPimOrigin = akeneoPimOrigin) - } + /** + * 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 - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ - interface Visitor { + /** + * 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 - fun visitS3Origin(s3Origin: S3Origin): T + /** + * 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 - fun visitS3CompatibleOrigin(s3CompatibleOrigin: S3CompatibleOrigin): T + /** + * 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 - fun visitCloudinaryBackupOrigin(cloudinaryBackupOrigin: CloudinaryBackupOrigin): T + /** + * 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 - fun visitWebFolderOrigin(webFolderOrigin: WebFolderOrigin): T + /** + * 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 - fun visitWebProxyOrigin(webProxyOrigin: WebProxyOrigin): T + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun visitGcsOrigin(gcsOrigin: GcsOrigin): T + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun visitAzureBlobOrigin(azureBlobOrigin: AzureBlobOrigin): T + fun toBuilder() = Builder().from(this) - fun visitAkeneoPimOrigin(akeneoPimOrigin: AkeneoPimOrigin): T + companion object { /** - * 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. + * Returns a mutable builder for constructing an instance of [Body]. * - * @throws ImageKitInvalidDataException in the default implementation. + * The following fields are required: + * ```java + * .name() + * .type() + * ``` */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Body: $json") - } + @JvmStatic fun builder() = Builder() } - internal class Deserializer : BaseDeserializer(Body::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Body { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) {} - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Origin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3CompatibleOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackupOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolderOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxyOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(gcsOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlobOrigin = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPimOrigin = 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() - } - } - } + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var type: JsonField? = null + private var accessKey: JsonField = JsonMissing.of() + private var accountName: JsonField = JsonMissing.of() + private var baseUrl: JsonField = JsonMissing.of() + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var bucket: JsonField = JsonMissing.of() + private var clientEmail: JsonField = JsonMissing.of() + private var clientId: JsonField = JsonMissing.of() + private var clientSecret: JsonField = JsonMissing.of() + private var container: JsonField = JsonMissing.of() + private var endpoint: JsonField = JsonMissing.of() + private var forwardHostHeaderToOrigin: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var password: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var privateKey: JsonField = JsonMissing.of() + private var s3ForcePathStyle: JsonField = JsonMissing.of() + private var sasToken: JsonField = JsonMissing.of() + private var secretKey: JsonField = JsonMissing.of() + private var username: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - internal class Serializer : BaseSerializer(Body::class) { - - override fun serialize( - value: Body, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.s3Origin != null -> generator.writeObject(value.s3Origin) - value.s3CompatibleOrigin != null -> - generator.writeObject(value.s3CompatibleOrigin) - value.cloudinaryBackupOrigin != null -> - generator.writeObject(value.cloudinaryBackupOrigin) - value.webFolderOrigin != null -> generator.writeObject(value.webFolderOrigin) - value.webProxyOrigin != null -> generator.writeObject(value.webProxyOrigin) - value.gcsOrigin != null -> generator.writeObject(value.gcsOrigin) - value.azureBlobOrigin != null -> generator.writeObject(value.azureBlobOrigin) - value.akeneoPimOrigin != null -> generator.writeObject(value.akeneoPimOrigin) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") - } + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + type = body.type + accessKey = body.accessKey + accountName = body.accountName + baseUrl = body.baseUrl + baseUrlForCanonicalHeader = body.baseUrlForCanonicalHeader + bucket = body.bucket + clientEmail = body.clientEmail + clientId = body.clientId + clientSecret = body.clientSecret + container = body.container + endpoint = body.endpoint + forwardHostHeaderToOrigin = body.forwardHostHeaderToOrigin + includeCanonicalHeader = body.includeCanonicalHeader + password = body.password + prefix = body.prefix + privateKey = body.privateKey + s3ForcePathStyle = body.s3ForcePathStyle + sasToken = body.sasToken + secretKey = body.secretKey + username = body.username + additionalProperties = body.additionalProperties.toMutableMap() } - } - class S3Origin - private constructor( - private val accessKey: JsonField, - private val bucket: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonField, - 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: JsonField = 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(), - ) + fun name(name: String) = name(JsonField.of(name)) /** - * Access key for the bucket. + * Sets [Builder.name] to an arbitrary JSON 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.name] 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(): String = accessKey.getRequired("accessKey") + fun name(name: JsonField) = apply { this.name = name } - /** - * 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") + fun type(type: Type) = type(JsonField.of(type)) /** - * Display name of the origin. + * Sets [Builder.type] to an arbitrary JSON 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.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 name(): String = name.getRequired("name") + fun type(type: JsonField) = apply { this.type = type } + + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Secret key for the bucket. + * Sets [Builder.accessKey] to an arbitrary JSON 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.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 secretKey(): String = secretKey.getRequired("secretKey") + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } - /** - * @throws ImageKitInvalidDataException if 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") + fun accountName(accountName: String) = accountName(JsonField.of(accountName)) /** - * URL used in the Canonical header (if enabled). + * Sets [Builder.accountName] to an arbitrary JSON 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.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 baseUrlForCanonicalHeader(): Optional = - baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + fun accountName(accountName: JsonField) = apply { + this.accountName = accountName + } - /** - * 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") + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) /** - * Path prefix inside the bucket. + * Sets [Builder.baseUrl] to an arbitrary JSON 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.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 prefix(): Optional = prefix.getOptional("prefix") + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) /** - * Returns the raw JSON value of [accessKey]. + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected - * type. + * 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. */ - @JsonProperty("accessKey") - @ExcludeMissing - fun _accessKey(): JsonField = accessKey + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) /** - * Returns the raw JSON value of [bucket]. + * Sets [Builder.bucket] to an arbitrary JSON value. * - * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + fun clientEmail(clientEmail: String) = clientEmail(JsonField.of(clientEmail)) /** - * Returns the raw JSON value of [name]. + * Sets [Builder.clientEmail] to an arbitrary JSON value. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun clientEmail(clientEmail: JsonField) = apply { + this.clientEmail = clientEmail + } + + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) /** - * Returns the raw JSON value of [secretKey]. + * Sets [Builder.clientId] to an arbitrary JSON value. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected - * type. + * 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. */ - @JsonProperty("secretKey") - @ExcludeMissing - fun _secretKey(): JsonField = secretKey + fun clientId(clientId: JsonField) = apply { this.clientId = clientId } + + fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) /** - * Returns the raw JSON value of [type]. + * Sets [Builder.clientSecret] to an arbitrary JSON value. * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + fun clientSecret(clientSecret: JsonField) = apply { + this.clientSecret = clientSecret + } + + fun container(container: String) = container(JsonField.of(container)) /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Sets [Builder.container] to an arbitrary JSON value. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has - * an unexpected type. + * 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. */ - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + fun container(container: JsonField) = apply { this.container = container } + + fun endpoint(endpoint: String) = endpoint(JsonField.of(endpoint)) /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Sets [Builder.endpoint] to an arbitrary JSON value. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * 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. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun endpoint(endpoint: JsonField) = apply { this.endpoint = endpoint } + + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = + forwardHostHeaderToOrigin(JsonField.of(forwardHostHeaderToOrigin)) /** - * Returns the raw JSON value of [prefix]. + * Sets [Builder.forwardHostHeaderToOrigin] to an arbitrary JSON value. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @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 [S3Origin]. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .name() - * .secretKey() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [S3Origin]. */ - 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: JsonField? = null - 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(s3Origin: S3Origin) = apply { - accessKey = s3Origin.accessKey - bucket = s3Origin.bucket - name = s3Origin.name - secretKey = s3Origin.secretKey - type = s3Origin.type - baseUrlForCanonicalHeader = s3Origin.baseUrlForCanonicalHeader - includeCanonicalHeader = s3Origin.includeCanonicalHeader - prefix = s3Origin.prefix - additionalProperties = s3Origin.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 } - - 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 } - - /** 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 [S3Origin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .name() - * .secretKey() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): S3Origin = - S3Origin( - checkRequired("accessKey", accessKey), - checkRequired("bucket", bucket), - checkRequired("name", name), - checkRequired("secretKey", secretKey), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): S3Origin = apply { - if (validated) { - return@apply - } - - accessKey() - bucket() - name() - secretKey() - type().validate() - baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - validated = true + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: JsonField) = apply { + this.forwardHostHeaderToOrigin = forwardHostHeaderToOrigin } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. * - * Used for best match union deserialization. + * 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. */ - @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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) - - 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 S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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 S3Origin && - 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, - ) + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader } - override fun hashCode(): Int = hashCode - - override fun toString() = - "S3Origin{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" - } - - class S3CompatibleOrigin - 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: JsonField, - 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: JsonField = 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(), - ) + fun password(password: String) = password(JsonField.of(password)) /** - * Access key for the bucket. + * Sets [Builder.password] to an arbitrary JSON 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.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 accessKey(): String = accessKey.getRequired("accessKey") + fun password(password: JsonField) = apply { this.password = password } + + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * S3 bucket name. + * Sets [Builder.prefix] to an arbitrary JSON 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.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 bucket(): String = bucket.getRequired("bucket") + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) /** - * Custom S3-compatible endpoint. + * Sets [Builder.privateKey] to an arbitrary JSON 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.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 endpoint(): String = endpoint.getRequired("endpoint") + fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } + + fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = + s3ForcePathStyle(JsonField.of(s3ForcePathStyle)) /** - * Display name of the origin. + * Sets [Builder.s3ForcePathStyle] to an arbitrary JSON 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.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 name(): String = name.getRequired("name") + fun s3ForcePathStyle(s3ForcePathStyle: JsonField) = apply { + this.s3ForcePathStyle = s3ForcePathStyle + } + + fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) /** - * Secret key for the bucket. + * Sets [Builder.sasToken] to an arbitrary JSON 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.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 secretKey(): String = secretKey.getRequired("secretKey") + fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } - /** - * @throws ImageKitInvalidDataException if 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") + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * URL used in the Canonical header (if enabled). + * Sets [Builder.secretKey] to an arbitrary JSON 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.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 baseUrlForCanonicalHeader(): Optional = - baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } - /** - * 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 [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 [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 + fun username(username: String) = username(JsonField.of(username)) /** - * Returns the raw JSON value of [prefix]. + * Sets [Builder.username] to an arbitrary JSON value. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + fun username(username: JsonField) = apply { this.username = username } - /** - * 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 + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { + 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 [S3CompatibleOrigin]. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .endpoint() - * .name() - * .secretKey() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** A builder for [S3CompatibleOrigin]. */ - 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: JsonField? = null - 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(s3CompatibleOrigin: S3CompatibleOrigin) = apply { - accessKey = s3CompatibleOrigin.accessKey - bucket = s3CompatibleOrigin.bucket - endpoint = s3CompatibleOrigin.endpoint - name = s3CompatibleOrigin.name - secretKey = s3CompatibleOrigin.secretKey - type = s3CompatibleOrigin.type - baseUrlForCanonicalHeader = s3CompatibleOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = s3CompatibleOrigin.includeCanonicalHeader - prefix = s3CompatibleOrigin.prefix - s3ForcePathStyle = s3CompatibleOrigin.s3ForcePathStyle - additionalProperties = s3CompatibleOrigin.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 } - - 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 } - - /** 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 [S3CompatibleOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .endpoint() - * .name() - * .secretKey() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): S3CompatibleOrigin = - S3CompatibleOrigin( - checkRequired("accessKey", accessKey), - checkRequired("bucket", bucket), - checkRequired("endpoint", endpoint), - checkRequired("name", name), - checkRequired("secretKey", secretKey), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - s3ForcePathStyle, - additionalProperties.toMutableMap(), - ) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - private var validated: Boolean = false - - fun validate(): S3CompatibleOrigin = apply { - if (validated) { - return@apply - } - - accessKey() - bucket() - endpoint() - name() - secretKey() - type().validate() - baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - s3ForcePathStyle() - validated = true + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [Body]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @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.asKnown().getOrNull()?.validity() ?: 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) - - 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 S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val S3 = of("S3") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - S3_COMPATIBLE, - S3, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - S3_COMPATIBLE, - S3, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - S3_COMPATIBLE -> Value.S3_COMPATIBLE - S3 -> Value.S3 - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - S3_COMPATIBLE -> Known.S3_COMPATIBLE - S3 -> Known.S3 - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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 S3CompatibleOrigin && - 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( + fun build(): Body = + Body( + checkRequired("name", name), + checkRequired("type", type), accessKey, + accountName, + baseUrl, + baseUrlForCanonicalHeader, bucket, + clientEmail, + clientId, + clientSecret, + container, endpoint, - name, - secretKey, - type, - baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, includeCanonicalHeader, + password, prefix, + privateKey, s3ForcePathStyle, - additionalProperties, + sasToken, + secretKey, + username, + additionalProperties.toMutableMap(), ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + type().validate() + accessKey() + accountName() + baseUrl() + baseUrlForCanonicalHeader() + bucket() + clientEmail() + clientId() + clientSecret() + container() + endpoint() + forwardHostHeaderToOrigin() + includeCanonicalHeader() + password() + prefix() + privateKey() + s3ForcePathStyle() + sasToken() + secretKey() + username() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - override fun hashCode(): Int = hashCode + /** + * Returns a 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.asKnown().getOrNull()?.validity() ?: 0) + + (if (accessKey.asKnown().isPresent) 1 else 0) + + (if (accountName.asKnown().isPresent) 1 else 0) + + (if (baseUrl.asKnown().isPresent) 1 else 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (bucket.asKnown().isPresent) 1 else 0) + + (if (clientEmail.asKnown().isPresent) 1 else 0) + + (if (clientId.asKnown().isPresent) 1 else 0) + + (if (clientSecret.asKnown().isPresent) 1 else 0) + + (if (container.asKnown().isPresent) 1 else 0) + + (if (endpoint.asKnown().isPresent) 1 else 0) + + (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + (if (privateKey.asKnown().isPresent) 1 else 0) + + (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + + (if (sasToken.asKnown().isPresent) 1 else 0) + + (if (secretKey.asKnown().isPresent) 1 else 0) + + (if (username.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun toString() = - "S3CompatibleOrigin{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" + return other is Body && + name == other.name && + type == other.type && + accessKey == other.accessKey && + accountName == other.accountName && + baseUrl == other.baseUrl && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + bucket == other.bucket && + clientEmail == other.clientEmail && + clientId == other.clientId && + clientSecret == other.clientSecret && + container == other.container && + endpoint == other.endpoint && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && + password == other.password && + prefix == other.prefix && + privateKey == other.privateKey && + s3ForcePathStyle == other.s3ForcePathStyle && + sasToken == other.sasToken && + secretKey == other.secretKey && + username == other.username && + additionalProperties == other.additionalProperties } - class CloudinaryBackupOrigin - private constructor( - private val accessKey: JsonField, - private val bucket: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonField, - 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: JsonField = 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, + private val hashCode: Int by lazy { + Objects.hash( name, - secretKey, type, + accessKey, + accountName, + baseUrl, baseUrlForCanonicalHeader, + bucket, + clientEmail, + clientId, + clientSecret, + container, + endpoint, + forwardHostHeaderToOrigin, includeCanonicalHeader, + password, prefix, - mutableMapOf(), + privateKey, + s3ForcePathStyle, + sasToken, + secretKey, + username, + additionalProperties, ) + } - /** - * 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") + override fun hashCode(): Int = hashCode - /** - * 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") + override fun toString() = + "Body{name=$name, type=$type, accessKey=$accessKey, accountName=$accountName, baseUrl=$baseUrl, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, bucket=$bucket, clientEmail=$clientEmail, clientId=$clientId, clientSecret=$clientSecret, container=$container, endpoint=$endpoint, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, password=$password, prefix=$prefix, privateKey=$privateKey, s3ForcePathStyle=$s3ForcePathStyle, sasToken=$sasToken, secretKey=$secretKey, username=$username, additionalProperties=$additionalProperties}" + } - /** - * 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") + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - /** - * 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") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = 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 type(): Type = type.getRequired("type") + companion object { - /** - * 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") + @JvmField val S3 = of("S3") - /** - * 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") + @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - /** - * 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") + @JvmField val WEB_FOLDER = of("WEB_FOLDER") - /** - * 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 + @JvmField val WEB_PROXY = of("WEB_PROXY") - /** - * 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 + @JvmField val GCS = of("GCS") - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JvmField val AZURE_BLOB = of("AZURE_BLOB") - /** - * 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 + @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - /** - * 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 + @JvmField val AKENEO_PIM = of("AKENEO_PIM") - /** - * 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 + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } - /** - * 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 + /** An enum containing [Type]'s known values. */ + enum class Known { + S3, + S3_COMPATIBLE, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + CLOUDINARY_BACKUP, + AKENEO_PIM, + } - /** - * 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 + /** + * 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 { + S3, + S3_COMPATIBLE, + WEB_FOLDER, + WEB_PROXY, + GCS, + AZURE_BLOB, + CLOUDINARY_BACKUP, + AKENEO_PIM, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - 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) { + S3 -> Value.S3 + S3_COMPATIBLE -> Value.S3_COMPATIBLE + WEB_FOLDER -> Value.WEB_FOLDER + WEB_PROXY -> Value.WEB_PROXY + GCS -> Value.GCS + AZURE_BLOB -> Value.AZURE_BLOB + CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP + AKENEO_PIM -> Value.AKENEO_PIM + else -> Value._UNKNOWN } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [CloudinaryBackupOrigin]. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .name() - * .secretKey() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + S3 -> Known.S3 + S3_COMPATIBLE -> Known.S3_COMPATIBLE + WEB_FOLDER -> Known.WEB_FOLDER + WEB_PROXY -> Known.WEB_PROXY + GCS -> Known.GCS + AZURE_BLOB -> Known.AZURE_BLOB + CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP + AKENEO_PIM -> Known.AKENEO_PIM + else -> throw ImageKitInvalidDataException("Unknown Type: $value") } - /** A builder for [CloudinaryBackupOrigin]. */ - 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: JsonField? = null - 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(cloudinaryBackupOrigin: CloudinaryBackupOrigin) = apply { - accessKey = cloudinaryBackupOrigin.accessKey - bucket = cloudinaryBackupOrigin.bucket - name = cloudinaryBackupOrigin.name - secretKey = cloudinaryBackupOrigin.secretKey - type = cloudinaryBackupOrigin.type - baseUrlForCanonicalHeader = cloudinaryBackupOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = cloudinaryBackupOrigin.includeCanonicalHeader - prefix = cloudinaryBackupOrigin.prefix - additionalProperties = - cloudinaryBackupOrigin.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 } - - 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 } - - /** 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 [CloudinaryBackupOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessKey() - * .bucket() - * .name() - * .secretKey() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CloudinaryBackupOrigin = - CloudinaryBackupOrigin( - checkRequired("accessKey", accessKey), - checkRequired("bucket", bucket), - checkRequired("name", name), - checkRequired("secretKey", secretKey), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties.toMutableMap(), - ) + /** + * Returns this class 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(): CloudinaryBackupOrigin = apply { - if (validated) { - return@apply - } - - accessKey() - bucket() - name() - secretKey() - type().validate() - baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - validated = true + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + known() + 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 = - (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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) - - 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 CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CLOUDINARY_BACKUP, - S3, - S3_COMPATIBLE, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - CLOUDINARY_BACKUP, - S3, - S3_COMPATIBLE, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CloudinaryBackupOrigin && - 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 - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private val hashCode: Int by lazy { - Objects.hash( - accessKey, - bucket, - name, - secretKey, - type, - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties, - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun hashCode(): Int = hashCode - - override fun toString() = - "CloudinaryBackupOrigin{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + return other is Type && value == other.value } - class WebFolderOrigin - private constructor( - private val baseUrl: JsonField, - private val name: JsonField, - private val type: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [WebFolderOrigin]. - * - * The following fields are required: - * ```java - * .baseUrl() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebFolderOrigin]. */ - class Builder internal constructor() { - - private var baseUrl: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - 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(webFolderOrigin: WebFolderOrigin) = apply { - baseUrl = webFolderOrigin.baseUrl - name = webFolderOrigin.name - type = webFolderOrigin.type - baseUrlForCanonicalHeader = webFolderOrigin.baseUrlForCanonicalHeader - forwardHostHeaderToOrigin = webFolderOrigin.forwardHostHeaderToOrigin - includeCanonicalHeader = webFolderOrigin.includeCanonicalHeader - additionalProperties = webFolderOrigin.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 } - - 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 } - - /** 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 [WebFolderOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .baseUrl() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): WebFolderOrigin = - WebFolderOrigin( - checkRequired("baseUrl", baseUrl), - checkRequired("name", name), - checkRequired("type", type), - baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): WebFolderOrigin = apply { - if (validated) { - return@apply - } - - baseUrl() - name() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_FOLDER, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - WEB_FOLDER, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_PROXY, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - WEB_FOLDER -> Value.WEB_FOLDER - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_FOLDER -> Known.WEB_FOLDER - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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 WebFolderOrigin && - 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() = - "WebFolderOrigin{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" - } - - class WebProxyOrigin - private constructor( - private val name: JsonField, - private val type: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [WebProxyOrigin]. - * - * The following fields are required: - * ```java - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebProxyOrigin]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var type: JsonField? = null - private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(webProxyOrigin: WebProxyOrigin) = apply { - name = webProxyOrigin.name - type = webProxyOrigin.type - baseUrlForCanonicalHeader = webProxyOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = webProxyOrigin.includeCanonicalHeader - additionalProperties = webProxyOrigin.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 } - - 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 } - - /** 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 [WebProxyOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): WebProxyOrigin = - WebProxyOrigin( - checkRequired("name", name), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): WebProxyOrigin = apply { - if (validated) { - return@apply - } - - name() - type().validate() - baseUrlForCanonicalHeader() - includeCanonicalHeader() - validated = true - } + override fun hashCode() = value.hashCode() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 WEB_PROXY = of("WEB_PROXY") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WEB_PROXY, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - GCS, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - WEB_PROXY, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - GCS, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - WEB_PROXY -> Value.WEB_PROXY - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - WEB_PROXY -> Known.WEB_PROXY - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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 WebProxyOrigin && - 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() = - "WebProxyOrigin{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" - } - - class GcsOrigin - private constructor( - private val bucket: JsonField, - private val clientEmail: JsonField, - private val name: JsonField, - private val privateKey: JsonField, - private val type: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [GcsOrigin]. - * - * The following fields are required: - * ```java - * .bucket() - * .clientEmail() - * .name() - * .privateKey() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GcsOrigin]. */ - 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: JsonField? = null - 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(gcsOrigin: GcsOrigin) = apply { - bucket = gcsOrigin.bucket - clientEmail = gcsOrigin.clientEmail - name = gcsOrigin.name - privateKey = gcsOrigin.privateKey - type = gcsOrigin.type - baseUrlForCanonicalHeader = gcsOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = gcsOrigin.includeCanonicalHeader - prefix = gcsOrigin.prefix - additionalProperties = gcsOrigin.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 - } - - 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 } - - /** 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 [GcsOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .bucket() - * .clientEmail() - * .name() - * .privateKey() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): GcsOrigin = - GcsOrigin( - checkRequired("bucket", bucket), - checkRequired("clientEmail", clientEmail), - checkRequired("name", name), - checkRequired("privateKey", privateKey), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GcsOrigin = apply { - if (validated) { - return@apply - } - - bucket() - clientEmail() - name() - privateKey() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) - - 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 GCS = of("GCS") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GCS, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - AZURE_BLOB, - AKENEO_PIM, - } - - /** - * 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 { - GCS, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - AZURE_BLOB, - AKENEO_PIM, - /** - * 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) { - GCS -> Value.GCS - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - AZURE_BLOB -> Value.AZURE_BLOB - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - GCS -> Known.GCS - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - AZURE_BLOB -> Known.AZURE_BLOB - AKENEO_PIM -> Known.AKENEO_PIM - 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 GcsOrigin && - 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() = - "GcsOrigin{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" - } - - class AzureBlobOrigin - private constructor( - private val accountName: JsonField, - private val container: JsonField, - private val name: JsonField, - private val sasToken: JsonField, - private val type: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [AzureBlobOrigin]. - * - * The following fields are required: - * ```java - * .accountName() - * .container() - * .name() - * .sasToken() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AzureBlobOrigin]. */ - 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: JsonField? = null - 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(azureBlobOrigin: AzureBlobOrigin) = apply { - accountName = azureBlobOrigin.accountName - container = azureBlobOrigin.container - name = azureBlobOrigin.name - sasToken = azureBlobOrigin.sasToken - type = azureBlobOrigin.type - baseUrlForCanonicalHeader = azureBlobOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobOrigin.includeCanonicalHeader - prefix = azureBlobOrigin.prefix - additionalProperties = azureBlobOrigin.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 } - - 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 } - - /** 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 [AzureBlobOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accountName() - * .container() - * .name() - * .sasToken() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AzureBlobOrigin = - AzureBlobOrigin( - checkRequired("accountName", accountName), - checkRequired("container", container), - checkRequired("name", name), - checkRequired("sasToken", sasToken), - checkRequired("type", type), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AzureBlobOrigin = apply { - if (validated) { - return@apply - } - - accountName() - container() - name() - sasToken() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) - - 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 AZURE_BLOB = of("AZURE_BLOB") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AKENEO_PIM = of("AKENEO_PIM") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AZURE_BLOB, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AKENEO_PIM, - } - - /** - * 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 { - AZURE_BLOB, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AKENEO_PIM, - /** - * 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) { - AZURE_BLOB -> Value.AZURE_BLOB - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AZURE_BLOB -> Known.AZURE_BLOB - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AKENEO_PIM -> Known.AKENEO_PIM - 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 AzureBlobOrigin && - 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() = - "AzureBlobOrigin{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" - } - - class AkeneoPimOrigin - 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: JsonField, - 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: JsonField = 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") - - /** - * @throws ImageKitInvalidDataException if 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") - - /** - * 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 [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 [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 [AkeneoPimOrigin]. - * - * The following fields are required: - * ```java - * .baseUrl() - * .clientId() - * .clientSecret() - * .name() - * .password() - * .type() - * .username() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AkeneoPimOrigin]. */ - 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: JsonField? = null - 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(akeneoPimOrigin: AkeneoPimOrigin) = apply { - baseUrl = akeneoPimOrigin.baseUrl - clientId = akeneoPimOrigin.clientId - clientSecret = akeneoPimOrigin.clientSecret - name = akeneoPimOrigin.name - password = akeneoPimOrigin.password - type = akeneoPimOrigin.type - username = akeneoPimOrigin.username - baseUrlForCanonicalHeader = akeneoPimOrigin.baseUrlForCanonicalHeader - includeCanonicalHeader = akeneoPimOrigin.includeCanonicalHeader - additionalProperties = akeneoPimOrigin.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 } - - 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 } - - /** 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 [AkeneoPimOrigin]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .baseUrl() - * .clientId() - * .clientSecret() - * .name() - * .password() - * .type() - * .username() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AkeneoPimOrigin = - AkeneoPimOrigin( - checkRequired("baseUrl", baseUrl), - checkRequired("clientId", clientId), - checkRequired("clientSecret", clientSecret), - checkRequired("name", name), - checkRequired("password", password), - checkRequired("type", type), - checkRequired("username", username), - baseUrlForCanonicalHeader, - includeCanonicalHeader, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AkeneoPimOrigin = apply { - if (validated) { - return@apply - } - - baseUrl() - clientId() - clientSecret() - name() - password() - type().validate() - 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (username.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) - - 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 AKENEO_PIM = of("AKENEO_PIM") - - @JvmField val S3 = of("S3") - - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") - - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") - - @JvmField val WEB_FOLDER = of("WEB_FOLDER") - - @JvmField val WEB_PROXY = of("WEB_PROXY") - - @JvmField val GCS = of("GCS") - - @JvmField val AZURE_BLOB = of("AZURE_BLOB") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AKENEO_PIM, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - } - - /** - * 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 { - AKENEO_PIM, - S3, - S3_COMPATIBLE, - CLOUDINARY_BACKUP, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - /** - * 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) { - AKENEO_PIM -> Value.AKENEO_PIM - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - AKENEO_PIM -> Known.AKENEO_PIM - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - 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 AkeneoPimOrigin && - 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() = - "AkeneoPimOrigin{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" - } + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { 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 0ba87a93..b745a271 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,18 +10,27 @@ internal class OriginCreateParamsTest { @Test fun create() { OriginCreateParams.builder() - .body( - OriginCreateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginCreateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) + .name("name") + .type(OriginCreateParams.Type.S3) + .accessKey("x") + .accountName("x") + .baseUrl("https://example.com") + .baseUrlForCanonicalHeader("https://example.com") + .bucket("x") + .clientEmail("dev@stainless.com") + .clientId("x") + .clientSecret("x") + .container("x") + .endpoint("https://example.com") + .forwardHostHeaderToOrigin(true) + .includeCanonicalHeader(true) + .password("x") + .prefix("prefix") + .privateKey("x") + .s3ForcePathStyle(true) + .sasToken("x") + .secretKey("x") + .username("x") .build() } @@ -29,67 +38,62 @@ internal class OriginCreateParamsTest { fun body() { val params = OriginCreateParams.builder() - .body( - OriginCreateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginCreateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) + .name("name") + .type(OriginCreateParams.Type.S3) + .accessKey("x") + .accountName("x") + .baseUrl("https://example.com") + .baseUrlForCanonicalHeader("https://example.com") + .bucket("x") + .clientEmail("dev@stainless.com") + .clientId("x") + .clientSecret("x") + .container("x") + .endpoint("https://example.com") + .forwardHostHeaderToOrigin(true) + .includeCanonicalHeader(true) + .password("x") + .prefix("prefix") + .privateKey("x") + .s3ForcePathStyle(true) + .sasToken("x") + .secretKey("x") + .username("x") .build() val body = params._body() - assertThat(body) - .isEqualTo( - OriginCreateParams.Body.ofS3Origin( - OriginCreateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginCreateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) - ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.type()).isEqualTo(OriginCreateParams.Type.S3) + assertThat(body.accessKey()).contains("x") + assertThat(body.accountName()).contains("x") + assertThat(body.baseUrl()).contains("https://example.com") + assertThat(body.baseUrlForCanonicalHeader()).contains("https://example.com") + assertThat(body.bucket()).contains("x") + assertThat(body.clientEmail()).contains("dev@stainless.com") + assertThat(body.clientId()).contains("x") + assertThat(body.clientSecret()).contains("x") + assertThat(body.container()).contains("x") + assertThat(body.endpoint()).contains("https://example.com") + assertThat(body.forwardHostHeaderToOrigin()).contains(true) + assertThat(body.includeCanonicalHeader()).contains(true) + assertThat(body.password()).contains("x") + assertThat(body.prefix()).contains("prefix") + assertThat(body.privateKey()).contains("x") + assertThat(body.s3ForcePathStyle()).contains(true) + assertThat(body.sasToken()).contains("x") + assertThat(body.secretKey()).contains("x") + assertThat(body.username()).contains("x") } @Test fun bodyWithoutOptionalFields() { val params = - OriginCreateParams.builder() - .body( - OriginCreateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginCreateParams.Body.S3Origin.Type.S3) - .build() - ) - .build() + OriginCreateParams.builder().name("name").type(OriginCreateParams.Type.S3).build() val body = params._body() - assertThat(body) - .isEqualTo( - OriginCreateParams.Body.ofS3Origin( - OriginCreateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginCreateParams.Body.S3Origin.Type.S3) - .build() - ) - ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.type()).isEqualTo(OriginCreateParams.Type.S3) } } 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 6391ae85..8591b885 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,18 +11,27 @@ internal class OriginUpdateParamsTest { fun create() { OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginUpdateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) + .name("name") + .type(OriginUpdateParams.Type.S3) + .accessKey("x") + .accountName("x") + .baseUrl("https://example.com") + .baseUrlForCanonicalHeader("https://example.com") + .bucket("x") + .clientEmail("dev@stainless.com") + .clientId("x") + .clientSecret("x") + .container("x") + .endpoint("https://example.com") + .forwardHostHeaderToOrigin(true) + .includeCanonicalHeader(true) + .password("x") + .prefix("prefix") + .privateKey("x") + .s3ForcePathStyle(true) + .sasToken("x") + .secretKey("x") + .username("x") .build() } @@ -31,15 +40,8 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginUpdateParams.Body.S3Origin.Type.S3) - .build() - ) + .name("name") + .type(OriginUpdateParams.Type.S3) .build() assertThat(params._pathParam(0)).isEqualTo("id") @@ -52,37 +54,52 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginUpdateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) + .name("name") + .type(OriginUpdateParams.Type.S3) + .accessKey("x") + .accountName("x") + .baseUrl("https://example.com") + .baseUrlForCanonicalHeader("https://example.com") + .bucket("x") + .clientEmail("dev@stainless.com") + .clientId("x") + .clientSecret("x") + .container("x") + .endpoint("https://example.com") + .forwardHostHeaderToOrigin(true) + .includeCanonicalHeader(true) + .password("x") + .prefix("prefix") + .privateKey("x") + .s3ForcePathStyle(true) + .sasToken("x") + .secretKey("x") + .username("x") .build() val body = params._body() - assertThat(body) - .isEqualTo( - OriginUpdateParams.Body.ofS3Origin( - OriginUpdateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginUpdateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) - ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.type()).isEqualTo(OriginUpdateParams.Type.S3) + assertThat(body.accessKey()).contains("x") + assertThat(body.accountName()).contains("x") + assertThat(body.baseUrl()).contains("https://example.com") + assertThat(body.baseUrlForCanonicalHeader()).contains("https://example.com") + assertThat(body.bucket()).contains("x") + assertThat(body.clientEmail()).contains("dev@stainless.com") + assertThat(body.clientId()).contains("x") + assertThat(body.clientSecret()).contains("x") + assertThat(body.container()).contains("x") + assertThat(body.endpoint()).contains("https://example.com") + assertThat(body.forwardHostHeaderToOrigin()).contains(true) + assertThat(body.includeCanonicalHeader()).contains(true) + assertThat(body.password()).contains("x") + assertThat(body.prefix()).contains("prefix") + assertThat(body.privateKey()).contains("x") + assertThat(body.s3ForcePathStyle()).contains(true) + assertThat(body.sasToken()).contains("x") + assertThat(body.secretKey()).contains("x") + assertThat(body.username()).contains("x") } @Test @@ -90,30 +107,13 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginUpdateParams.Body.S3Origin.Type.S3) - .build() - ) + .name("name") + .type(OriginUpdateParams.Type.S3) .build() val body = params._body() - assertThat(body) - .isEqualTo( - OriginUpdateParams.Body.ofS3Origin( - OriginUpdateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginUpdateParams.Body.S3Origin.Type.S3) - .build() - ) - ) + assertThat(body.name()).isEqualTo("name") + assertThat(body.type()).isEqualTo(OriginUpdateParams.Type.S3) } } 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 b44f2580..3576f056 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 @@ -27,18 +27,27 @@ internal class OriginServiceAsyncTest { val originFuture = originServiceAsync.create( OriginCreateParams.builder() - .body( - OriginCreateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginCreateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) + .name("name") + .type(OriginCreateParams.Type.S3) + .accessKey("x") + .accountName("x") + .baseUrl("https://example.com") + .baseUrlForCanonicalHeader("https://example.com") + .bucket("x") + .clientEmail("dev@stainless.com") + .clientId("x") + .clientSecret("x") + .container("x") + .endpoint("https://example.com") + .forwardHostHeaderToOrigin(true) + .includeCanonicalHeader(true) + .password("x") + .prefix("prefix") + .privateKey("x") + .s3ForcePathStyle(true) + .sasToken("x") + .secretKey("x") + .username("x") .build() ) @@ -61,18 +70,27 @@ internal class OriginServiceAsyncTest { originServiceAsync.update( OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginUpdateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) + .name("name") + .type(OriginUpdateParams.Type.S3) + .accessKey("x") + .accountName("x") + .baseUrl("https://example.com") + .baseUrlForCanonicalHeader("https://example.com") + .bucket("x") + .clientEmail("dev@stainless.com") + .clientId("x") + .clientSecret("x") + .container("x") + .endpoint("https://example.com") + .forwardHostHeaderToOrigin(true) + .includeCanonicalHeader(true) + .password("x") + .prefix("prefix") + .privateKey("x") + .s3ForcePathStyle(true) + .sasToken("x") + .secretKey("x") + .username("x") .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 48cfe1d6..8aebefb8 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 @@ -27,18 +27,27 @@ internal class OriginServiceTest { val origin = originService.create( OriginCreateParams.builder() - .body( - OriginCreateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginCreateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) + .name("name") + .type(OriginCreateParams.Type.S3) + .accessKey("x") + .accountName("x") + .baseUrl("https://example.com") + .baseUrlForCanonicalHeader("https://example.com") + .bucket("x") + .clientEmail("dev@stainless.com") + .clientId("x") + .clientSecret("x") + .container("x") + .endpoint("https://example.com") + .forwardHostHeaderToOrigin(true) + .includeCanonicalHeader(true) + .password("x") + .prefix("prefix") + .privateKey("x") + .s3ForcePathStyle(true) + .sasToken("x") + .secretKey("x") + .username("x") .build() ) @@ -60,18 +69,27 @@ internal class OriginServiceTest { originService.update( OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3Origin.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .type(OriginUpdateParams.Body.S3Origin.Type.S3) - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) + .name("name") + .type(OriginUpdateParams.Type.S3) + .accessKey("x") + .accountName("x") + .baseUrl("https://example.com") + .baseUrlForCanonicalHeader("https://example.com") + .bucket("x") + .clientEmail("dev@stainless.com") + .clientId("x") + .clientSecret("x") + .container("x") + .endpoint("https://example.com") + .forwardHostHeaderToOrigin(true) + .includeCanonicalHeader(true) + .password("x") + .prefix("prefix") + .privateKey("x") + .s3ForcePathStyle(true) + .sasToken("x") + .secretKey("x") + .username("x") .build() ) From 15d8b71a6fb4331ff9a1080b5f0e944ba23c326b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:54:57 +0000 Subject: [PATCH 036/125] feat(api): manual updates --- .stats.yml | 6 +- .../accounts/origins/OriginCreateParams.kt | 5219 +++++++++++----- .../accounts/origins/OriginUpdateParams.kt | 5265 ++++++++++++----- .../origins/OriginCreateParamsTest.kt | 123 +- .../origins/OriginUpdateParamsTest.kt | 132 +- .../async/accounts/OriginServiceAsyncTest.kt | 64 +- .../blocking/accounts/OriginServiceTest.kt | 64 +- 7 files changed, 7817 insertions(+), 3056 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0604c950..4fc82ca0 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-3fced4085838ae20641cfa2775c6d36757bbaae28415892b2e9ee438e3b56a85.yml -openapi_spec_hash: 58327d97499fdad00856caa35ca3f16a -config_hash: ecd4e1fc35135b5e53487ca547e46fd7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-76afc867b06fdc43b339f2c7d19f25a46481b25e8264ca24ea43daa1ea9234fc.yml +openapi_spec_hash: a1455d2ab02c48a14551362dd8ec2261 +config_hash: 396f0b1c74b8b5bc4dd6b5d87e374d90 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 b56e665c..c733da5f 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 @@ -6,307 +6,40 @@ import 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.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.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.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams private constructor( - private val body: Body, + private val origin: Origin, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - /** - * @throws ImageKitInvalidDataException if the 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 type(): Type = body.type() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun accessKey(): Optional = body.accessKey() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun accountName(): Optional = body.accountName() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun baseUrl(): Optional = body.baseUrl() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun baseUrlForCanonicalHeader(): Optional = body.baseUrlForCanonicalHeader() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun bucket(): Optional = body.bucket() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun clientEmail(): Optional = body.clientEmail() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun clientId(): Optional = body.clientId() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun clientSecret(): Optional = body.clientSecret() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun container(): Optional = body.container() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun endpoint(): Optional = body.endpoint() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun forwardHostHeaderToOrigin(): Optional = body.forwardHostHeaderToOrigin() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun includeCanonicalHeader(): Optional = body.includeCanonicalHeader() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun password(): Optional = body.password() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun prefix(): Optional = body.prefix() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun privateKey(): Optional = body.privateKey() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun s3ForcePathStyle(): Optional = body.s3ForcePathStyle() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun sasToken(): Optional = body.sasToken() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun secretKey(): Optional = body.secretKey() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun username(): Optional = body.username() - - /** - * 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 [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _type(): JsonField = body._type() - - /** - * Returns the raw JSON value of [accessKey]. - * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _accessKey(): JsonField = body._accessKey() - - /** - * Returns the raw JSON value of [accountName]. - * - * Unlike [accountName], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _accountName(): JsonField = body._accountName() - - /** - * Returns the raw JSON value of [baseUrl]. - * - * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _baseUrl(): JsonField = body._baseUrl() - - /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. - * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. - */ - fun _baseUrlForCanonicalHeader(): JsonField = body._baseUrlForCanonicalHeader() - - /** - * Returns the raw JSON value of [bucket]. - * - * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _bucket(): JsonField = body._bucket() - - /** - * Returns the raw JSON value of [clientEmail]. - * - * Unlike [clientEmail], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _clientEmail(): JsonField = body._clientEmail() - - /** - * Returns the raw JSON value of [clientId]. - * - * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _clientId(): JsonField = body._clientId() - - /** - * Returns the raw JSON value of [clientSecret]. - * - * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _clientSecret(): JsonField = body._clientSecret() - - /** - * Returns the raw JSON value of [container]. - * - * Unlike [container], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _container(): JsonField = body._container() - - /** - * Returns the raw JSON value of [endpoint]. - * - * Unlike [endpoint], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _endpoint(): JsonField = body._endpoint() - - /** - * Returns the raw JSON value of [forwardHostHeaderToOrigin]. - * - * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an - * unexpected type. - */ - fun _forwardHostHeaderToOrigin(): JsonField = body._forwardHostHeaderToOrigin() - - /** - * Returns the raw JSON value of [includeCanonicalHeader]. - * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. - */ - fun _includeCanonicalHeader(): JsonField = body._includeCanonicalHeader() - - /** - * Returns the raw JSON value of [password]. - * - * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _password(): JsonField = body._password() - - /** - * Returns the raw JSON value of [prefix]. - * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _prefix(): JsonField = body._prefix() - - /** - * Returns the raw JSON value of [privateKey]. - * - * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _privateKey(): JsonField = body._privateKey() - - /** - * Returns the raw JSON value of [s3ForcePathStyle]. - * - * Unlike [s3ForcePathStyle], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _s3ForcePathStyle(): JsonField = body._s3ForcePathStyle() - - /** - * Returns the raw JSON value of [sasToken]. - * - * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _sasToken(): JsonField = body._sasToken() - - /** - * Returns the raw JSON value of [secretKey]. - * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _secretKey(): JsonField = body._secretKey() - - /** - * Returns the raw JSON value of [username]. - * - * Unlike [username], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _username(): JsonField = body._username() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + /** Schema for origin resources. */ + fun origin(): Origin = origin /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -323,8 +56,7 @@ private constructor( * * The following fields are required: * ```java - * .name() - * .type() + * .origin() * ``` */ @JvmStatic fun builder() = Builder() @@ -333,288 +65,48 @@ private constructor( /** A builder for [OriginCreateParams]. */ class Builder internal constructor() { - private var body: Body.Builder = Body.builder() + private var origin: Origin? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(originCreateParams: OriginCreateParams) = apply { - body = originCreateParams.body.toBuilder() + origin = originCreateParams.origin additionalHeaders = originCreateParams.additionalHeaders.toBuilder() additionalQueryParams = originCreateParams.additionalQueryParams.toBuilder() } - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [name] - * - [type] - * - [accessKey] - * - [accountName] - * - [baseUrl] - * - etc. - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - 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 type(type: Type) = apply { body.type(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 { body.type(type) } - - fun accessKey(accessKey: String) = apply { body.accessKey(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 { body.accessKey(accessKey) } - - fun accountName(accountName: String) = apply { body.accountName(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 { body.accountName(accountName) } - - fun baseUrl(baseUrl: String) = apply { body.baseUrl(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 { body.baseUrl(baseUrl) } - - fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = apply { - body.baseUrlForCanonicalHeader(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 { - body.baseUrlForCanonicalHeader(baseUrlForCanonicalHeader) - } - - fun bucket(bucket: String) = apply { body.bucket(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 { body.bucket(bucket) } - - fun clientEmail(clientEmail: String) = apply { body.clientEmail(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 { body.clientEmail(clientEmail) } - - fun clientId(clientId: String) = apply { body.clientId(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 { body.clientId(clientId) } - - fun clientSecret(clientSecret: String) = apply { body.clientSecret(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 { - body.clientSecret(clientSecret) - } - - fun container(container: String) = apply { body.container(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 { body.container(container) } - - fun endpoint(endpoint: String) = apply { body.endpoint(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 { body.endpoint(endpoint) } - - fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = apply { - body.forwardHostHeaderToOrigin(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 { - body.forwardHostHeaderToOrigin(forwardHostHeaderToOrigin) - } - - fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = apply { - body.includeCanonicalHeader(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 { - body.includeCanonicalHeader(includeCanonicalHeader) - } - - fun password(password: String) = apply { body.password(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 { body.password(password) } - - fun prefix(prefix: String) = apply { body.prefix(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 { body.prefix(prefix) } - - fun privateKey(privateKey: String) = apply { body.privateKey(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 { body.privateKey(privateKey) } - - fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = apply { - body.s3ForcePathStyle(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 { - body.s3ForcePathStyle(s3ForcePathStyle) - } + /** Schema for origin resources. */ + fun origin(origin: Origin) = apply { this.origin = origin } - fun sasToken(sasToken: String) = apply { body.sasToken(sasToken) } + /** Alias for calling [origin] with `Origin.ofS3(s3)`. */ + fun origin(s3: Origin.S3) = origin(Origin.ofS3(s3)) - /** - * 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 { body.sasToken(sasToken) } + /** Alias for calling [origin] with `Origin.ofS3Compatible(s3Compatible)`. */ + fun origin(s3Compatible: Origin.S3Compatible) = origin(Origin.ofS3Compatible(s3Compatible)) - fun secretKey(secretKey: String) = apply { body.secretKey(secretKey) } + /** Alias for calling [origin] with `Origin.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun origin(cloudinaryBackup: Origin.CloudinaryBackup) = + origin(Origin.ofCloudinaryBackup(cloudinaryBackup)) - /** - * 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 { body.secretKey(secretKey) } + /** Alias for calling [origin] with `Origin.ofWebFolder(webFolder)`. */ + fun origin(webFolder: Origin.WebFolder) = origin(Origin.ofWebFolder(webFolder)) - fun username(username: String) = apply { body.username(username) } + /** Alias for calling [origin] with `Origin.ofWebProxy(webProxy)`. */ + fun origin(webProxy: Origin.WebProxy) = origin(Origin.ofWebProxy(webProxy)) /** - * 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. + * Alias for calling [origin] with `Origin.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ - fun username(username: JsonField) = apply { body.username(username) } - - 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 origin(googleCloudStorageGcs: Origin.GoogleCloudStorageGcs) = + origin(Origin.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + /** Alias for calling [origin] with `Origin.ofAzureBlobStorage(azureBlobStorage)`. */ + fun origin(azureBlobStorage: Origin.AzureBlobStorage) = + origin(Origin.ofAzureBlobStorage(azureBlobStorage)) - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + /** Alias for calling [origin] with `Origin.ofAkeneoPim(akeneoPim)`. */ + fun origin(akeneoPim: Origin.AkeneoPim) = origin(Origin.ofAkeneoPim(akeneoPim)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -721,1106 +213,4023 @@ private constructor( * * The following fields are required: * ```java - * .name() - * .type() + * .origin() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): OriginCreateParams = OriginCreateParams( - body.build(), + checkRequired("origin", origin), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): Body = body + fun _body(): Origin = origin override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - class Body + /** Schema for origin resources. */ + @JsonDeserialize(using = Origin.Deserializer::class) + @JsonSerialize(using = Origin.Serializer::class) + class Origin private constructor( - private val name: JsonField, - private val type: JsonField, - private val accessKey: JsonField, - private val accountName: JsonField, - private val baseUrl: JsonField, - private val baseUrlForCanonicalHeader: JsonField, - private val bucket: JsonField, - private val clientEmail: JsonField, - private val clientId: JsonField, - private val clientSecret: JsonField, - private val container: JsonField, - private val endpoint: JsonField, - private val forwardHostHeaderToOrigin: JsonField, - private val includeCanonicalHeader: JsonField, - private val password: JsonField, - private val prefix: JsonField, - private val privateKey: JsonField, - private val s3ForcePathStyle: JsonField, - private val sasToken: JsonField, - private val secretKey: JsonField, - private val username: JsonField, - private val additionalProperties: MutableMap, + 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = null, + private val akeneoPim: AkeneoPim? = null, + private val _json: JsonValue? = null, ) { - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("accessKey") - @ExcludeMissing - accessKey: JsonField = JsonMissing.of(), - @JsonProperty("accountName") - @ExcludeMissing - accountName: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("clientEmail") - @ExcludeMissing - clientEmail: JsonField = JsonMissing.of(), - @JsonProperty("clientId") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("clientSecret") - @ExcludeMissing - clientSecret: JsonField = JsonMissing.of(), - @JsonProperty("container") - @ExcludeMissing - container: JsonField = JsonMissing.of(), - @JsonProperty("endpoint") - @ExcludeMissing - endpoint: JsonField = JsonMissing.of(), - @JsonProperty("forwardHostHeaderToOrigin") - @ExcludeMissing - forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("password") - @ExcludeMissing - password: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("privateKey") - @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), - @JsonProperty("s3ForcePathStyle") - @ExcludeMissing - s3ForcePathStyle: JsonField = JsonMissing.of(), - @JsonProperty("sasToken") - @ExcludeMissing - sasToken: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") - @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), - @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), - ) : this( - name, - type, - accessKey, - accountName, - baseUrl, - baseUrlForCanonicalHeader, - bucket, - clientEmail, - clientId, - clientSecret, - container, - endpoint, - forwardHostHeaderToOrigin, - includeCanonicalHeader, - password, - prefix, - privateKey, - s3ForcePathStyle, - sasToken, - secretKey, - username, - mutableMapOf(), - ) + fun s3(): Optional = Optional.ofNullable(s3) - /** - * @throws ImageKitInvalidDataException if the 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") + fun s3Compatible(): Optional = Optional.ofNullable(s3Compatible) - /** - * @throws ImageKitInvalidDataException if 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") + fun cloudinaryBackup(): Optional = Optional.ofNullable(cloudinaryBackup) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun accessKey(): Optional = accessKey.getOptional("accessKey") + fun webFolder(): Optional = Optional.ofNullable(webFolder) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun accountName(): Optional = accountName.getOptional("accountName") + fun webProxy(): Optional = Optional.ofNullable(webProxy) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun baseUrl(): Optional = baseUrl.getOptional("baseUrl") + fun googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) - /** - * @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") + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun bucket(): Optional = bucket.getOptional("bucket") + fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun clientEmail(): Optional = clientEmail.getOptional("clientEmail") + fun isS3(): Boolean = s3 != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun clientId(): Optional = clientId.getOptional("clientId") + fun isS3Compatible(): Boolean = s3Compatible != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun clientSecret(): Optional = clientSecret.getOptional("clientSecret") + fun isCloudinaryBackup(): Boolean = cloudinaryBackup != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun container(): Optional = container.getOptional("container") + fun isWebFolder(): Boolean = webFolder != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endpoint(): Optional = endpoint.getOptional("endpoint") + fun isWebProxy(): Boolean = webProxy != null - /** - * @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") + fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null - /** - * @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") + fun isAzureBlobStorage(): Boolean = azureBlobStorage != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun password(): Optional = password.getOptional("password") + fun isAkeneoPim(): Boolean = akeneoPim != null - /** - * @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") + fun asS3(): S3 = s3.getOrThrow("s3") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun privateKey(): Optional = privateKey.getOptional("privateKey") + fun asS3Compatible(): S3Compatible = s3Compatible.getOrThrow("s3Compatible") - /** - * @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") + fun asCloudinaryBackup(): CloudinaryBackup = cloudinaryBackup.getOrThrow("cloudinaryBackup") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun sasToken(): Optional = sasToken.getOptional("sasToken") + fun asWebFolder(): WebFolder = webFolder.getOrThrow("webFolder") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun secretKey(): Optional = secretKey.getOptional("secretKey") + fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun username(): Optional = username.getOptional("username") + fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") - /** - * 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 + fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") - /** - * 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 + fun _json(): Optional = Optional.ofNullable(_json) - /** - * 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 + 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } - /** - * 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 + private var validated: Boolean = false - /** - * 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 + fun validate(): Origin = apply { + if (validated) { + return@apply + } - /** - * 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 + 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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() + } + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.validate() + } + + override fun visitAkeneoPim(akeneoPim: AkeneoPim) { + akeneoPim.validate() + } + } + ) + validated = true + } - /** - * 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 + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } /** - * Returns the raw JSON value of [clientId]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("clientId") @ExcludeMissing fun _clientId(): JsonField = clientId + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitS3(s3: S3) = s3.validity() - /** - * 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 + override fun visitS3Compatible(s3Compatible: S3Compatible) = + s3Compatible.validity() - /** - * 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 + override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + cloudinaryBackup.validity() - /** - * 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 + override fun visitWebFolder(webFolder: WebFolder) = webFolder.validity() - /** - * 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 + override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - /** - * 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 + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() - /** - * 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 + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.validity() - /** - * 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 + override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() - /** - * 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 + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 + return other is Origin && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && + akeneoPim == other.akeneoPim + } - /** - * 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 + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + googleCloudStorageGcs, + azureBlobStorage, + akeneoPim, + ) - /** - * 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 + override fun toString(): String = + when { + s3 != null -> "Origin{s3=$s3}" + s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "Origin{webFolder=$webFolder}" + webProxy != null -> "Origin{webProxy=$webProxy}" + googleCloudStorageGcs != null -> + "Origin{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "Origin{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" + _json != null -> "Origin{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Origin") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + Origin(cloudinaryBackup = cloudinaryBackup) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) + + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + Origin(googleCloudStorageGcs = googleCloudStorageGcs) + + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + Origin(azureBlobStorage = azureBlobStorage) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An interface that defines how to map each variant of [Origin] to a value of type [T]. */ + interface Visitor { - fun toBuilder() = Builder().from(this) + fun visitS3(s3: S3): T - companion object { + fun visitS3Compatible(s3Compatible: S3Compatible): T + + fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup): T + + fun visitWebFolder(webFolder: WebFolder): T + + fun visitWebProxy(webProxy: WebProxy): T + + fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): T /** - * Returns a mutable builder for constructing an instance of [Body]. + * Maps an unknown variant of [Origin] to a value of type [T]. * - * The following fields are required: - * ```java - * .name() - * .type() - * ``` + * An instance of [Origin] 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. */ - @JvmStatic fun builder() = Builder() + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Origin: $json") + } } - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var type: JsonField? = null - private var accessKey: JsonField = JsonMissing.of() - private var accountName: JsonField = JsonMissing.of() - private var baseUrl: JsonField = JsonMissing.of() - private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var bucket: JsonField = JsonMissing.of() - private var clientEmail: JsonField = JsonMissing.of() - private var clientId: JsonField = JsonMissing.of() - private var clientSecret: JsonField = JsonMissing.of() - private var container: JsonField = JsonMissing.of() - private var endpoint: JsonField = JsonMissing.of() - private var forwardHostHeaderToOrigin: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() - private var password: JsonField = JsonMissing.of() - private var prefix: JsonField = JsonMissing.of() - private var privateKey: JsonField = JsonMissing.of() - private var s3ForcePathStyle: JsonField = JsonMissing.of() - private var sasToken: JsonField = JsonMissing.of() - private var secretKey: JsonField = JsonMissing.of() - private var username: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal class Deserializer : BaseDeserializer(Origin::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Origin { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Origin(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Origin(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Origin(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Origin(akeneoPim = 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 -> Origin(_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() + } + } + } - @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - type = body.type - accessKey = body.accessKey - accountName = body.accountName - baseUrl = body.baseUrl - baseUrlForCanonicalHeader = body.baseUrlForCanonicalHeader - bucket = body.bucket - clientEmail = body.clientEmail - clientId = body.clientId - clientSecret = body.clientSecret - container = body.container - endpoint = body.endpoint - forwardHostHeaderToOrigin = body.forwardHostHeaderToOrigin - includeCanonicalHeader = body.includeCanonicalHeader - password = body.password - prefix = body.prefix - privateKey = body.privateKey - s3ForcePathStyle = body.s3ForcePathStyle - sasToken = body.sasToken - secretKey = body.secretKey - username = body.username - additionalProperties = body.additionalProperties.toMutableMap() + internal class Serializer : BaseSerializer(Origin::class) { + + override fun serialize( + value: Origin, + 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Origin") + } } + } - fun name(name: String) = name(JsonField.of(name)) + 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(), + ) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Access key for the bucket. * - * You should usually call [Builder.name] 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 name(name: JsonField) = apply { this.name = name } - - fun type(type: Type) = type(JsonField.of(type)) + fun accessKey(): String = accessKey.getRequired("accessKey") /** - * Sets [Builder.type] to an arbitrary JSON value. + * S3 bucket name. * - * 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. + * @throws ImageKitInvalidDataException if 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: JsonField) = apply { this.type = type } - - fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + fun bucket(): String = bucket.getRequired("bucket") /** - * Sets [Builder.accessKey] to an arbitrary JSON value. + * Display name of the origin. * - * 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. + * @throws ImageKitInvalidDataException if 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(accessKey: JsonField) = apply { this.accessKey = accessKey } - - fun accountName(accountName: String) = accountName(JsonField.of(accountName)) + fun name(): String = name.getRequired("name") /** - * Sets [Builder.accountName] to an arbitrary JSON value. + * Secret key for the bucket. * - * 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. + * @throws ImageKitInvalidDataException if 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(accountName: JsonField) = apply { - this.accountName = accountName - } - - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + fun secretKey(): String = secretKey.getRequired("secretKey") /** - * Sets [Builder.baseUrl] to an arbitrary JSON value. + * Expected to always return the following: + * ```java + * JsonValue.from("S3") + * ``` * - * 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. + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = - baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + /** + * 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") /** - * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * Whether to send a Canonical header. * - * 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. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { - this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader - } + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") - fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + /** + * 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") /** - * Sets [Builder.bucket] to an arbitrary JSON value. + * Returns the raw JSON value of [accessKey]. * - * 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. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + @JsonProperty("accessKey") + @ExcludeMissing + fun _accessKey(): JsonField = accessKey - fun clientEmail(clientEmail: String) = clientEmail(JsonField.of(clientEmail)) + /** + * 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 /** - * Sets [Builder.clientEmail] to an arbitrary JSON value. + * Returns the raw JSON value of [name]. * - * 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. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun clientEmail(clientEmail: JsonField) = apply { - this.clientEmail = clientEmail - } + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + /** + * 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 /** - * Sets [Builder.clientId] to an arbitrary JSON value. + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. * - * 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. + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun clientId(clientId: JsonField) = apply { this.clientId = clientId } + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader - fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + /** + * 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 /** - * Sets [Builder.clientSecret] to an arbitrary JSON value. + * Returns the raw JSON value of [prefix]. * - * 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. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - fun clientSecret(clientSecret: JsonField) = apply { - this.clientSecret = clientSecret + @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(), + ) } - fun container(container: String) = container(JsonField.of(container)) + 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 + } /** - * Sets [Builder.container] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * 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. + * Used for best match union deserialization. */ - fun container(container: JsonField) = apply { this.container = container } + @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}" + } - fun endpoint(endpoint: String) = endpoint(JsonField.of(endpoint)) + 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(), + ) /** - * Sets [Builder.endpoint] to an arbitrary JSON value. + * Access key for the bucket. * - * 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. + * @throws ImageKitInvalidDataException if 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(endpoint: JsonField) = apply { this.endpoint = endpoint } - - fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = - forwardHostHeaderToOrigin(JsonField.of(forwardHostHeaderToOrigin)) + fun accessKey(): String = accessKey.getRequired("accessKey") /** - * Sets [Builder.forwardHostHeaderToOrigin] to an arbitrary JSON value. + * S3 bucket name. * - * 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. + * @throws ImageKitInvalidDataException if 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(forwardHostHeaderToOrigin: JsonField) = apply { - this.forwardHostHeaderToOrigin = forwardHostHeaderToOrigin - } + fun bucket(): String = bucket.getRequired("bucket") - fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = - includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + /** + * 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") /** - * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * Display name of the origin. * - * 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. + * @throws ImageKitInvalidDataException if 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(includeCanonicalHeader: JsonField) = apply { - this.includeCanonicalHeader = includeCanonicalHeader - } + fun name(): String = name.getRequired("name") - fun password(password: String) = password(JsonField.of(password)) + /** + * 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") /** - * Sets [Builder.password] to an arbitrary JSON value. + * Expected to always return the following: + * ```java + * JsonValue.from("S3_COMPATIBLE") + * ``` * - * 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. + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun password(password: JsonField) = apply { this.password = password } + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** + * 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") /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Whether to send a Canonical header. * - * 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. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") - fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + /** + * 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") /** - * Sets [Builder.privateKey] to an arbitrary JSON value. + * Use path-style S3 URLs? * - * 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. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } + fun s3ForcePathStyle(): Optional = + s3ForcePathStyle.getOptional("s3ForcePathStyle") - fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = - s3ForcePathStyle(JsonField.of(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 /** - * Sets [Builder.s3ForcePathStyle] to an arbitrary JSON value. + * Returns the raw JSON value of [bucket]. * - * 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. + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. */ - fun s3ForcePathStyle(s3ForcePathStyle: JsonField) = apply { - this.s3ForcePathStyle = s3ForcePathStyle - } + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket - fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) + /** + * 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 /** - * Sets [Builder.sasToken] to an arbitrary JSON value. + * Returns the raw JSON value of [name]. * - * 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. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** + * 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 /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. * - * 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. + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader - fun username(username: String) = username(JsonField.of(username)) + /** + * 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 /** - * Sets [Builder.username] to an arbitrary JSON value. + * Returns the raw JSON value of [prefix]. * - * 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. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - fun username(username: JsonField) = apply { this.username = username } + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * 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 - fun putAdditionalProperty(key: String, value: JsonValue) = apply { + @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 [S3Compatible]. + * + * The following fields are required: + * ```java + * .accessKey() + * .bucket() + * .endpoint() + * .name() + * .secretKey() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** 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(), + ) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + 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 an immutable instance of [Body]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): Body = - Body( - checkRequired("name", name), - checkRequired("type", type), + @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, - accountName, - baseUrl, - baseUrlForCanonicalHeader, bucket, - clientEmail, - clientId, - clientSecret, - container, endpoint, - forwardHostHeaderToOrigin, + name, + secretKey, + type, + baseUrlForCanonicalHeader, includeCanonicalHeader, - password, prefix, - privateKey, s3ForcePathStyle, - sasToken, - secretKey, - username, - additionalProperties.toMutableMap(), + additionalProperties, ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - name() - type().validate() - accessKey() - accountName() - baseUrl() - baseUrlForCanonicalHeader() - bucket() - clientEmail() - clientId() - clientSecret() - container() - endpoint() - forwardHostHeaderToOrigin() - includeCanonicalHeader() - password() - prefix() - privateKey() - s3ForcePathStyle() - sasToken() - secretKey() - username() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false } - /** - * Returns a 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (accessKey.asKnown().isPresent) 1 else 0) + - (if (accountName.asKnown().isPresent) 1 else 0) + - (if (baseUrl.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (bucket.asKnown().isPresent) 1 else 0) + - (if (clientEmail.asKnown().isPresent) 1 else 0) + - (if (clientId.asKnown().isPresent) 1 else 0) + - (if (clientSecret.asKnown().isPresent) 1 else 0) + - (if (container.asKnown().isPresent) 1 else 0) + - (if (endpoint.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (password.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) + - (if (privateKey.asKnown().isPresent) 1 else 0) + - (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + - (if (sasToken.asKnown().isPresent) 1 else 0) + - (if (secretKey.asKnown().isPresent) 1 else 0) + - (if (username.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun hashCode(): Int = hashCode - return other is Body && - name == other.name && - type == other.type && - accessKey == other.accessKey && - accountName == other.accountName && - baseUrl == other.baseUrl && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - bucket == other.bucket && - clientEmail == other.clientEmail && - clientId == other.clientId && - clientSecret == other.clientSecret && - container == other.container && - endpoint == other.endpoint && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && - password == other.password && - prefix == other.prefix && - privateKey == other.privateKey && - s3ForcePathStyle == other.s3ForcePathStyle && - sasToken == other.sasToken && - secretKey == other.secretKey && - username == other.username && - additionalProperties == other.additionalProperties + 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}" } - private val hashCode: Int by lazy { - Objects.hash( + 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, - accessKey, - accountName, - baseUrl, baseUrlForCanonicalHeader, - bucket, - clientEmail, - clientId, - clientSecret, - container, - endpoint, - forwardHostHeaderToOrigin, includeCanonicalHeader, - password, prefix, - privateKey, - s3ForcePathStyle, - sasToken, - secretKey, - username, - additionalProperties, + mutableMapOf(), ) - } - - override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, type=$type, accessKey=$accessKey, accountName=$accountName, baseUrl=$baseUrl, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, bucket=$bucket, clientEmail=$clientEmail, clientId=$clientId, clientSecret=$clientSecret, container=$container, endpoint=$endpoint, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, password=$password, prefix=$prefix, privateKey=$privateKey, s3ForcePathStyle=$s3ForcePathStyle, sasToken=$sasToken, secretKey=$secretKey, username=$username, additionalProperties=$additionalProperties}" - } + /** + * 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") - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + /** + * 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") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * 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") - companion object { + /** + * 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") - @JvmField val S3 = of("S3") + /** + * 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 - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + /** + * 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") - @JvmField val WEB_FOLDER = of("WEB_FOLDER") + /** + * 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") - @JvmField val WEB_PROXY = of("WEB_PROXY") + /** + * 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") - @JvmField val GCS = of("GCS") + /** + * 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 - @JvmField val AZURE_BLOB = of("AZURE_BLOB") + /** + * 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 - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmField val AKENEO_PIM = of("AKENEO_PIM") + /** + * 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 - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + /** + * 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 - /** An enum containing [Type]'s known values. */ - enum class Known { - S3, - S3_COMPATIBLE, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - CLOUDINARY_BACKUP, - AKENEO_PIM, - } + /** + * 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 - /** - * 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 { - S3, - S3_COMPATIBLE, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - CLOUDINARY_BACKUP, - AKENEO_PIM, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } + /** + * 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 an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, 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) { - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - AKENEO_PIM -> Known.AKENEO_PIM - else -> throw ImageKitInvalidDataException("Unknown Type: $value") + @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() } - /** - * Returns this class 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") + /** 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 + 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 validate(): Type = 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 (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 } - known() - validated = true + 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}" } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + 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) } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @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() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** 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, + ) } - return other is Type && value == other.value + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - override fun hashCode() = value.hashCode() + 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}" + } - override fun toString() = value.toString() + class GoogleCloudStorageGcs + 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 + * [GoogleCloudStorageGcs]. + * + * The following fields are required: + * ```java + * .bucket() + * .clientEmail() + * .name() + * .privateKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleCloudStorageGcs]. */ + 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.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 [GoogleCloudStorageGcs]. + * + * 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(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( + 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(): GoogleCloudStorageGcs = 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 GoogleCloudStorageGcs && + 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() = + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + } + + class AzureBlobStorage + 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 [AzureBlobStorage]. + * + * The following fields are required: + * ```java + * .accountName() + * .container() + * .name() + * .sasToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlobStorage]. */ + 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(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.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 [AzureBlobStorage]. + * + * 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(): AzureBlobStorage = + AzureBlobStorage( + 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(): AzureBlobStorage = 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 AzureBlobStorage && + 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() = + "AzureBlobStorage{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}" + } } override fun equals(other: Any?): Boolean { @@ -1829,13 +4238,13 @@ private constructor( } return other is OriginCreateParams && - body == other.body && + origin == other.origin && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = Objects.hash(origin, additionalHeaders, additionalQueryParams) override fun toString() = - "OriginCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "OriginCreateParams{origin=$origin, 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 9ab81213..4f23d963 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 @@ -6,13 +6,23 @@ import 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.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.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.errors.ImageKitInvalidDataException @@ -38,284 +48,8 @@ private constructor( */ fun id(): Optional = Optional.ofNullable(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 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 type(): Type = body.type() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun accessKey(): Optional = body.accessKey() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun accountName(): Optional = body.accountName() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun baseUrl(): Optional = body.baseUrl() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun baseUrlForCanonicalHeader(): Optional = body.baseUrlForCanonicalHeader() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun bucket(): Optional = body.bucket() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun clientEmail(): Optional = body.clientEmail() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun clientId(): Optional = body.clientId() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun clientSecret(): Optional = body.clientSecret() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun container(): Optional = body.container() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun endpoint(): Optional = body.endpoint() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun forwardHostHeaderToOrigin(): Optional = body.forwardHostHeaderToOrigin() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun includeCanonicalHeader(): Optional = body.includeCanonicalHeader() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun password(): Optional = body.password() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun prefix(): Optional = body.prefix() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun privateKey(): Optional = body.privateKey() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun s3ForcePathStyle(): Optional = body.s3ForcePathStyle() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun sasToken(): Optional = body.sasToken() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun secretKey(): Optional = body.secretKey() - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun username(): Optional = body.username() - - /** - * 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 [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _type(): JsonField = body._type() - - /** - * Returns the raw JSON value of [accessKey]. - * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _accessKey(): JsonField = body._accessKey() - - /** - * Returns the raw JSON value of [accountName]. - * - * Unlike [accountName], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _accountName(): JsonField = body._accountName() - - /** - * Returns the raw JSON value of [baseUrl]. - * - * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _baseUrl(): JsonField = body._baseUrl() - - /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. - * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. - */ - fun _baseUrlForCanonicalHeader(): JsonField = body._baseUrlForCanonicalHeader() - - /** - * Returns the raw JSON value of [bucket]. - * - * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _bucket(): JsonField = body._bucket() - - /** - * Returns the raw JSON value of [clientEmail]. - * - * Unlike [clientEmail], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _clientEmail(): JsonField = body._clientEmail() - - /** - * Returns the raw JSON value of [clientId]. - * - * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _clientId(): JsonField = body._clientId() - - /** - * Returns the raw JSON value of [clientSecret]. - * - * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _clientSecret(): JsonField = body._clientSecret() - - /** - * Returns the raw JSON value of [container]. - * - * Unlike [container], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _container(): JsonField = body._container() - - /** - * Returns the raw JSON value of [endpoint]. - * - * Unlike [endpoint], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _endpoint(): JsonField = body._endpoint() - - /** - * Returns the raw JSON value of [forwardHostHeaderToOrigin]. - * - * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an - * unexpected type. - */ - fun _forwardHostHeaderToOrigin(): JsonField = body._forwardHostHeaderToOrigin() - - /** - * Returns the raw JSON value of [includeCanonicalHeader]. - * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. - */ - fun _includeCanonicalHeader(): JsonField = body._includeCanonicalHeader() - - /** - * Returns the raw JSON value of [password]. - * - * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _password(): JsonField = body._password() - - /** - * Returns the raw JSON value of [prefix]. - * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _prefix(): JsonField = body._prefix() - - /** - * Returns the raw JSON value of [privateKey]. - * - * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _privateKey(): JsonField = body._privateKey() - - /** - * Returns the raw JSON value of [s3ForcePathStyle]. - * - * Unlike [s3ForcePathStyle], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _s3ForcePathStyle(): JsonField = body._s3ForcePathStyle() - - /** - * Returns the raw JSON value of [sasToken]. - * - * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _sasToken(): JsonField = body._sasToken() - - /** - * Returns the raw JSON value of [secretKey]. - * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _secretKey(): JsonField = body._secretKey() - - /** - * Returns the raw JSON value of [username]. - * - * Unlike [username], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _username(): JsonField = body._username() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + /** Schema for origin resources. */ + fun body(): Body = body /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -332,8 +66,7 @@ private constructor( * * The following fields are required: * ```java - * .name() - * .type() + * .body() * ``` */ @JvmStatic fun builder() = Builder() @@ -343,14 +76,14 @@ private constructor( class Builder internal constructor() { private var id: String? = null - private var body: Body.Builder = Body.builder() + private var body: Body? = 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 - body = originUpdateParams.body.toBuilder() + body = originUpdateParams.body additionalHeaders = originUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = originUpdateParams.additionalQueryParams.toBuilder() } @@ -364,277 +97,35 @@ private constructor( /** 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: - * - [name] - * - [type] - * - [accessKey] - * - [accountName] - * - [baseUrl] - * - etc. - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - 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 type(type: Type) = apply { body.type(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 { body.type(type) } - - fun accessKey(accessKey: String) = apply { body.accessKey(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 { body.accessKey(accessKey) } - - fun accountName(accountName: String) = apply { body.accountName(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 { body.accountName(accountName) } - - fun baseUrl(baseUrl: String) = apply { body.baseUrl(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 { body.baseUrl(baseUrl) } - - fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = apply { - body.baseUrlForCanonicalHeader(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 { - body.baseUrlForCanonicalHeader(baseUrlForCanonicalHeader) - } - - fun bucket(bucket: String) = apply { body.bucket(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 { body.bucket(bucket) } - - fun clientEmail(clientEmail: String) = apply { body.clientEmail(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 { body.clientEmail(clientEmail) } - - fun clientId(clientId: String) = apply { body.clientId(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 { body.clientId(clientId) } - - fun clientSecret(clientSecret: String) = apply { body.clientSecret(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 { - body.clientSecret(clientSecret) - } - - fun container(container: String) = apply { body.container(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 { body.container(container) } - - fun endpoint(endpoint: String) = apply { body.endpoint(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 { body.endpoint(endpoint) } - - fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = apply { - body.forwardHostHeaderToOrigin(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 { - body.forwardHostHeaderToOrigin(forwardHostHeaderToOrigin) - } - - fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = apply { - body.includeCanonicalHeader(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 { - body.includeCanonicalHeader(includeCanonicalHeader) - } - - fun password(password: String) = apply { body.password(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 { body.password(password) } - - fun prefix(prefix: String) = apply { body.prefix(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 { body.prefix(prefix) } - - fun privateKey(privateKey: String) = apply { body.privateKey(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 { body.privateKey(privateKey) } - - fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = apply { - body.s3ForcePathStyle(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 { - body.s3ForcePathStyle(s3ForcePathStyle) - } - - fun sasToken(sasToken: String) = apply { body.sasToken(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 { body.sasToken(sasToken) } - - fun secretKey(secretKey: String) = apply { body.secretKey(secretKey) } + /** Schema for origin resources. */ + fun body(body: Body) = apply { this.body = body } - /** - * 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 { body.secretKey(secretKey) } + /** Alias for calling [body] with `Body.ofS3(s3)`. */ + fun body(s3: Body.S3) = body(Body.ofS3(s3)) - fun username(username: String) = apply { body.username(username) } + /** Alias for calling [body] with `Body.ofS3Compatible(s3Compatible)`. */ + fun body(s3Compatible: Body.S3Compatible) = body(Body.ofS3Compatible(s3Compatible)) - /** - * 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 { body.username(username) } + /** Alias for calling [body] with `Body.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun body(cloudinaryBackup: Body.CloudinaryBackup) = + body(Body.ofCloudinaryBackup(cloudinaryBackup)) - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + /** Alias for calling [body] with `Body.ofWebFolder(webFolder)`. */ + fun body(webFolder: Body.WebFolder) = body(Body.ofWebFolder(webFolder)) - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ + fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } + /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ + fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = + body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ + fun body(azureBlobStorage: Body.AzureBlobStorage) = + body(Body.ofAzureBlobStorage(azureBlobStorage)) - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ + fun body(akeneoPim: Body.AkeneoPim) = body(Body.ofAkeneoPim(akeneoPim)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -741,8 +232,7 @@ private constructor( * * The following fields are required: * ```java - * .name() - * .type() + * .body() * ``` * * @throws IllegalStateException if any required field is unset. @@ -750,7 +240,7 @@ private constructor( fun build(): OriginUpdateParams = OriginUpdateParams( id, - body.build(), + checkRequired("body", body), additionalHeaders.build(), additionalQueryParams.build(), ) @@ -768,1086 +258,4003 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + /** Schema for origin resources. */ + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) class Body private constructor( - private val name: JsonField, - private val type: JsonField, - private val accessKey: JsonField, - private val accountName: JsonField, - private val baseUrl: JsonField, - private val baseUrlForCanonicalHeader: JsonField, - private val bucket: JsonField, - private val clientEmail: JsonField, - private val clientId: JsonField, - private val clientSecret: JsonField, - private val container: JsonField, - private val endpoint: JsonField, - private val forwardHostHeaderToOrigin: JsonField, - private val includeCanonicalHeader: JsonField, - private val password: JsonField, - private val prefix: JsonField, - private val privateKey: JsonField, - private val s3ForcePathStyle: JsonField, - private val sasToken: JsonField, - private val secretKey: JsonField, - private val username: JsonField, - private val additionalProperties: MutableMap, + 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = null, + private val akeneoPim: AkeneoPim? = null, + private val _json: JsonValue? = null, ) { - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("accessKey") - @ExcludeMissing - accessKey: JsonField = JsonMissing.of(), - @JsonProperty("accountName") - @ExcludeMissing - accountName: JsonField = JsonMissing.of(), - @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("clientEmail") - @ExcludeMissing - clientEmail: JsonField = JsonMissing.of(), - @JsonProperty("clientId") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("clientSecret") - @ExcludeMissing - clientSecret: JsonField = JsonMissing.of(), - @JsonProperty("container") - @ExcludeMissing - container: JsonField = JsonMissing.of(), - @JsonProperty("endpoint") - @ExcludeMissing - endpoint: JsonField = JsonMissing.of(), - @JsonProperty("forwardHostHeaderToOrigin") - @ExcludeMissing - forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("password") - @ExcludeMissing - password: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("privateKey") - @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), - @JsonProperty("s3ForcePathStyle") - @ExcludeMissing - s3ForcePathStyle: JsonField = JsonMissing.of(), - @JsonProperty("sasToken") - @ExcludeMissing - sasToken: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") - @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), - @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), - ) : this( - name, - type, - accessKey, - accountName, - baseUrl, - baseUrlForCanonicalHeader, - bucket, - clientEmail, - clientId, - clientSecret, - container, - endpoint, - forwardHostHeaderToOrigin, - includeCanonicalHeader, - password, - prefix, - privateKey, - s3ForcePathStyle, - sasToken, - secretKey, - username, - mutableMapOf(), - ) + fun s3(): Optional = Optional.ofNullable(s3) - /** - * @throws ImageKitInvalidDataException if the 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") + fun s3Compatible(): Optional = Optional.ofNullable(s3Compatible) - /** - * @throws ImageKitInvalidDataException if 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") + fun cloudinaryBackup(): Optional = Optional.ofNullable(cloudinaryBackup) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun accessKey(): Optional = accessKey.getOptional("accessKey") + fun webFolder(): Optional = Optional.ofNullable(webFolder) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun accountName(): Optional = accountName.getOptional("accountName") + fun webProxy(): Optional = Optional.ofNullable(webProxy) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun baseUrl(): Optional = baseUrl.getOptional("baseUrl") + fun googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) - /** - * @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") + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun bucket(): Optional = bucket.getOptional("bucket") + fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun clientEmail(): Optional = clientEmail.getOptional("clientEmail") + fun isS3(): Boolean = s3 != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun clientId(): Optional = clientId.getOptional("clientId") + fun isS3Compatible(): Boolean = s3Compatible != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun clientSecret(): Optional = clientSecret.getOptional("clientSecret") + fun isCloudinaryBackup(): Boolean = cloudinaryBackup != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun container(): Optional = container.getOptional("container") + fun isWebFolder(): Boolean = webFolder != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun endpoint(): Optional = endpoint.getOptional("endpoint") + fun isWebProxy(): Boolean = webProxy != null - /** - * @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") + fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null - /** - * @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") + fun isAzureBlobStorage(): Boolean = azureBlobStorage != null - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun password(): Optional = password.getOptional("password") + fun isAkeneoPim(): Boolean = akeneoPim != null - /** - * @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") + fun asS3(): S3 = s3.getOrThrow("s3") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun privateKey(): Optional = privateKey.getOptional("privateKey") + fun asS3Compatible(): S3Compatible = s3Compatible.getOrThrow("s3Compatible") - /** - * @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") + fun asCloudinaryBackup(): CloudinaryBackup = cloudinaryBackup.getOrThrow("cloudinaryBackup") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun sasToken(): Optional = sasToken.getOptional("sasToken") + fun asWebFolder(): WebFolder = webFolder.getOrThrow("webFolder") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun secretKey(): Optional = secretKey.getOptional("secretKey") + fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun username(): Optional = username.getOptional("username") + fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") - /** - * 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 + fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") - /** - * 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 + fun _json(): Optional = Optional.ofNullable(_json) - /** - * 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 + 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } - /** - * 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 + private var validated: Boolean = false - /** - * 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 + fun validate(): Body = apply { + if (validated) { + return@apply + } - /** - * 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 + 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 visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() + } + + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.validate() + } + + override fun visitAkeneoPim(akeneoPim: AkeneoPim) { + akeneoPim.validate() + } + } + ) + validated = true + } - /** - * 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 + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } /** - * Returns the raw JSON value of [clientId]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("clientId") @ExcludeMissing fun _clientId(): JsonField = clientId + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitS3(s3: S3) = s3.validity() - /** - * 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 + override fun visitS3Compatible(s3Compatible: S3Compatible) = + s3Compatible.validity() - /** - * 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 + override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + cloudinaryBackup.validity() - /** - * 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 + override fun visitWebFolder(webFolder: WebFolder) = webFolder.validity() - /** - * 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 + override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - /** - * 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 + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() - /** - * 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 + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.validity() - /** - * 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 + override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() - /** - * 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 + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * 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 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 + return other is Body && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && + akeneoPim == other.akeneoPim + } - /** - * 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 + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + googleCloudStorageGcs, + azureBlobStorage, + akeneoPim, + ) - /** - * 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 + override fun toString(): String = + when { + s3 != null -> "Body{s3=$s3}" + s3Compatible != null -> "Body{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "Body{webFolder=$webFolder}" + webProxy != null -> "Body{webProxy=$webProxy}" + googleCloudStorageGcs != null -> + "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmStatic fun ofS3(s3: S3) = Body(s3 = s3) - fun toBuilder() = Builder().from(this) + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = Body(s3Compatible = s3Compatible) - companion object { + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + Body(cloudinaryBackup = cloudinaryBackup) - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Body(webFolder = webFolder) - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var type: JsonField? = null - private var accessKey: JsonField = JsonMissing.of() - private var accountName: JsonField = JsonMissing.of() - private var baseUrl: JsonField = JsonMissing.of() - private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var bucket: JsonField = JsonMissing.of() - private var clientEmail: JsonField = JsonMissing.of() - private var clientId: JsonField = JsonMissing.of() - private var clientSecret: JsonField = JsonMissing.of() - private var container: JsonField = JsonMissing.of() - private var endpoint: JsonField = JsonMissing.of() - private var forwardHostHeaderToOrigin: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() - private var password: JsonField = JsonMissing.of() - private var prefix: JsonField = JsonMissing.of() - private var privateKey: JsonField = JsonMissing.of() - private var s3ForcePathStyle: JsonField = JsonMissing.of() - private var sasToken: JsonField = JsonMissing.of() - private var secretKey: JsonField = JsonMissing.of() - private var username: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) - @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - type = body.type - accessKey = body.accessKey - accountName = body.accountName - baseUrl = body.baseUrl - baseUrlForCanonicalHeader = body.baseUrlForCanonicalHeader - bucket = body.bucket - clientEmail = body.clientEmail - clientId = body.clientId - clientSecret = body.clientSecret - container = body.container - endpoint = body.endpoint - forwardHostHeaderToOrigin = body.forwardHostHeaderToOrigin - includeCanonicalHeader = body.includeCanonicalHeader - password = body.password - prefix = body.prefix - privateKey = body.privateKey - s3ForcePathStyle = body.s3ForcePathStyle - sasToken = body.sasToken - secretKey = body.secretKey - username = body.username - additionalProperties = body.additionalProperties.toMutableMap() - } + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + Body(googleCloudStorageGcs = googleCloudStorageGcs) - fun name(name: String) = name(JsonField.of(name)) + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + Body(azureBlobStorage = azureBlobStorage) - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) + } - fun type(type: Type) = type(JsonField.of(type)) + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + interface Visitor { - /** - * 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 visitS3(s3: S3): T - fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + fun visitS3Compatible(s3Compatible: S3Compatible): T - /** - * 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 } + fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup): T - fun accountName(accountName: String) = accountName(JsonField.of(accountName)) + fun visitWebFolder(webFolder: WebFolder): T - /** - * 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 visitWebProxy(webProxy: WebProxy): T - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T - /** - * 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 } + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T - fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = - baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + fun visitAkeneoPim(akeneoPim: AkeneoPim): T /** - * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * 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. * - * 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. + * @throws ImageKitInvalidDataException in the default implementation. */ - fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { - this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + 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(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(akeneoPim = 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.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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } } + } - fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + 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(), + ) /** - * Sets [Builder.bucket] to an arbitrary JSON value. + * Access key for the bucket. * - * 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. + * @throws ImageKitInvalidDataException if 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(bucket: JsonField) = apply { this.bucket = bucket } - - fun clientEmail(clientEmail: String) = clientEmail(JsonField.of(clientEmail)) + fun accessKey(): String = accessKey.getRequired("accessKey") /** - * Sets [Builder.clientEmail] to an arbitrary JSON value. + * S3 bucket name. * - * 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. + * @throws ImageKitInvalidDataException if 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(clientEmail: JsonField) = apply { - this.clientEmail = clientEmail - } - - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + fun bucket(): String = bucket.getRequired("bucket") /** - * Sets [Builder.clientId] to an arbitrary JSON value. + * Display name of the origin. * - * 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. + * @throws ImageKitInvalidDataException if 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(clientId: JsonField) = apply { this.clientId = clientId } - - fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + fun name(): String = name.getRequired("name") /** - * Sets [Builder.clientSecret] to an arbitrary JSON value. + * Secret key for the bucket. * - * 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. + * @throws ImageKitInvalidDataException if 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(clientSecret: JsonField) = apply { - this.clientSecret = clientSecret - } - - fun container(container: String) = container(JsonField.of(container)) + fun secretKey(): String = secretKey.getRequired("secretKey") /** - * Sets [Builder.container] to an arbitrary JSON value. + * Expected to always return the following: + * ```java + * JsonValue.from("S3") + * ``` * - * 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. + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun container(container: JsonField) = apply { this.container = container } - - fun endpoint(endpoint: String) = endpoint(JsonField.of(endpoint)) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** - * Sets [Builder.endpoint] to an arbitrary JSON value. + * URL used in the Canonical header (if enabled). * - * 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. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun endpoint(endpoint: JsonField) = apply { this.endpoint = endpoint } - - fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = - forwardHostHeaderToOrigin(JsonField.of(forwardHostHeaderToOrigin)) + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Sets [Builder.forwardHostHeaderToOrigin] to an arbitrary JSON value. + * Whether to send a Canonical header. * - * 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. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: JsonField) = apply { - this.forwardHostHeaderToOrigin = forwardHostHeaderToOrigin - } - - fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = - includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * Path prefix inside the bucket. * - * 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. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { - this.includeCanonicalHeader = includeCanonicalHeader - } - - fun password(password: String) = password(JsonField.of(password)) + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Sets [Builder.password] to an arbitrary JSON value. + * Returns the raw JSON value of [accessKey]. * - * 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. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun password(password: JsonField) = apply { this.password = password } - - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + @JsonProperty("accessKey") + @ExcludeMissing + fun _accessKey(): JsonField = accessKey /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Returns the raw JSON value of [bucket]. * - * 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. + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - - fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Sets [Builder.privateKey] to an arbitrary JSON value. + * Returns the raw JSON value of [name]. * - * 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. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } - - fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = - s3ForcePathStyle(JsonField.of(s3ForcePathStyle)) + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Sets [Builder.s3ForcePathStyle] to an arbitrary JSON value. + * Returns the raw JSON value of [secretKey]. * - * 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. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun s3ForcePathStyle(s3ForcePathStyle: JsonField) = apply { - this.s3ForcePathStyle = s3ForcePathStyle - } - - fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) + @JsonProperty("secretKey") + @ExcludeMissing + fun _secretKey(): JsonField = secretKey /** - * Sets [Builder.sasToken] to an arbitrary JSON value. + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. * - * 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. + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has + * an unexpected type. */ - fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } - - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * 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. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } - - fun username(username: String) = username(JsonField.of(username)) + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Sets [Builder.username] to an arbitrary JSON value. + * Returns the raw JSON value of [prefix]. * - * 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. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - fun username(username: JsonField) = apply { this.username = username } + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { + @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 [S3]. + * + * The following fields are required: + * ```java + * .accessKey() + * .bucket() + * .name() + * .secretKey() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** 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(), + ) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + 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 an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * .type() - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): Body = - Body( - checkRequired("name", name), - checkRequired("type", type), + @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, - accountName, - baseUrl, - baseUrlForCanonicalHeader, bucket, - clientEmail, - clientId, - clientSecret, - container, - endpoint, - forwardHostHeaderToOrigin, + name, + secretKey, + type, + baseUrlForCanonicalHeader, includeCanonicalHeader, - password, prefix, - privateKey, - s3ForcePathStyle, - sasToken, - secretKey, - username, - additionalProperties.toMutableMap(), + additionalProperties, ) - } + } - private var validated: Boolean = false + 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 GoogleCloudStorageGcs + 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 + * [GoogleCloudStorageGcs]. + * + * The following fields are required: + * ```java + * .bucket() + * .clientEmail() + * .name() + * .privateKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleCloudStorageGcs]. */ + 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.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 [GoogleCloudStorageGcs]. + * + * 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(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( + 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(): GoogleCloudStorageGcs = 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 GoogleCloudStorageGcs && + 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() = + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + } + + class AzureBlobStorage + 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(), + ) - fun validate(): Body = apply { - if (validated) { - return@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 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) } - name() - type().validate() - accessKey() - accountName() - baseUrl() - baseUrlForCanonicalHeader() - bucket() - clientEmail() - clientId() - clientSecret() - container() - endpoint() - forwardHostHeaderToOrigin() - includeCanonicalHeader() - password() - prefix() - privateKey() - s3ForcePathStyle() - sasToken() - secretKey() - username() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * + * The following fields are required: + * ```java + * .accountName() + * .container() + * .name() + * .sasToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + /** A builder for [AzureBlobStorage]. */ + 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(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.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 [AzureBlobStorage]. + * + * 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(): AzureBlobStorage = + AzureBlobStorage( + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("name", name), + checkRequired("sasToken", sasToken), + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) } - /** - * Returns a 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.asKnown().getOrNull()?.validity() ?: 0) + - (if (accessKey.asKnown().isPresent) 1 else 0) + + private var validated: Boolean = false + + fun validate(): AzureBlobStorage = 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 (baseUrl.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (bucket.asKnown().isPresent) 1 else 0) + - (if (clientEmail.asKnown().isPresent) 1 else 0) + - (if (clientId.asKnown().isPresent) 1 else 0) + - (if (clientSecret.asKnown().isPresent) 1 else 0) + - (if (container.asKnown().isPresent) 1 else 0) + - (if (endpoint.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (password.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) + - (if (privateKey.asKnown().isPresent) 1 else 0) + - (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + - (if (sasToken.asKnown().isPresent) 1 else 0) + - (if (secretKey.asKnown().isPresent) 1 else 0) + - (if (username.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 AzureBlobStorage && + 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 + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + private val hashCode: Int by lazy { + Objects.hash( + accountName, + container, + name, + sasToken, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties, + ) } - return other is Body && - name == other.name && - type == other.type && - accessKey == other.accessKey && - accountName == other.accountName && - baseUrl == other.baseUrl && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - bucket == other.bucket && - clientEmail == other.clientEmail && - clientId == other.clientId && - clientSecret == other.clientSecret && - container == other.container && - endpoint == other.endpoint && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && - password == other.password && - prefix == other.prefix && - privateKey == other.privateKey && - s3ForcePathStyle == other.s3ForcePathStyle && - sasToken == other.sasToken && - secretKey == other.secretKey && - username == other.username && - additionalProperties == other.additionalProperties + override fun hashCode(): Int = hashCode + + override fun toString() = + "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - private val hashCode: Int by lazy { - Objects.hash( - name, - type, - accessKey, - accountName, + 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, - baseUrlForCanonicalHeader, - bucket, - clientEmail, clientId, clientSecret, - container, - endpoint, - forwardHostHeaderToOrigin, - includeCanonicalHeader, + name, password, - prefix, - privateKey, - s3ForcePathStyle, - sasToken, - secretKey, + type, username, - additionalProperties, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + mutableMapOf(), ) - } - override fun hashCode(): Int = hashCode + /** + * 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") - override fun toString() = - "Body{name=$name, type=$type, accessKey=$accessKey, accountName=$accountName, baseUrl=$baseUrl, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, bucket=$bucket, clientEmail=$clientEmail, clientId=$clientId, clientSecret=$clientSecret, container=$container, endpoint=$endpoint, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, password=$password, prefix=$prefix, privateKey=$privateKey, s3ForcePathStyle=$s3ForcePathStyle, sasToken=$sasToken, secretKey=$secretKey, username=$username, additionalProperties=$additionalProperties}" - } + /** + * 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") - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + /** + * 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") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * 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") - companion object { + /** + * 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") - @JvmField val S3 = of("S3") + /** + * 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 - @JvmField val S3_COMPATIBLE = of("S3_COMPATIBLE") + /** + * 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") - @JvmField val WEB_FOLDER = of("WEB_FOLDER") + /** + * 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") - @JvmField val WEB_PROXY = of("WEB_PROXY") + /** + * 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") - @JvmField val GCS = of("GCS") + /** + * 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 - @JvmField val AZURE_BLOB = of("AZURE_BLOB") + /** + * 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 - @JvmField val CLOUDINARY_BACKUP = of("CLOUDINARY_BACKUP") + /** + * 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 - @JvmField val AKENEO_PIM = of("AKENEO_PIM") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + /** + * 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 - /** An enum containing [Type]'s known values. */ - enum class Known { - S3, - S3_COMPATIBLE, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - CLOUDINARY_BACKUP, - AKENEO_PIM, - } + /** + * 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 - /** - * 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 { - S3, - S3_COMPATIBLE, - WEB_FOLDER, - WEB_PROXY, - GCS, - AZURE_BLOB, - CLOUDINARY_BACKUP, - AKENEO_PIM, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } + /** + * 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 an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - S3 -> Value.S3 - S3_COMPATIBLE -> Value.S3_COMPATIBLE - WEB_FOLDER -> Value.WEB_FOLDER - WEB_PROXY -> Value.WEB_PROXY - GCS -> Value.GCS - AZURE_BLOB -> Value.AZURE_BLOB - CLOUDINARY_BACKUP -> Value.CLOUDINARY_BACKUP - AKENEO_PIM -> Value.AKENEO_PIM - else -> Value._UNKNOWN - } + /** + * 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 an enum member corresponding to this class instance's value. - * - * Use 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) { - S3 -> Known.S3 - S3_COMPATIBLE -> Known.S3_COMPATIBLE - WEB_FOLDER -> Known.WEB_FOLDER - WEB_PROXY -> Known.WEB_PROXY - GCS -> Known.GCS - AZURE_BLOB -> Known.AZURE_BLOB - CLOUDINARY_BACKUP -> Known.CLOUDINARY_BACKUP - AKENEO_PIM -> Known.AKENEO_PIM - else -> throw ImageKitInvalidDataException("Unknown Type: $value") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + 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") + @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() } - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply + /** 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(), + ) } - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + 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 } - /** - * Returns a score indicating how many valid values 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 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 (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 } - return other is Type && value == other.value - } + private val hashCode: Int by lazy { + Objects.hash( + baseUrl, + clientId, + clientSecret, + name, + password, + type, + username, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + additionalProperties, + ) + } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int = hashCode - override fun toString() = value.toString() + override fun toString() = + "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { 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 b745a271..e8defa1a 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,27 +10,17 @@ internal class OriginCreateParamsTest { @Test fun create() { OriginCreateParams.builder() - .name("name") - .type(OriginCreateParams.Type.S3) - .accessKey("x") - .accountName("x") - .baseUrl("https://example.com") - .baseUrlForCanonicalHeader("https://example.com") - .bucket("x") - .clientEmail("dev@stainless.com") - .clientId("x") - .clientSecret("x") - .container("x") - .endpoint("https://example.com") - .forwardHostHeaderToOrigin(true) - .includeCanonicalHeader(true) - .password("x") - .prefix("prefix") - .privateKey("x") - .s3ForcePathStyle(true) - .sasToken("x") - .secretKey("x") - .username("x") + .origin( + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) .build() } @@ -38,62 +28,63 @@ internal class OriginCreateParamsTest { fun body() { val params = OriginCreateParams.builder() - .name("name") - .type(OriginCreateParams.Type.S3) - .accessKey("x") - .accountName("x") - .baseUrl("https://example.com") - .baseUrlForCanonicalHeader("https://example.com") - .bucket("x") - .clientEmail("dev@stainless.com") - .clientId("x") - .clientSecret("x") - .container("x") - .endpoint("https://example.com") - .forwardHostHeaderToOrigin(true) - .includeCanonicalHeader(true) - .password("x") - .prefix("prefix") - .privateKey("x") - .s3ForcePathStyle(true) - .sasToken("x") - .secretKey("x") - .username("x") + .origin( + OriginCreateParams.Origin.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.name()).isEqualTo("name") - assertThat(body.type()).isEqualTo(OriginCreateParams.Type.S3) - assertThat(body.accessKey()).contains("x") - assertThat(body.accountName()).contains("x") - assertThat(body.baseUrl()).contains("https://example.com") - assertThat(body.baseUrlForCanonicalHeader()).contains("https://example.com") - assertThat(body.bucket()).contains("x") - assertThat(body.clientEmail()).contains("dev@stainless.com") - assertThat(body.clientId()).contains("x") - assertThat(body.clientSecret()).contains("x") - assertThat(body.container()).contains("x") - assertThat(body.endpoint()).contains("https://example.com") - assertThat(body.forwardHostHeaderToOrigin()).contains(true) - assertThat(body.includeCanonicalHeader()).contains(true) - assertThat(body.password()).contains("x") - assertThat(body.prefix()).contains("prefix") - assertThat(body.privateKey()).contains("x") - assertThat(body.s3ForcePathStyle()).contains(true) - assertThat(body.sasToken()).contains("x") - assertThat(body.secretKey()).contains("x") - assertThat(body.username()).contains("x") + assertThat(body) + .isEqualTo( + OriginCreateParams.Origin.ofS3( + OriginCreateParams.Origin.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().name("name").type(OriginCreateParams.Type.S3).build() + OriginCreateParams.builder() + .origin( + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) + .build() val body = params._body() - assertThat(body.name()).isEqualTo("name") - assertThat(body.type()).isEqualTo(OriginCreateParams.Type.S3) + assertThat(body) + .isEqualTo( + OriginCreateParams.Origin.ofS3( + OriginCreateParams.Origin.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/OriginUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt index 8591b885..ac041a2b 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,27 +11,17 @@ internal class OriginUpdateParamsTest { fun create() { OriginUpdateParams.builder() .id("id") - .name("name") - .type(OriginUpdateParams.Type.S3) - .accessKey("x") - .accountName("x") - .baseUrl("https://example.com") - .baseUrlForCanonicalHeader("https://example.com") - .bucket("x") - .clientEmail("dev@stainless.com") - .clientId("x") - .clientSecret("x") - .container("x") - .endpoint("https://example.com") - .forwardHostHeaderToOrigin(true) - .includeCanonicalHeader(true) - .password("x") - .prefix("prefix") - .privateKey("x") - .s3ForcePathStyle(true) - .sasToken("x") - .secretKey("x") - .username("x") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) .build() } @@ -40,8 +30,14 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .name("name") - .type(OriginUpdateParams.Type.S3) + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) .build() assertThat(params._pathParam(0)).isEqualTo("id") @@ -54,52 +50,35 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .name("name") - .type(OriginUpdateParams.Type.S3) - .accessKey("x") - .accountName("x") - .baseUrl("https://example.com") - .baseUrlForCanonicalHeader("https://example.com") - .bucket("x") - .clientEmail("dev@stainless.com") - .clientId("x") - .clientSecret("x") - .container("x") - .endpoint("https://example.com") - .forwardHostHeaderToOrigin(true) - .includeCanonicalHeader(true) - .password("x") - .prefix("prefix") - .privateKey("x") - .s3ForcePathStyle(true) - .sasToken("x") - .secretKey("x") - .username("x") + .body( + OriginUpdateParams.Body.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.name()).isEqualTo("name") - assertThat(body.type()).isEqualTo(OriginUpdateParams.Type.S3) - assertThat(body.accessKey()).contains("x") - assertThat(body.accountName()).contains("x") - assertThat(body.baseUrl()).contains("https://example.com") - assertThat(body.baseUrlForCanonicalHeader()).contains("https://example.com") - assertThat(body.bucket()).contains("x") - assertThat(body.clientEmail()).contains("dev@stainless.com") - assertThat(body.clientId()).contains("x") - assertThat(body.clientSecret()).contains("x") - assertThat(body.container()).contains("x") - assertThat(body.endpoint()).contains("https://example.com") - assertThat(body.forwardHostHeaderToOrigin()).contains(true) - assertThat(body.includeCanonicalHeader()).contains(true) - assertThat(body.password()).contains("x") - assertThat(body.prefix()).contains("prefix") - assertThat(body.privateKey()).contains("x") - assertThat(body.s3ForcePathStyle()).contains(true) - assertThat(body.sasToken()).contains("x") - assertThat(body.secretKey()).contains("x") - assertThat(body.username()).contains("x") + assertThat(body) + .isEqualTo( + OriginUpdateParams.Body.ofS3( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + ) } @Test @@ -107,13 +86,28 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .name("name") - .type(OriginUpdateParams.Type.S3) + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) .build() val body = params._body() - assertThat(body.name()).isEqualTo("name") - assertThat(body.type()).isEqualTo(OriginUpdateParams.Type.S3) + assertThat(body) + .isEqualTo( + OriginUpdateParams.Body.ofS3( + OriginUpdateParams.Body.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/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index 3576f056..a3cb55f7 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 @@ -27,27 +27,17 @@ internal class OriginServiceAsyncTest { val originFuture = originServiceAsync.create( OriginCreateParams.builder() - .name("name") - .type(OriginCreateParams.Type.S3) - .accessKey("x") - .accountName("x") - .baseUrl("https://example.com") - .baseUrlForCanonicalHeader("https://example.com") - .bucket("x") - .clientEmail("dev@stainless.com") - .clientId("x") - .clientSecret("x") - .container("x") - .endpoint("https://example.com") - .forwardHostHeaderToOrigin(true) - .includeCanonicalHeader(true) - .password("x") - .prefix("prefix") - .privateKey("x") - .s3ForcePathStyle(true) - .sasToken("x") - .secretKey("x") - .username("x") + .origin( + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) .build() ) @@ -70,27 +60,17 @@ internal class OriginServiceAsyncTest { originServiceAsync.update( OriginUpdateParams.builder() .id("id") - .name("name") - .type(OriginUpdateParams.Type.S3) - .accessKey("x") - .accountName("x") - .baseUrl("https://example.com") - .baseUrlForCanonicalHeader("https://example.com") - .bucket("x") - .clientEmail("dev@stainless.com") - .clientId("x") - .clientSecret("x") - .container("x") - .endpoint("https://example.com") - .forwardHostHeaderToOrigin(true) - .includeCanonicalHeader(true) - .password("x") - .prefix("prefix") - .privateKey("x") - .s3ForcePathStyle(true) - .sasToken("x") - .secretKey("x") - .username("x") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .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 8aebefb8..100ab77a 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 @@ -27,27 +27,17 @@ internal class OriginServiceTest { val origin = originService.create( OriginCreateParams.builder() - .name("name") - .type(OriginCreateParams.Type.S3) - .accessKey("x") - .accountName("x") - .baseUrl("https://example.com") - .baseUrlForCanonicalHeader("https://example.com") - .bucket("x") - .clientEmail("dev@stainless.com") - .clientId("x") - .clientSecret("x") - .container("x") - .endpoint("https://example.com") - .forwardHostHeaderToOrigin(true) - .includeCanonicalHeader(true) - .password("x") - .prefix("prefix") - .privateKey("x") - .s3ForcePathStyle(true) - .sasToken("x") - .secretKey("x") - .username("x") + .origin( + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) .build() ) @@ -69,27 +59,17 @@ internal class OriginServiceTest { originService.update( OriginUpdateParams.builder() .id("id") - .name("name") - .type(OriginUpdateParams.Type.S3) - .accessKey("x") - .accountName("x") - .baseUrl("https://example.com") - .baseUrlForCanonicalHeader("https://example.com") - .bucket("x") - .clientEmail("dev@stainless.com") - .clientId("x") - .clientSecret("x") - .container("x") - .endpoint("https://example.com") - .forwardHostHeaderToOrigin(true) - .includeCanonicalHeader(true) - .password("x") - .prefix("prefix") - .privateKey("x") - .s3ForcePathStyle(true) - .sasToken("x") - .secretKey("x") - .username("x") + .body( + OriginUpdateParams.Body.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) .build() ) From d35e263a7af3e06d3a8174160de02dc79d66b022 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 13:06:37 +0000 Subject: [PATCH 037/125] feat(api): manual updates --- .stats.yml | 2 +- .../accounts/origins/OriginUpdateParams.kt | 152 +++++++++--------- .../api/models/files/FileUpdateParams.kt | 123 +++++++------- .../origins/OriginUpdateParamsTest.kt | 24 +-- .../api/models/files/FileUpdateParamsTest.kt | 80 ++++----- .../services/async/FileServiceAsyncTest.kt | 74 +++++---- .../async/accounts/OriginServiceAsyncTest.kt | 4 +- .../api/services/blocking/FileServiceTest.kt | 74 +++++---- .../blocking/accounts/OriginServiceTest.kt | 4 +- 9 files changed, 277 insertions(+), 260 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4fc82ca0..4f127f14 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-76afc867b06fdc43b339f2c7d19f25a46481b25e8264ca24ea43daa1ea9234fc.yml openapi_spec_hash: a1455d2ab02c48a14551362dd8ec2261 -config_hash: 396f0b1c74b8b5bc4dd6b5d87e374d90 +config_hash: c434cea5e670c34d574784866661bebd 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 4f23d963..7b663b82 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 @@ -38,7 +38,7 @@ import kotlin.jvm.optionals.getOrNull class OriginUpdateParams private constructor( private val id: String?, - private val body: Body, + private val origin: Origin, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -49,7 +49,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** Schema for origin resources. */ - fun body(): Body = body + fun origin(): Origin = origin /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -66,7 +66,7 @@ private constructor( * * The following fields are required: * ```java - * .body() + * .origin() * ``` */ @JvmStatic fun builder() = Builder() @@ -76,14 +76,14 @@ private constructor( class Builder internal constructor() { private var id: String? = null - private var body: Body? = null + private var origin: Origin? = 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 - body = originUpdateParams.body + origin = originUpdateParams.origin additionalHeaders = originUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = originUpdateParams.additionalQueryParams.toBuilder() } @@ -98,34 +98,36 @@ private constructor( fun id(id: Optional) = id(id.getOrNull()) /** Schema for origin resources. */ - fun body(body: Body) = apply { this.body = body } + fun origin(origin: Origin) = apply { this.origin = origin } - /** Alias for calling [body] with `Body.ofS3(s3)`. */ - fun body(s3: Body.S3) = body(Body.ofS3(s3)) + /** Alias for calling [origin] with `Origin.ofS3(s3)`. */ + fun origin(s3: Origin.S3) = origin(Origin.ofS3(s3)) - /** Alias for calling [body] with `Body.ofS3Compatible(s3Compatible)`. */ - fun body(s3Compatible: Body.S3Compatible) = body(Body.ofS3Compatible(s3Compatible)) + /** Alias for calling [origin] with `Origin.ofS3Compatible(s3Compatible)`. */ + fun origin(s3Compatible: Origin.S3Compatible) = origin(Origin.ofS3Compatible(s3Compatible)) - /** Alias for calling [body] with `Body.ofCloudinaryBackup(cloudinaryBackup)`. */ - fun body(cloudinaryBackup: Body.CloudinaryBackup) = - body(Body.ofCloudinaryBackup(cloudinaryBackup)) + /** Alias for calling [origin] with `Origin.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun origin(cloudinaryBackup: Origin.CloudinaryBackup) = + origin(Origin.ofCloudinaryBackup(cloudinaryBackup)) - /** Alias for calling [body] with `Body.ofWebFolder(webFolder)`. */ - fun body(webFolder: Body.WebFolder) = body(Body.ofWebFolder(webFolder)) + /** Alias for calling [origin] with `Origin.ofWebFolder(webFolder)`. */ + fun origin(webFolder: Origin.WebFolder) = origin(Origin.ofWebFolder(webFolder)) - /** Alias for calling [body] with `Body.ofWebProxy(webProxy)`. */ - fun body(webProxy: Body.WebProxy) = body(Body.ofWebProxy(webProxy)) + /** Alias for calling [origin] with `Origin.ofWebProxy(webProxy)`. */ + fun origin(webProxy: Origin.WebProxy) = origin(Origin.ofWebProxy(webProxy)) - /** Alias for calling [body] with `Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. */ - fun body(googleCloudStorageGcs: Body.GoogleCloudStorageGcs) = - body(Body.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + /** + * Alias for calling [origin] with `Origin.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. + */ + fun origin(googleCloudStorageGcs: Origin.GoogleCloudStorageGcs) = + origin(Origin.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) - /** Alias for calling [body] with `Body.ofAzureBlobStorage(azureBlobStorage)`. */ - fun body(azureBlobStorage: Body.AzureBlobStorage) = - body(Body.ofAzureBlobStorage(azureBlobStorage)) + /** Alias for calling [origin] with `Origin.ofAzureBlobStorage(azureBlobStorage)`. */ + fun origin(azureBlobStorage: Origin.AzureBlobStorage) = + origin(Origin.ofAzureBlobStorage(azureBlobStorage)) - /** Alias for calling [body] with `Body.ofAkeneoPim(akeneoPim)`. */ - fun body(akeneoPim: Body.AkeneoPim) = body(Body.ofAkeneoPim(akeneoPim)) + /** Alias for calling [origin] with `Origin.ofAkeneoPim(akeneoPim)`. */ + fun origin(akeneoPim: Origin.AkeneoPim) = origin(Origin.ofAkeneoPim(akeneoPim)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -232,7 +234,7 @@ private constructor( * * The following fields are required: * ```java - * .body() + * .origin() * ``` * * @throws IllegalStateException if any required field is unset. @@ -240,13 +242,13 @@ private constructor( fun build(): OriginUpdateParams = OriginUpdateParams( id, - checkRequired("body", body), + checkRequired("origin", origin), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): Body = body + fun _body(): Origin = origin fun _pathParam(index: Int): String = when (index) { @@ -259,9 +261,9 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams /** Schema for origin resources. */ - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body + @JsonDeserialize(using = Origin.Deserializer::class) + @JsonSerialize(using = Origin.Serializer::class) + class Origin private constructor( private val s3: S3? = null, private val s3Compatible: S3Compatible? = null, @@ -342,7 +344,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { + fun validate(): Origin = apply { if (validated) { return@apply } @@ -435,7 +437,7 @@ private constructor( return true } - return other is Body && + return other is Origin && s3 == other.s3 && s3Compatible == other.s3Compatible && cloudinaryBackup == other.cloudinaryBackup && @@ -460,46 +462,46 @@ private constructor( override fun toString(): String = when { - s3 != null -> "Body{s3=$s3}" - s3Compatible != null -> "Body{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "Body{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "Body{webFolder=$webFolder}" - webProxy != null -> "Body{webProxy=$webProxy}" + s3 != null -> "Origin{s3=$s3}" + s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "Origin{webFolder=$webFolder}" + webProxy != null -> "Origin{webProxy=$webProxy}" googleCloudStorageGcs != null -> - "Body{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "Body{azureBlobStorage=$azureBlobStorage}" - akeneoPim != null -> "Body{akeneoPim=$akeneoPim}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") + "Origin{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "Origin{azureBlobStorage=$azureBlobStorage}" + akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" + _json != null -> "Origin{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Origin") } companion object { - @JvmStatic fun ofS3(s3: S3) = Body(s3 = s3) + @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = Body(s3Compatible = s3Compatible) + fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) @JvmStatic fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - Body(cloudinaryBackup = cloudinaryBackup) + Origin(cloudinaryBackup = cloudinaryBackup) - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Body(webFolder = webFolder) + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Body(webProxy = webProxy) + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) @JvmStatic fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - Body(googleCloudStorageGcs = googleCloudStorageGcs) + Origin(googleCloudStorageGcs = googleCloudStorageGcs) @JvmStatic fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - Body(azureBlobStorage = azureBlobStorage) + Origin(azureBlobStorage = azureBlobStorage) - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Body(akeneoPim = akeneoPim) + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) } - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + /** An interface that defines how to map each variant of [Origin] to a value of type [T]. */ interface Visitor { fun visitS3(s3: S3): T @@ -519,49 +521,50 @@ private constructor( fun visitAkeneoPim(akeneoPim: AkeneoPim): T /** - * Maps an unknown variant of [Body] to a value of type [T]. + * Maps an unknown variant of [Origin] 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. + * An instance of [Origin] 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") + throw ImageKitInvalidDataException("Unknown Origin: $json") } } - internal class Deserializer : BaseDeserializer(Body::class) { + internal class Deserializer : BaseDeserializer(Origin::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Body { + override fun ObjectCodec.deserialize(node: JsonNode): Origin { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3 = it, _json = json) + Origin(s3 = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(s3Compatible = it, _json = json) + Origin(s3Compatible = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(cloudinaryBackup = it, _json = json) + Origin(cloudinaryBackup = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(webFolder = it, _json = json) + Origin(webFolder = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(webProxy = it, _json = json) + Origin(webProxy = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(googleCloudStorageGcs = it, _json = json) + Origin(googleCloudStorageGcs = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(azureBlobStorage = it, _json = json) + Origin(azureBlobStorage = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(akeneoPim = it, _json = json) + Origin(akeneoPim = it, _json = json) }, ) .filterNotNull() @@ -570,7 +573,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 -> Body(_json = json) + 0 -> Origin(_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 @@ -580,10 +583,10 @@ private constructor( } } - internal class Serializer : BaseSerializer(Body::class) { + internal class Serializer : BaseSerializer(Origin::class) { override fun serialize( - value: Body, + value: Origin, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -598,7 +601,7 @@ private constructor( value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) value.akeneoPim != null -> generator.writeObject(value.akeneoPim) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") + else -> throw IllegalStateException("Invalid Origin") } } } @@ -4264,13 +4267,14 @@ private constructor( return other is OriginUpdateParams && id == other.id && - body == other.body && + origin == other.origin && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(id, origin, additionalHeaders, additionalQueryParams) override fun toString() = - "OriginUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "OriginUpdateParams{id=$id, origin=$origin, 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 a6c526b0..2f8a39b0 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 @@ -42,14 +42,14 @@ import kotlin.jvm.optionals.getOrNull class FileUpdateParams private constructor( private val fileId: String?, - private val body: Body?, + private val update: Update?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun fileId(): Optional = Optional.ofNullable(fileId) - fun body(): Optional = Optional.ofNullable(body) + fun update(): Optional = Optional.ofNullable(update) /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -71,14 +71,14 @@ private constructor( class Builder internal constructor() { private var fileId: String? = null - private var body: Body? = 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 - body = fileUpdateParams.body + update = fileUpdateParams.update additionalHeaders = fileUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = fileUpdateParams.additionalQueryParams.toBuilder() } @@ -88,20 +88,21 @@ 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 update(update: Update?) = apply { this.update = update } - /** Alias for calling [Builder.body] with `body.orElse(null)`. */ - fun body(body: Optional) = body(body.getOrNull()) + /** Alias for calling [Builder.update] with `update.orElse(null)`. */ + fun update(update: Optional) = update(update.getOrNull()) - /** Alias for calling [body] with `Body.ofUpdateFileDetails(updateFileDetails)`. */ - fun body(updateFileDetails: Body.UpdateFileDetails) = - body(Body.ofUpdateFileDetails(updateFileDetails)) + /** Alias for calling [update] with `Update.ofFileDetails(fileDetails)`. */ + fun update(fileDetails: Update.UpdateFileDetails) = + update(Update.ofFileDetails(fileDetails)) /** - * Alias for calling [body] with `Body.ofChangePublicationStatus(changePublicationStatus)`. + * Alias for calling [update] with + * `Update.ofChangePublicationStatus(changePublicationStatus)`. */ - fun body(changePublicationStatus: Body.ChangePublicationStatus) = - body(Body.ofChangePublicationStatus(changePublicationStatus)) + fun update(changePublicationStatus: Update.ChangePublicationStatus) = + update(Update.ofChangePublicationStatus(changePublicationStatus)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -207,10 +208,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, + update, + additionalHeaders.build(), + additionalQueryParams.build(), + ) } - fun _body(): Optional = Optional.ofNullable(body) + fun _body(): Optional = Optional.ofNullable(update) fun _pathParam(index: Int): String = when (index) { @@ -222,27 +228,25 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body + @JsonDeserialize(using = Update.Deserializer::class) + @JsonSerialize(using = Update.Serializer::class) + class Update private constructor( - private val updateFileDetails: UpdateFileDetails? = null, + private val fileDetails: UpdateFileDetails? = null, private val changePublicationStatus: ChangePublicationStatus? = null, private val _json: JsonValue? = null, ) { - fun updateFileDetails(): Optional = - Optional.ofNullable(updateFileDetails) + fun fileDetails(): Optional = Optional.ofNullable(fileDetails) fun changePublicationStatus(): Optional = Optional.ofNullable(changePublicationStatus) - fun isUpdateFileDetails(): Boolean = updateFileDetails != null + fun isFileDetails(): Boolean = fileDetails != null fun isChangePublicationStatus(): Boolean = changePublicationStatus != null - fun asUpdateFileDetails(): UpdateFileDetails = - updateFileDetails.getOrThrow("updateFileDetails") + fun asFileDetails(): UpdateFileDetails = fileDetails.getOrThrow("fileDetails") fun asChangePublicationStatus(): ChangePublicationStatus = changePublicationStatus.getOrThrow("changePublicationStatus") @@ -251,7 +255,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - updateFileDetails != null -> visitor.visitUpdateFileDetails(updateFileDetails) + fileDetails != null -> visitor.visitFileDetails(fileDetails) changePublicationStatus != null -> visitor.visitChangePublicationStatus(changePublicationStatus) else -> visitor.unknown(_json) @@ -259,15 +263,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { + fun validate(): Update = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) { - updateFileDetails.validate() + override fun visitFileDetails(fileDetails: UpdateFileDetails) { + fileDetails.validate() } override fun visitChangePublicationStatus( @@ -298,8 +302,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) = - updateFileDetails.validity() + override fun visitFileDetails(fileDetails: UpdateFileDetails) = + fileDetails.validity() override fun visitChangePublicationStatus( changePublicationStatus: ChangePublicationStatus @@ -314,66 +318,66 @@ private constructor( return true } - return other is Body && - updateFileDetails == other.updateFileDetails && + return other is Update && + fileDetails == other.fileDetails && changePublicationStatus == other.changePublicationStatus } - override fun hashCode(): Int = Objects.hash(updateFileDetails, changePublicationStatus) + override fun hashCode(): Int = Objects.hash(fileDetails, changePublicationStatus) override fun toString(): String = when { - updateFileDetails != null -> "Body{updateFileDetails=$updateFileDetails}" + fileDetails != null -> "Update{fileDetails=$fileDetails}" changePublicationStatus != null -> - "Body{changePublicationStatus=$changePublicationStatus}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") + "Update{changePublicationStatus=$changePublicationStatus}" + _json != null -> "Update{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Update") } companion object { @JvmStatic - fun ofUpdateFileDetails(updateFileDetails: UpdateFileDetails) = - Body(updateFileDetails = updateFileDetails) + fun ofFileDetails(fileDetails: UpdateFileDetails) = Update(fileDetails = fileDetails) @JvmStatic fun ofChangePublicationStatus(changePublicationStatus: ChangePublicationStatus) = - Body(changePublicationStatus = changePublicationStatus) + Update(changePublicationStatus = changePublicationStatus) } - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + /** An interface that defines how to map each variant of [Update] to a value of type [T]. */ interface Visitor { - fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails): T + fun visitFileDetails(fileDetails: UpdateFileDetails): T fun visitChangePublicationStatus(changePublicationStatus: ChangePublicationStatus): T /** - * Maps an unknown variant of [Body] to a value of type [T]. + * Maps an unknown variant of [Update] 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. + * 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 Body: $json") + throw ImageKitInvalidDataException("Unknown Update: $json") } } - internal class Deserializer : BaseDeserializer(Body::class) { + internal class Deserializer : BaseDeserializer(Update::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Body { + override fun ObjectCodec.deserialize(node: JsonNode): Update { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - Body(updateFileDetails = it, _json = json) + Update(fileDetails = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Body(changePublicationStatus = it, _json = json) + Update(changePublicationStatus = it, _json = json) }, ) .filterNotNull() @@ -382,7 +386,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 -> Body(_json = json) + 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 @@ -392,20 +396,19 @@ private constructor( } } - internal class Serializer : BaseSerializer(Body::class) { + internal class Serializer : BaseSerializer(Update::class) { override fun serialize( - value: Body, + value: Update, generator: JsonGenerator, provider: SerializerProvider, ) { when { - value.updateFileDetails != null -> - generator.writeObject(value.updateFileDetails) + 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 Body") + else -> throw IllegalStateException("Invalid Update") } } } @@ -2743,14 +2746,14 @@ private constructor( return other is FileUpdateParams && fileId == other.fileId && - body == other.body && + update == other.update && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(fileId, body, additionalHeaders, additionalQueryParams) + Objects.hash(fileId, update, additionalHeaders, additionalQueryParams) override fun toString() = - "FileUpdateParams{fileId=$fileId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileUpdateParams{fileId=$fileId, update=$update, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 ac041a2b..e9be0a35 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,8 +11,8 @@ internal class OriginUpdateParamsTest { fun create() { OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3.builder() + .origin( + OriginUpdateParams.Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -30,8 +30,8 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3.builder() + .origin( + OriginUpdateParams.Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -50,8 +50,8 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3.builder() + .origin( + OriginUpdateParams.Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -67,8 +67,8 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - OriginUpdateParams.Body.ofS3( - OriginUpdateParams.Body.S3.builder() + OriginUpdateParams.Origin.ofS3( + OriginUpdateParams.Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -86,8 +86,8 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3.builder() + .origin( + OriginUpdateParams.Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -100,8 +100,8 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - OriginUpdateParams.Body.ofS3( - OriginUpdateParams.Body.S3.builder() + OriginUpdateParams.Origin.ofS3( + OriginUpdateParams.Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") 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 9e1d7e14..41e97d1c 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 @@ -13,11 +13,11 @@ internal class FileUpdateParamsTest { fun create() { FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -25,10 +25,11 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg.builder() + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg + .builder() .options( - FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg .Options .builder() .addShadow(true) @@ -39,35 +40,36 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAiAutoDescription(), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -93,11 +95,11 @@ internal class FileUpdateParamsTest { val params = FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -105,11 +107,11 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg .builder() .options( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemoveBg .Options .builder() @@ -121,35 +123,35 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .ofAiAutoDescription(), ) ) @@ -165,11 +167,11 @@ internal class FileUpdateParamsTest { assertThat(body) .isEqualTo( - FileUpdateParams.Body.ofUpdateFileDetails( - FileUpdateParams.Body.UpdateFileDetails.builder() + FileUpdateParams.Update.ofFileDetails( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -177,11 +179,11 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg .builder() .options( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemoveBg .Options .builder() @@ -193,35 +195,35 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .ofAiAutoDescription(), ) ) 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 d8e6799b..947eac17 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 @@ -32,11 +32,11 @@ internal class FileServiceAsyncTest { fileServiceAsync.update( FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -44,11 +44,11 @@ internal class FileServiceAsyncTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg .builder() .options( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemoveBg .Options .builder() @@ -60,35 +60,39 @@ internal class FileServiceAsyncTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension + 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(), ) ) 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 a3cb55f7..89426faf 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 @@ -60,8 +60,8 @@ internal class OriginServiceAsyncTest { originServiceAsync.update( OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3.builder() + .origin( + OriginUpdateParams.Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") 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 68654463..a55fbd4e 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 @@ -32,11 +32,11 @@ internal class FileServiceTest { fileService.update( FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -44,11 +44,11 @@ internal class FileServiceTest { .description("description") .extensions( listOf( - FileUpdateParams.Body.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Body.UpdateFileDetails.Extension.RemoveBg + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg .builder() .options( - FileUpdateParams.Body.UpdateFileDetails.Extension + FileUpdateParams.Update.UpdateFileDetails.Extension .RemoveBg .Options .builder() @@ -60,35 +60,39 @@ internal class FileServiceTest { ) .build() ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Body.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Body.UpdateFileDetails.Extension + 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(), ) ) 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 100ab77a..13880caa 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 @@ -59,8 +59,8 @@ internal class OriginServiceTest { originService.update( OriginUpdateParams.builder() .id("id") - .body( - OriginUpdateParams.Body.S3.builder() + .origin( + OriginUpdateParams.Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") From 9745e82746e5cf5f17f5c7dfe571936894eec368 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 13:10:43 +0000 Subject: [PATCH 038/125] feat(api): manual updates --- .stats.yml | 4 +- .../accounts/origins/OriginCreateParams.kt | 250 +++++++++--------- .../accounts/origins/OriginCreateResponse.kt | 229 ++++++++-------- .../accounts/origins/OriginGetResponse.kt | 230 ++++++++-------- .../accounts/origins/OriginListResponse.kt | 230 ++++++++-------- .../accounts/origins/OriginUpdateParams.kt | 249 +++++++++-------- .../accounts/origins/OriginUpdateResponse.kt | 229 ++++++++-------- .../urlendpoints/UrlEndpointCreateResponse.kt | 104 ++++---- .../urlendpoints/UrlEndpointGetResponse.kt | 104 ++++---- .../urlendpoints/UrlEndpointListResponse.kt | 104 ++++---- .../urlendpoints/UrlEndpointUpdateResponse.kt | 104 ++++---- .../origins/OriginCreateResponseTest.kt | 61 +++-- .../accounts/origins/OriginGetResponseTest.kt | 60 ++--- .../origins/OriginListResponseTest.kt | 60 ++--- .../origins/OriginUpdateResponseTest.kt | 61 +++-- .../UrlEndpointCreateResponseTest.kt | 14 +- .../UrlEndpointGetResponseTest.kt | 14 +- .../UrlEndpointListResponseTest.kt | 14 +- .../UrlEndpointUpdateResponseTest.kt | 14 +- 19 files changed, 1043 insertions(+), 1092 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4f127f14..61a94110 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-76afc867b06fdc43b339f2c7d19f25a46481b25e8264ca24ea43daa1ea9234fc.yml -openapi_spec_hash: a1455d2ab02c48a14551362dd8ec2261 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-4bc3e70493ee36b6dd29a92334f55232a5429d1bf03139d1f072f854c3ba5a6e.yml +openapi_spec_hash: 9b8384f2a421b73c3f03d1ca84c26113 config_hash: c434cea5e670c34d574784866661bebd 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 c733da5f..f11dbf68 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 @@ -20,7 +20,6 @@ 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.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers @@ -29,6 +28,7 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams @@ -96,14 +96,20 @@ private constructor( fun origin(webProxy: Origin.WebProxy) = origin(Origin.ofWebProxy(webProxy)) /** - * Alias for calling [origin] with `Origin.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. + * Alias for calling [origin] with the following: + * ```java + * Origin.WebProxy.builder() + * .name(name) + * .build() + * ``` */ - fun origin(googleCloudStorageGcs: Origin.GoogleCloudStorageGcs) = - origin(Origin.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + fun webProxyOrigin(name: String) = origin(Origin.WebProxy.builder().name(name).build()) - /** Alias for calling [origin] with `Origin.ofAzureBlobStorage(azureBlobStorage)`. */ - fun origin(azureBlobStorage: Origin.AzureBlobStorage) = - origin(Origin.ofAzureBlobStorage(azureBlobStorage)) + /** Alias for calling [origin] with `Origin.ofGcs(gcs)`. */ + fun origin(gcs: Origin.Gcs) = origin(Origin.ofGcs(gcs)) + + /** Alias for calling [origin] with `Origin.ofAzureBlob(azureBlob)`. */ + fun origin(azureBlob: Origin.AzureBlob) = origin(Origin.ofAzureBlob(azureBlob)) /** Alias for calling [origin] with `Origin.ofAkeneoPim(akeneoPim)`. */ fun origin(akeneoPim: Origin.AkeneoPim) = origin(Origin.ofAkeneoPim(akeneoPim)) @@ -242,8 +248,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -258,10 +264,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -275,9 +280,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -291,10 +296,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -307,9 +311,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -343,14 +346,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -391,12 +392,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -415,8 +413,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -427,8 +425,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -439,9 +437,8 @@ private constructor( cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "Origin{webFolder=$webFolder}" webProxy != null -> "Origin{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "Origin{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "Origin{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "Origin{gcs=$gcs}" + azureBlob != null -> "Origin{azureBlob=$azureBlob}" akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" _json != null -> "Origin{_unknown=$_json}" else -> throw IllegalStateException("Invalid Origin") @@ -462,13 +459,9 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - Origin(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) - @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - Origin(azureBlobStorage = azureBlobStorage) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) } @@ -486,9 +479,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -511,47 +504,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Origin { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(akeneoPim = 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 -> Origin(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3 = it, _json = json) + } ?: Origin(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3Compatible = it, _json = json) + } ?: Origin(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(cloudinaryBackup = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webFolder = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webProxy = it, _json = json) + } ?: Origin(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(gcs = it, _json = json) + } ?: Origin(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(azureBlob = it, _json = json) + } ?: Origin(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(akeneoPim = it, _json = json) + } ?: Origin(_json = json) + } } + + return Origin(_json = json) } } @@ -568,9 +566,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 Origin") @@ -2779,7 +2776,7 @@ private constructor( "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class Gcs private constructor( private val bucket: JsonField, private val clientEmail: JsonField, @@ -2965,8 +2962,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java @@ -2979,7 +2975,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [Gcs]. */ class Builder internal constructor() { private var bucket: JsonField? = null @@ -2993,16 +2989,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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)) @@ -3133,7 +3129,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [Gcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3147,8 +3143,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), checkRequired("name", name), @@ -3163,7 +3159,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } @@ -3213,7 +3209,7 @@ private constructor( return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && bucket == other.bucket && clientEmail == other.clientEmail && name == other.name && @@ -3242,10 +3238,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "Gcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlob private constructor( private val accountName: JsonField, private val container: JsonField, @@ -3432,7 +3428,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java @@ -3445,7 +3441,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlob]. */ class Builder internal constructor() { private var accountName: JsonField? = null @@ -3459,16 +3455,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + 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)) @@ -3597,7 +3593,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlob]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3611,8 +3607,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( checkRequired("accountName", accountName), checkRequired("container", container), checkRequired("name", name), @@ -3627,7 +3623,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } @@ -3677,7 +3673,7 @@ private constructor( return true } - return other is AzureBlobStorage && + return other is AzureBlob && accountName == other.accountName && container == other.container && name == other.name && @@ -3706,7 +3702,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "AzureBlob{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt index b72b2ef6..4eb17b1b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt @@ -19,13 +19,13 @@ 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.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 = OriginCreateResponse.Deserializer::class) @@ -37,8 +37,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -53,10 +53,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -70,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -86,10 +85,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -102,9 +100,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -138,14 +135,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -184,12 +179,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -208,8 +200,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -220,8 +212,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -232,9 +224,8 @@ private constructor( cloudinaryBackup != null -> "OriginCreateResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginCreateResponse{webFolder=$webFolder}" webProxy != null -> "OriginCreateResponse{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "OriginCreateResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "OriginCreateResponse{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "OriginCreateResponse{gcs=$gcs}" + azureBlob != null -> "OriginCreateResponse{azureBlob=$azureBlob}" akeneoPim != null -> "OriginCreateResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginCreateResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginCreateResponse") @@ -257,13 +248,10 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginCreateResponse(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - OriginCreateResponse(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginCreateResponse(gcs = gcs) @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - OriginCreateResponse(azureBlobStorage = azureBlobStorage) + fun ofAzureBlob(azureBlob: AzureBlob) = OriginCreateResponse(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginCreateResponse(akeneoPim = akeneoPim) @@ -285,9 +273,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -311,46 +299,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginCreateResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(akeneoPim = 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 -> OriginCreateResponse(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(s3 = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(s3Compatible = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(cloudinaryBackup = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(webFolder = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(webProxy = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(gcs = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(azureBlob = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(akeneoPim = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } } + + return OriginCreateResponse(_json = json) } } @@ -367,9 +361,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 OriginCreateResponse") @@ -2499,7 +2492,7 @@ private constructor( "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class Gcs private constructor( private val id: JsonField, private val bucket: JsonField, @@ -2676,7 +2669,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java @@ -2691,7 +2684,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [Gcs]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -2705,16 +2698,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - id = googleCloudStorageGcs.id - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - name = googleCloudStorageGcs.name - prefix = googleCloudStorageGcs.prefix - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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() } /** @@ -2843,7 +2836,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [Gcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2859,8 +2852,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), @@ -2875,7 +2868,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } @@ -2925,7 +2918,7 @@ private constructor( return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && @@ -2954,10 +2947,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlob private constructor( private val id: JsonField, private val accountName: JsonField, @@ -3136,7 +3129,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java @@ -3151,7 +3144,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlob]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3165,16 +3158,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(azureBlobStorage: AzureBlobStorage) = apply { - id = azureBlobStorage.id - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - name = azureBlobStorage.name - prefix = azureBlobStorage.prefix - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + 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() } /** @@ -3303,7 +3296,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlob]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3319,8 +3312,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( checkRequired("id", id), checkRequired("accountName", accountName), checkRequired("container", container), @@ -3335,7 +3328,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } @@ -3385,7 +3378,7 @@ private constructor( return true } - return other is AzureBlobStorage && + return other is AzureBlob && id == other.id && accountName == other.accountName && container == other.container && @@ -3414,7 +3407,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "AzureBlob{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class AkeneoPim diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt index fff95a19..81dffd47 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt @@ -19,13 +19,13 @@ 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.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 = OriginGetResponse.Deserializer::class) @@ -37,8 +37,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -53,10 +53,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -70,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -86,10 +85,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -102,9 +100,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -138,14 +135,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -184,12 +179,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -208,8 +200,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -220,8 +212,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -232,9 +224,8 @@ private constructor( cloudinaryBackup != null -> "OriginGetResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginGetResponse{webFolder=$webFolder}" webProxy != null -> "OriginGetResponse{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "OriginGetResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "OriginGetResponse{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "OriginGetResponse{gcs=$gcs}" + azureBlob != null -> "OriginGetResponse{azureBlob=$azureBlob}" akeneoPim != null -> "OriginGetResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginGetResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginGetResponse") @@ -256,13 +247,9 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginGetResponse(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - OriginGetResponse(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginGetResponse(gcs = gcs) - @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - OriginGetResponse(azureBlobStorage = azureBlobStorage) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginGetResponse(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginGetResponse(akeneoPim = akeneoPim) } @@ -283,9 +270,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -308,46 +295,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginGetResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(akeneoPim = 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 -> OriginGetResponse(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(s3 = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(s3Compatible = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(cloudinaryBackup = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(webFolder = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(webProxy = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(gcs = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(azureBlob = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(akeneoPim = it, _json = json) + } ?: OriginGetResponse(_json = json) + } } + + return OriginGetResponse(_json = json) } } @@ -364,9 +357,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 OriginGetResponse") @@ -2496,7 +2488,7 @@ private constructor( "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class Gcs private constructor( private val id: JsonField, private val bucket: JsonField, @@ -2673,7 +2665,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java @@ -2688,7 +2680,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [Gcs]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -2702,16 +2694,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - id = googleCloudStorageGcs.id - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - name = googleCloudStorageGcs.name - prefix = googleCloudStorageGcs.prefix - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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() } /** @@ -2840,7 +2832,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [Gcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2856,8 +2848,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), @@ -2872,7 +2864,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } @@ -2922,7 +2914,7 @@ private constructor( return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && @@ -2951,10 +2943,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlob private constructor( private val id: JsonField, private val accountName: JsonField, @@ -3133,7 +3125,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java @@ -3148,7 +3140,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlob]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3162,16 +3154,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(azureBlobStorage: AzureBlobStorage) = apply { - id = azureBlobStorage.id - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - name = azureBlobStorage.name - prefix = azureBlobStorage.prefix - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + 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() } /** @@ -3300,7 +3292,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlob]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3316,8 +3308,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( checkRequired("id", id), checkRequired("accountName", accountName), checkRequired("container", container), @@ -3332,7 +3324,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } @@ -3382,7 +3374,7 @@ private constructor( return true } - return other is AzureBlobStorage && + return other is AzureBlob && id == other.id && accountName == other.accountName && container == other.container && @@ -3411,7 +3403,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "AzureBlob{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class AkeneoPim diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt index 4b159e15..8ec0a69e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt @@ -19,13 +19,13 @@ 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.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 = OriginListResponse.Deserializer::class) @@ -37,8 +37,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -53,10 +53,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -70,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -86,10 +85,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -102,9 +100,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -138,14 +135,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -184,12 +179,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -208,8 +200,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -220,8 +212,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -232,9 +224,8 @@ private constructor( cloudinaryBackup != null -> "OriginListResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginListResponse{webFolder=$webFolder}" webProxy != null -> "OriginListResponse{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "OriginListResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "OriginListResponse{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "OriginListResponse{gcs=$gcs}" + azureBlob != null -> "OriginListResponse{azureBlob=$azureBlob}" akeneoPim != null -> "OriginListResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginListResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginListResponse") @@ -256,13 +247,9 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginListResponse(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - OriginListResponse(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginListResponse(gcs = gcs) - @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - OriginListResponse(azureBlobStorage = azureBlobStorage) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginListResponse(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginListResponse(akeneoPim = akeneoPim) } @@ -283,9 +270,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -308,46 +295,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginListResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(akeneoPim = 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 -> OriginListResponse(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(s3 = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(s3Compatible = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(cloudinaryBackup = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(webFolder = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(webProxy = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(gcs = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(azureBlob = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(akeneoPim = it, _json = json) + } ?: OriginListResponse(_json = json) + } } + + return OriginListResponse(_json = json) } } @@ -364,9 +357,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 OriginListResponse") @@ -2496,7 +2488,7 @@ private constructor( "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class Gcs private constructor( private val id: JsonField, private val bucket: JsonField, @@ -2673,7 +2665,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java @@ -2688,7 +2680,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [Gcs]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -2702,16 +2694,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - id = googleCloudStorageGcs.id - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - name = googleCloudStorageGcs.name - prefix = googleCloudStorageGcs.prefix - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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() } /** @@ -2840,7 +2832,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [Gcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2856,8 +2848,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), @@ -2872,7 +2864,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } @@ -2922,7 +2914,7 @@ private constructor( return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && @@ -2951,10 +2943,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlob private constructor( private val id: JsonField, private val accountName: JsonField, @@ -3133,7 +3125,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java @@ -3148,7 +3140,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlob]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3162,16 +3154,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(azureBlobStorage: AzureBlobStorage) = apply { - id = azureBlobStorage.id - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - name = azureBlobStorage.name - prefix = azureBlobStorage.prefix - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + 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() } /** @@ -3300,7 +3292,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlob]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3316,8 +3308,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( checkRequired("id", id), checkRequired("accountName", accountName), checkRequired("container", container), @@ -3332,7 +3324,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } @@ -3382,7 +3374,7 @@ private constructor( return true } - return other is AzureBlobStorage && + return other is AzureBlob && id == other.id && accountName == other.accountName && container == other.container && @@ -3411,7 +3403,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "AzureBlob{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class AkeneoPim 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 7b663b82..ce410564 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 @@ -20,7 +20,6 @@ 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.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers @@ -117,14 +116,20 @@ private constructor( fun origin(webProxy: Origin.WebProxy) = origin(Origin.ofWebProxy(webProxy)) /** - * Alias for calling [origin] with `Origin.ofGoogleCloudStorageGcs(googleCloudStorageGcs)`. + * Alias for calling [origin] with the following: + * ```java + * Origin.WebProxy.builder() + * .name(name) + * .build() + * ``` */ - fun origin(googleCloudStorageGcs: Origin.GoogleCloudStorageGcs) = - origin(Origin.ofGoogleCloudStorageGcs(googleCloudStorageGcs)) + fun webProxyOrigin(name: String) = origin(Origin.WebProxy.builder().name(name).build()) - /** Alias for calling [origin] with `Origin.ofAzureBlobStorage(azureBlobStorage)`. */ - fun origin(azureBlobStorage: Origin.AzureBlobStorage) = - origin(Origin.ofAzureBlobStorage(azureBlobStorage)) + /** Alias for calling [origin] with `Origin.ofGcs(gcs)`. */ + fun origin(gcs: Origin.Gcs) = origin(Origin.ofGcs(gcs)) + + /** Alias for calling [origin] with `Origin.ofAzureBlob(azureBlob)`. */ + fun origin(azureBlob: Origin.AzureBlob) = origin(Origin.ofAzureBlob(azureBlob)) /** Alias for calling [origin] with `Origin.ofAkeneoPim(akeneoPim)`. */ fun origin(akeneoPim: Origin.AkeneoPim) = origin(Origin.ofAkeneoPim(akeneoPim)) @@ -270,8 +275,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -286,10 +291,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -303,9 +307,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -319,10 +323,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -335,9 +338,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -371,14 +373,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -419,12 +419,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -443,8 +440,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -455,8 +452,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -467,9 +464,8 @@ private constructor( cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "Origin{webFolder=$webFolder}" webProxy != null -> "Origin{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "Origin{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "Origin{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "Origin{gcs=$gcs}" + azureBlob != null -> "Origin{azureBlob=$azureBlob}" akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" _json != null -> "Origin{_unknown=$_json}" else -> throw IllegalStateException("Invalid Origin") @@ -490,13 +486,9 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - Origin(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) - @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - Origin(azureBlobStorage = azureBlobStorage) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) } @@ -514,9 +506,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -539,47 +531,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Origin { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Origin(akeneoPim = 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 -> Origin(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3 = it, _json = json) + } ?: Origin(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3Compatible = it, _json = json) + } ?: Origin(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(cloudinaryBackup = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webFolder = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webProxy = it, _json = json) + } ?: Origin(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(gcs = it, _json = json) + } ?: Origin(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(azureBlob = it, _json = json) + } ?: Origin(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(akeneoPim = it, _json = json) + } ?: Origin(_json = json) + } } + + return Origin(_json = json) } } @@ -596,9 +593,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 Origin") @@ -2807,7 +2803,7 @@ private constructor( "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class Gcs private constructor( private val bucket: JsonField, private val clientEmail: JsonField, @@ -2993,8 +2989,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java @@ -3007,7 +3002,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [Gcs]. */ class Builder internal constructor() { private var bucket: JsonField? = null @@ -3021,16 +3016,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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)) @@ -3161,7 +3156,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [Gcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3175,8 +3170,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), checkRequired("name", name), @@ -3191,7 +3186,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } @@ -3241,7 +3236,7 @@ private constructor( return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && bucket == other.bucket && clientEmail == other.clientEmail && name == other.name && @@ -3270,10 +3265,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "Gcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlob private constructor( private val accountName: JsonField, private val container: JsonField, @@ -3460,7 +3455,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java @@ -3473,7 +3468,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlob]. */ class Builder internal constructor() { private var accountName: JsonField? = null @@ -3487,16 +3482,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + 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)) @@ -3625,7 +3620,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlob]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3639,8 +3634,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( checkRequired("accountName", accountName), checkRequired("container", container), checkRequired("name", name), @@ -3655,7 +3650,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } @@ -3705,7 +3700,7 @@ private constructor( return true } - return other is AzureBlobStorage && + return other is AzureBlob && accountName == other.accountName && container == other.container && name == other.name && @@ -3734,7 +3729,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "AzureBlob{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt index d2c571f8..06009d04 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt @@ -19,13 +19,13 @@ 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.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 = OriginUpdateResponse.Deserializer::class) @@ -37,8 +37,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -53,10 +53,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -70,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -86,10 +85,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -102,9 +100,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -138,14 +135,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -184,12 +179,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -208,8 +200,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -220,8 +212,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -232,9 +224,8 @@ private constructor( cloudinaryBackup != null -> "OriginUpdateResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginUpdateResponse{webFolder=$webFolder}" webProxy != null -> "OriginUpdateResponse{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "OriginUpdateResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "OriginUpdateResponse{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "OriginUpdateResponse{gcs=$gcs}" + azureBlob != null -> "OriginUpdateResponse{azureBlob=$azureBlob}" akeneoPim != null -> "OriginUpdateResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginUpdateResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginUpdateResponse") @@ -257,13 +248,10 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginUpdateResponse(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - OriginUpdateResponse(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginUpdateResponse(gcs = gcs) @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - OriginUpdateResponse(azureBlobStorage = azureBlobStorage) + fun ofAzureBlob(azureBlob: AzureBlob) = OriginUpdateResponse(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginUpdateResponse(akeneoPim = akeneoPim) @@ -285,9 +273,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -311,46 +299,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginUpdateResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(akeneoPim = 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 -> OriginUpdateResponse(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(s3 = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(s3Compatible = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(cloudinaryBackup = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(webFolder = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(webProxy = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(gcs = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(azureBlob = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(akeneoPim = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } } + + return OriginUpdateResponse(_json = json) } } @@ -367,9 +361,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 OriginUpdateResponse") @@ -2499,7 +2492,7 @@ private constructor( "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + class Gcs private constructor( private val id: JsonField, private val bucket: JsonField, @@ -2676,7 +2669,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java @@ -2691,7 +2684,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** A builder for [Gcs]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -2705,16 +2698,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - id = googleCloudStorageGcs.id - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - name = googleCloudStorageGcs.name - prefix = googleCloudStorageGcs.prefix - type = googleCloudStorageGcs.type - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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() } /** @@ -2843,7 +2836,7 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * Returns an immutable instance of [Gcs]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2859,8 +2852,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), @@ -2875,7 +2868,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } @@ -2925,7 +2918,7 @@ private constructor( return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && @@ -2954,10 +2947,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + class AzureBlob private constructor( private val id: JsonField, private val accountName: JsonField, @@ -3136,7 +3129,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java @@ -3151,7 +3144,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** A builder for [AzureBlob]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3165,16 +3158,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(azureBlobStorage: AzureBlobStorage) = apply { - id = azureBlobStorage.id - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - name = azureBlobStorage.name - prefix = azureBlobStorage.prefix - type = azureBlobStorage.type - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + 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() } /** @@ -3303,7 +3296,7 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * Returns an immutable instance of [AzureBlob]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3319,8 +3312,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( checkRequired("id", id), checkRequired("accountName", accountName), checkRequired("container", container), @@ -3335,7 +3328,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } @@ -3385,7 +3378,7 @@ private constructor( return true } - return other is AzureBlobStorage && + return other is AzureBlob && id == other.id && accountName == other.accountName && container == other.container && @@ -3414,7 +3407,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "AzureBlob{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class AkeneoPim diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt index 96a15325..2abf66c0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt @@ -19,7 +19,6 @@ 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 @@ -271,9 +270,24 @@ private constructor( } /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = + 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()) @@ -366,13 +380,13 @@ private constructor( @JsonSerialize(using = UrlRewriter.Serializer::class) class UrlRewriter private constructor( - private val cloudinary: CloudinaryUrlRewriter? = null, + 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 cloudinary(): Optional = Optional.ofNullable(cloudinary) fun imgix(): Optional = Optional.ofNullable(imgix) @@ -384,7 +398,7 @@ private constructor( fun isAkamai(): Boolean = akamai != null - fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + fun asCloudinary(): Cloudinary = cloudinary.getOrThrow("cloudinary") fun asImgix(): JsonValue = imgix.getOrThrow("imgix") @@ -409,7 +423,7 @@ private constructor( accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) { + override fun visitCloudinary(cloudinary: Cloudinary) { cloudinary.validate() } @@ -455,8 +469,7 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = - cloudinary.validity() + 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 } @@ -493,8 +506,7 @@ private constructor( companion object { @JvmStatic - fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = - UrlRewriter(cloudinary = cloudinary) + fun ofCloudinary(cloudinary: Cloudinary) = UrlRewriter(cloudinary = cloudinary) @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) @@ -508,7 +520,7 @@ private constructor( */ interface Visitor { - fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + fun visitCloudinary(cloudinary: Cloudinary): T fun visitImgix(imgix: JsonValue): T @@ -533,32 +545,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): UrlRewriter { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { UrlRewriter(imgix = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { UrlRewriter(akamai = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(cloudinary = 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 -> UrlRewriter(_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) { + "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) } } @@ -579,7 +586,7 @@ private constructor( } } - class CloudinaryUrlRewriter + class Cloudinary private constructor( private val preserveAssetDeliveryTypes: JsonField, private val type: JsonValue, @@ -640,8 +647,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CloudinaryUrlRewriter]. + * Returns a mutable builder for constructing an instance of [Cloudinary]. * * The following fields are required: * ```java @@ -651,7 +657,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CloudinaryUrlRewriter]. */ + /** A builder for [Cloudinary]. */ class Builder internal constructor() { private var preserveAssetDeliveryTypes: JsonField? = null @@ -659,10 +665,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { - preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes - type = cloudinaryUrlRewriter.type - additionalProperties = cloudinaryUrlRewriter.additionalProperties.toMutableMap() + internal fun from(cloudinary: Cloudinary) = apply { + preserveAssetDeliveryTypes = cloudinary.preserveAssetDeliveryTypes + type = cloudinary.type + additionalProperties = cloudinary.additionalProperties.toMutableMap() } /** Whether to preserve `/` in the rewritten URL. */ @@ -718,7 +724,7 @@ private constructor( } /** - * Returns an immutable instance of [CloudinaryUrlRewriter]. + * Returns an immutable instance of [Cloudinary]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -729,8 +735,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CloudinaryUrlRewriter = - CloudinaryUrlRewriter( + fun build(): Cloudinary = + Cloudinary( checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), type, additionalProperties.toMutableMap(), @@ -739,7 +745,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CloudinaryUrlRewriter = apply { + fun validate(): Cloudinary = apply { if (validated) { return@apply } @@ -777,7 +783,7 @@ private constructor( return true } - return other is CloudinaryUrlRewriter && + return other is Cloudinary && preserveAssetDeliveryTypes == other.preserveAssetDeliveryTypes && type == other.type && additionalProperties == other.additionalProperties @@ -790,7 +796,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + "Cloudinary{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt index 9842c9d6..e595cbd3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt @@ -19,7 +19,6 @@ 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 @@ -271,9 +270,24 @@ private constructor( } /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = + 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()) @@ -366,13 +380,13 @@ private constructor( @JsonSerialize(using = UrlRewriter.Serializer::class) class UrlRewriter private constructor( - private val cloudinary: CloudinaryUrlRewriter? = null, + 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 cloudinary(): Optional = Optional.ofNullable(cloudinary) fun imgix(): Optional = Optional.ofNullable(imgix) @@ -384,7 +398,7 @@ private constructor( fun isAkamai(): Boolean = akamai != null - fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + fun asCloudinary(): Cloudinary = cloudinary.getOrThrow("cloudinary") fun asImgix(): JsonValue = imgix.getOrThrow("imgix") @@ -409,7 +423,7 @@ private constructor( accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) { + override fun visitCloudinary(cloudinary: Cloudinary) { cloudinary.validate() } @@ -455,8 +469,7 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = - cloudinary.validity() + 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 } @@ -493,8 +506,7 @@ private constructor( companion object { @JvmStatic - fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = - UrlRewriter(cloudinary = cloudinary) + fun ofCloudinary(cloudinary: Cloudinary) = UrlRewriter(cloudinary = cloudinary) @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) @@ -508,7 +520,7 @@ private constructor( */ interface Visitor { - fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + fun visitCloudinary(cloudinary: Cloudinary): T fun visitImgix(imgix: JsonValue): T @@ -533,32 +545,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): UrlRewriter { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { UrlRewriter(imgix = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { UrlRewriter(akamai = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(cloudinary = 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 -> UrlRewriter(_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) { + "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) } } @@ -579,7 +586,7 @@ private constructor( } } - class CloudinaryUrlRewriter + class Cloudinary private constructor( private val preserveAssetDeliveryTypes: JsonField, private val type: JsonValue, @@ -640,8 +647,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CloudinaryUrlRewriter]. + * Returns a mutable builder for constructing an instance of [Cloudinary]. * * The following fields are required: * ```java @@ -651,7 +657,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CloudinaryUrlRewriter]. */ + /** A builder for [Cloudinary]. */ class Builder internal constructor() { private var preserveAssetDeliveryTypes: JsonField? = null @@ -659,10 +665,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { - preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes - type = cloudinaryUrlRewriter.type - additionalProperties = cloudinaryUrlRewriter.additionalProperties.toMutableMap() + internal fun from(cloudinary: Cloudinary) = apply { + preserveAssetDeliveryTypes = cloudinary.preserveAssetDeliveryTypes + type = cloudinary.type + additionalProperties = cloudinary.additionalProperties.toMutableMap() } /** Whether to preserve `/` in the rewritten URL. */ @@ -718,7 +724,7 @@ private constructor( } /** - * Returns an immutable instance of [CloudinaryUrlRewriter]. + * Returns an immutable instance of [Cloudinary]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -729,8 +735,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CloudinaryUrlRewriter = - CloudinaryUrlRewriter( + fun build(): Cloudinary = + Cloudinary( checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), type, additionalProperties.toMutableMap(), @@ -739,7 +745,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CloudinaryUrlRewriter = apply { + fun validate(): Cloudinary = apply { if (validated) { return@apply } @@ -777,7 +783,7 @@ private constructor( return true } - return other is CloudinaryUrlRewriter && + return other is Cloudinary && preserveAssetDeliveryTypes == other.preserveAssetDeliveryTypes && type == other.type && additionalProperties == other.additionalProperties @@ -790,7 +796,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + "Cloudinary{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt index 5b27b56f..42d660f9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt @@ -19,7 +19,6 @@ 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 @@ -271,9 +270,24 @@ private constructor( } /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = + 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()) @@ -366,13 +380,13 @@ private constructor( @JsonSerialize(using = UrlRewriter.Serializer::class) class UrlRewriter private constructor( - private val cloudinary: CloudinaryUrlRewriter? = null, + 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 cloudinary(): Optional = Optional.ofNullable(cloudinary) fun imgix(): Optional = Optional.ofNullable(imgix) @@ -384,7 +398,7 @@ private constructor( fun isAkamai(): Boolean = akamai != null - fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + fun asCloudinary(): Cloudinary = cloudinary.getOrThrow("cloudinary") fun asImgix(): JsonValue = imgix.getOrThrow("imgix") @@ -409,7 +423,7 @@ private constructor( accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) { + override fun visitCloudinary(cloudinary: Cloudinary) { cloudinary.validate() } @@ -455,8 +469,7 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = - cloudinary.validity() + 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 } @@ -493,8 +506,7 @@ private constructor( companion object { @JvmStatic - fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = - UrlRewriter(cloudinary = cloudinary) + fun ofCloudinary(cloudinary: Cloudinary) = UrlRewriter(cloudinary = cloudinary) @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) @@ -508,7 +520,7 @@ private constructor( */ interface Visitor { - fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + fun visitCloudinary(cloudinary: Cloudinary): T fun visitImgix(imgix: JsonValue): T @@ -533,32 +545,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): UrlRewriter { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { UrlRewriter(imgix = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { UrlRewriter(akamai = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(cloudinary = 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 -> UrlRewriter(_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) { + "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) } } @@ -579,7 +586,7 @@ private constructor( } } - class CloudinaryUrlRewriter + class Cloudinary private constructor( private val preserveAssetDeliveryTypes: JsonField, private val type: JsonValue, @@ -640,8 +647,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CloudinaryUrlRewriter]. + * Returns a mutable builder for constructing an instance of [Cloudinary]. * * The following fields are required: * ```java @@ -651,7 +657,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CloudinaryUrlRewriter]. */ + /** A builder for [Cloudinary]. */ class Builder internal constructor() { private var preserveAssetDeliveryTypes: JsonField? = null @@ -659,10 +665,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { - preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes - type = cloudinaryUrlRewriter.type - additionalProperties = cloudinaryUrlRewriter.additionalProperties.toMutableMap() + internal fun from(cloudinary: Cloudinary) = apply { + preserveAssetDeliveryTypes = cloudinary.preserveAssetDeliveryTypes + type = cloudinary.type + additionalProperties = cloudinary.additionalProperties.toMutableMap() } /** Whether to preserve `/` in the rewritten URL. */ @@ -718,7 +724,7 @@ private constructor( } /** - * Returns an immutable instance of [CloudinaryUrlRewriter]. + * Returns an immutable instance of [Cloudinary]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -729,8 +735,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CloudinaryUrlRewriter = - CloudinaryUrlRewriter( + fun build(): Cloudinary = + Cloudinary( checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), type, additionalProperties.toMutableMap(), @@ -739,7 +745,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CloudinaryUrlRewriter = apply { + fun validate(): Cloudinary = apply { if (validated) { return@apply } @@ -777,7 +783,7 @@ private constructor( return true } - return other is CloudinaryUrlRewriter && + return other is Cloudinary && preserveAssetDeliveryTypes == other.preserveAssetDeliveryTypes && type == other.type && additionalProperties == other.additionalProperties @@ -790,7 +796,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + "Cloudinary{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt index 9d73ae46..0a01479c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt @@ -19,7 +19,6 @@ 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 @@ -271,9 +270,24 @@ private constructor( } /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.CloudinaryUrlRewriter) = + 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()) @@ -366,13 +380,13 @@ private constructor( @JsonSerialize(using = UrlRewriter.Serializer::class) class UrlRewriter private constructor( - private val cloudinary: CloudinaryUrlRewriter? = null, + 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 cloudinary(): Optional = Optional.ofNullable(cloudinary) fun imgix(): Optional = Optional.ofNullable(imgix) @@ -384,7 +398,7 @@ private constructor( fun isAkamai(): Boolean = akamai != null - fun asCloudinary(): CloudinaryUrlRewriter = cloudinary.getOrThrow("cloudinary") + fun asCloudinary(): Cloudinary = cloudinary.getOrThrow("cloudinary") fun asImgix(): JsonValue = imgix.getOrThrow("imgix") @@ -409,7 +423,7 @@ private constructor( accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) { + override fun visitCloudinary(cloudinary: Cloudinary) { cloudinary.validate() } @@ -455,8 +469,7 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitCloudinary(cloudinary: CloudinaryUrlRewriter) = - cloudinary.validity() + 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 } @@ -493,8 +506,7 @@ private constructor( companion object { @JvmStatic - fun ofCloudinary(cloudinary: CloudinaryUrlRewriter) = - UrlRewriter(cloudinary = cloudinary) + fun ofCloudinary(cloudinary: Cloudinary) = UrlRewriter(cloudinary = cloudinary) @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) @@ -508,7 +520,7 @@ private constructor( */ interface Visitor { - fun visitCloudinary(cloudinary: CloudinaryUrlRewriter): T + fun visitCloudinary(cloudinary: Cloudinary): T fun visitImgix(imgix: JsonValue): T @@ -533,32 +545,27 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): UrlRewriter { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { UrlRewriter(imgix = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { UrlRewriter(akamai = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef())?.let { - UrlRewriter(cloudinary = 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 -> UrlRewriter(_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) { + "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) } } @@ -579,7 +586,7 @@ private constructor( } } - class CloudinaryUrlRewriter + class Cloudinary private constructor( private val preserveAssetDeliveryTypes: JsonField, private val type: JsonValue, @@ -640,8 +647,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CloudinaryUrlRewriter]. + * Returns a mutable builder for constructing an instance of [Cloudinary]. * * The following fields are required: * ```java @@ -651,7 +657,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CloudinaryUrlRewriter]. */ + /** A builder for [Cloudinary]. */ class Builder internal constructor() { private var preserveAssetDeliveryTypes: JsonField? = null @@ -659,10 +665,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cloudinaryUrlRewriter: CloudinaryUrlRewriter) = apply { - preserveAssetDeliveryTypes = cloudinaryUrlRewriter.preserveAssetDeliveryTypes - type = cloudinaryUrlRewriter.type - additionalProperties = cloudinaryUrlRewriter.additionalProperties.toMutableMap() + internal fun from(cloudinary: Cloudinary) = apply { + preserveAssetDeliveryTypes = cloudinary.preserveAssetDeliveryTypes + type = cloudinary.type + additionalProperties = cloudinary.additionalProperties.toMutableMap() } /** Whether to preserve `/` in the rewritten URL. */ @@ -718,7 +724,7 @@ private constructor( } /** - * Returns an immutable instance of [CloudinaryUrlRewriter]. + * Returns an immutable instance of [Cloudinary]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -729,8 +735,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CloudinaryUrlRewriter = - CloudinaryUrlRewriter( + fun build(): Cloudinary = + Cloudinary( checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), type, additionalProperties.toMutableMap(), @@ -739,7 +745,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CloudinaryUrlRewriter = apply { + fun validate(): Cloudinary = apply { if (validated) { return@apply } @@ -777,7 +783,7 @@ private constructor( return true } - return other is CloudinaryUrlRewriter && + return other is Cloudinary && preserveAssetDeliveryTypes == other.preserveAssetDeliveryTypes && type == other.type && additionalProperties == other.additionalProperties @@ -790,7 +796,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryUrlRewriter{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + "Cloudinary{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt index db4c0d29..be5a3722 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt @@ -33,8 +33,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -83,8 +83,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -133,8 +133,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -181,8 +181,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).contains(webFolder) assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -227,8 +227,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).contains(webProxy) - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -255,9 +255,9 @@ internal class OriginCreateResponseTest { } @Test - fun ofGoogleCloudStorageGcs() { - val googleCloudStorageGcs = - OriginCreateResponse.GoogleCloudStorageGcs.builder() + fun ofGcs() { + val gcs = + OriginCreateResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -267,25 +267,24 @@ internal class OriginCreateResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originCreateResponse = - OriginCreateResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + val originCreateResponse = OriginCreateResponse.ofGcs(gcs) assertThat(originCreateResponse.s3()).isEmpty assertThat(originCreateResponse.s3Compatible()).isEmpty assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).contains(gcs) + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @Test - fun ofGoogleCloudStorageGcsRoundtrip() { + fun ofGcsRoundtrip() { val jsonMapper = jsonMapper() val originCreateResponse = - OriginCreateResponse.ofGoogleCloudStorageGcs( - OriginCreateResponse.GoogleCloudStorageGcs.builder() + OriginCreateResponse.ofGcs( + OriginCreateResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -306,9 +305,9 @@ internal class OriginCreateResponseTest { } @Test - fun ofAzureBlobStorage() { - val azureBlobStorage = - OriginCreateResponse.AzureBlobStorage.builder() + fun ofAzureBlob() { + val azureBlob = + OriginCreateResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -318,24 +317,24 @@ internal class OriginCreateResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originCreateResponse = OriginCreateResponse.ofAzureBlobStorage(azureBlobStorage) + val originCreateResponse = OriginCreateResponse.ofAzureBlob(azureBlob) assertThat(originCreateResponse.s3()).isEmpty assertThat(originCreateResponse.s3Compatible()).isEmpty assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).contains(azureBlob) assertThat(originCreateResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobStorageRoundtrip() { + fun ofAzureBlobRoundtrip() { val jsonMapper = jsonMapper() val originCreateResponse = - OriginCreateResponse.ofAzureBlobStorage( - OriginCreateResponse.AzureBlobStorage.builder() + OriginCreateResponse.ofAzureBlob( + OriginCreateResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -373,8 +372,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).contains(akeneoPim) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt index d276b8de..81a0e62f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt @@ -33,8 +33,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -83,8 +83,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -133,8 +133,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -181,8 +181,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).contains(webFolder) assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -227,8 +227,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).contains(webProxy) - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -255,9 +255,9 @@ internal class OriginGetResponseTest { } @Test - fun ofGoogleCloudStorageGcs() { - val googleCloudStorageGcs = - OriginGetResponse.GoogleCloudStorageGcs.builder() + fun ofGcs() { + val gcs = + OriginGetResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -267,24 +267,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + val originGetResponse = OriginGetResponse.ofGcs(gcs) assertThat(originGetResponse.s3()).isEmpty assertThat(originGetResponse.s3Compatible()).isEmpty assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).contains(gcs) + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @Test - fun ofGoogleCloudStorageGcsRoundtrip() { + fun ofGcsRoundtrip() { val jsonMapper = jsonMapper() val originGetResponse = - OriginGetResponse.ofGoogleCloudStorageGcs( - OriginGetResponse.GoogleCloudStorageGcs.builder() + OriginGetResponse.ofGcs( + OriginGetResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -305,9 +305,9 @@ internal class OriginGetResponseTest { } @Test - fun ofAzureBlobStorage() { - val azureBlobStorage = - OriginGetResponse.AzureBlobStorage.builder() + fun ofAzureBlob() { + val azureBlob = + OriginGetResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -317,24 +317,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofAzureBlobStorage(azureBlobStorage) + val originGetResponse = OriginGetResponse.ofAzureBlob(azureBlob) assertThat(originGetResponse.s3()).isEmpty assertThat(originGetResponse.s3Compatible()).isEmpty assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).contains(azureBlob) assertThat(originGetResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobStorageRoundtrip() { + fun ofAzureBlobRoundtrip() { val jsonMapper = jsonMapper() val originGetResponse = - OriginGetResponse.ofAzureBlobStorage( - OriginGetResponse.AzureBlobStorage.builder() + OriginGetResponse.ofAzureBlob( + OriginGetResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -372,8 +372,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).contains(akeneoPim) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt index 351f3b6c..5a5b4506 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt @@ -33,8 +33,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -83,8 +83,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -133,8 +133,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -181,8 +181,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).contains(webFolder) assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -227,8 +227,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).contains(webProxy) - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -255,9 +255,9 @@ internal class OriginListResponseTest { } @Test - fun ofGoogleCloudStorageGcs() { - val googleCloudStorageGcs = - OriginListResponse.GoogleCloudStorageGcs.builder() + fun ofGcs() { + val gcs = + OriginListResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -267,24 +267,24 @@ internal class OriginListResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originListResponse = OriginListResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + val originListResponse = OriginListResponse.ofGcs(gcs) assertThat(originListResponse.s3()).isEmpty assertThat(originListResponse.s3Compatible()).isEmpty assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).contains(gcs) + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @Test - fun ofGoogleCloudStorageGcsRoundtrip() { + fun ofGcsRoundtrip() { val jsonMapper = jsonMapper() val originListResponse = - OriginListResponse.ofGoogleCloudStorageGcs( - OriginListResponse.GoogleCloudStorageGcs.builder() + OriginListResponse.ofGcs( + OriginListResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -305,9 +305,9 @@ internal class OriginListResponseTest { } @Test - fun ofAzureBlobStorage() { - val azureBlobStorage = - OriginListResponse.AzureBlobStorage.builder() + fun ofAzureBlob() { + val azureBlob = + OriginListResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -317,24 +317,24 @@ internal class OriginListResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originListResponse = OriginListResponse.ofAzureBlobStorage(azureBlobStorage) + val originListResponse = OriginListResponse.ofAzureBlob(azureBlob) assertThat(originListResponse.s3()).isEmpty assertThat(originListResponse.s3Compatible()).isEmpty assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).contains(azureBlob) assertThat(originListResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobStorageRoundtrip() { + fun ofAzureBlobRoundtrip() { val jsonMapper = jsonMapper() val originListResponse = - OriginListResponse.ofAzureBlobStorage( - OriginListResponse.AzureBlobStorage.builder() + OriginListResponse.ofAzureBlob( + OriginListResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -372,8 +372,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).contains(akeneoPim) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt index ab884763..c569a06f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt @@ -33,8 +33,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -83,8 +83,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -133,8 +133,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -181,8 +181,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).contains(webFolder) assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -227,8 +227,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).contains(webProxy) - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -255,9 +255,9 @@ internal class OriginUpdateResponseTest { } @Test - fun ofGoogleCloudStorageGcs() { - val googleCloudStorageGcs = - OriginUpdateResponse.GoogleCloudStorageGcs.builder() + fun ofGcs() { + val gcs = + OriginUpdateResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -267,25 +267,24 @@ internal class OriginUpdateResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originUpdateResponse = - OriginUpdateResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + val originUpdateResponse = OriginUpdateResponse.ofGcs(gcs) assertThat(originUpdateResponse.s3()).isEmpty assertThat(originUpdateResponse.s3Compatible()).isEmpty assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).contains(gcs) + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @Test - fun ofGoogleCloudStorageGcsRoundtrip() { + fun ofGcsRoundtrip() { val jsonMapper = jsonMapper() val originUpdateResponse = - OriginUpdateResponse.ofGoogleCloudStorageGcs( - OriginUpdateResponse.GoogleCloudStorageGcs.builder() + OriginUpdateResponse.ofGcs( + OriginUpdateResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -306,9 +305,9 @@ internal class OriginUpdateResponseTest { } @Test - fun ofAzureBlobStorage() { - val azureBlobStorage = - OriginUpdateResponse.AzureBlobStorage.builder() + fun ofAzureBlob() { + val azureBlob = + OriginUpdateResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -318,24 +317,24 @@ internal class OriginUpdateResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originUpdateResponse = OriginUpdateResponse.ofAzureBlobStorage(azureBlobStorage) + val originUpdateResponse = OriginUpdateResponse.ofAzureBlob(azureBlob) assertThat(originUpdateResponse.s3()).isEmpty assertThat(originUpdateResponse.s3Compatible()).isEmpty assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).contains(azureBlob) assertThat(originUpdateResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobStorageRoundtrip() { + fun ofAzureBlobRoundtrip() { val jsonMapper = jsonMapper() val originUpdateResponse = - OriginUpdateResponse.ofAzureBlobStorage( - OriginUpdateResponse.AzureBlobStorage.builder() + OriginUpdateResponse.ofAzureBlob( + OriginUpdateResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -373,8 +372,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).contains(akeneoPim) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt index 5f18e0c3..cfdc7b73 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt @@ -18,11 +18,7 @@ internal class UrlEndpointCreateResponseTest { .addOrigin("origin-id-1") .addOrigin("origin-id-2") .urlPrefix("product-images") - .urlRewriter( - UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + .cloudinaryUrlRewriter(true) .build() assertThat(urlEndpointCreateResponse.id()).isEqualTo("id") @@ -33,7 +29,7 @@ internal class UrlEndpointCreateResponseTest { assertThat(urlEndpointCreateResponse.urlRewriter()) .contains( UrlEndpointCreateResponse.UrlRewriter.ofCloudinary( - UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + UrlEndpointCreateResponse.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -50,11 +46,7 @@ internal class UrlEndpointCreateResponseTest { .addOrigin("origin-id-1") .addOrigin("origin-id-2") .urlPrefix("product-images") - .urlRewriter( - UrlEndpointCreateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + .cloudinaryUrlRewriter(true) .build() val roundtrippedUrlEndpointCreateResponse = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt index f6254249..8a4924cd 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt @@ -18,11 +18,7 @@ internal class UrlEndpointGetResponseTest { .addOrigin("origin-id-1") .addOrigin("origin-id-2") .urlPrefix("product-images") - .urlRewriter( - UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + .cloudinaryUrlRewriter(true) .build() assertThat(urlEndpointGetResponse.id()).isEqualTo("id") @@ -32,7 +28,7 @@ internal class UrlEndpointGetResponseTest { assertThat(urlEndpointGetResponse.urlRewriter()) .contains( UrlEndpointGetResponse.UrlRewriter.ofCloudinary( - UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + UrlEndpointGetResponse.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -49,11 +45,7 @@ internal class UrlEndpointGetResponseTest { .addOrigin("origin-id-1") .addOrigin("origin-id-2") .urlPrefix("product-images") - .urlRewriter( - UrlEndpointGetResponse.UrlRewriter.CloudinaryUrlRewriter.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + .cloudinaryUrlRewriter(true) .build() val roundtrippedUrlEndpointGetResponse = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt index b21fa619..ea471e4a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt @@ -18,11 +18,7 @@ internal class UrlEndpointListResponseTest { .addOrigin("origin-id-1") .addOrigin("origin-id-2") .urlPrefix("product-images") - .urlRewriter( - UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + .cloudinaryUrlRewriter(true) .build() assertThat(urlEndpointListResponse.id()).isEqualTo("id") @@ -32,7 +28,7 @@ internal class UrlEndpointListResponseTest { assertThat(urlEndpointListResponse.urlRewriter()) .contains( UrlEndpointListResponse.UrlRewriter.ofCloudinary( - UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + UrlEndpointListResponse.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -49,11 +45,7 @@ internal class UrlEndpointListResponseTest { .addOrigin("origin-id-1") .addOrigin("origin-id-2") .urlPrefix("product-images") - .urlRewriter( - UrlEndpointListResponse.UrlRewriter.CloudinaryUrlRewriter.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + .cloudinaryUrlRewriter(true) .build() val roundtrippedUrlEndpointListResponse = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt index e5552227..ea15aa1d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt @@ -18,11 +18,7 @@ internal class UrlEndpointUpdateResponseTest { .addOrigin("origin-id-1") .addOrigin("origin-id-2") .urlPrefix("product-images") - .urlRewriter( - UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + .cloudinaryUrlRewriter(true) .build() assertThat(urlEndpointUpdateResponse.id()).isEqualTo("id") @@ -33,7 +29,7 @@ internal class UrlEndpointUpdateResponseTest { assertThat(urlEndpointUpdateResponse.urlRewriter()) .contains( UrlEndpointUpdateResponse.UrlRewriter.ofCloudinary( - UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() + UrlEndpointUpdateResponse.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -50,11 +46,7 @@ internal class UrlEndpointUpdateResponseTest { .addOrigin("origin-id-1") .addOrigin("origin-id-2") .urlPrefix("product-images") - .urlRewriter( - UrlEndpointUpdateResponse.UrlRewriter.CloudinaryUrlRewriter.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + .cloudinaryUrlRewriter(true) .build() val roundtrippedUrlEndpointUpdateResponse = From c76de5367425c581bbe5df9aa636ea7edb51f10e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 13:49:59 +0000 Subject: [PATCH 039/125] codegen metadata --- .stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 61a94110..878cd0fc 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-4bc3e70493ee36b6dd29a92334f55232a5429d1bf03139d1f072f854c3ba5a6e.yml -openapi_spec_hash: 9b8384f2a421b73c3f03d1ca84c26113 -config_hash: c434cea5e670c34d574784866661bebd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-5e37410c61128e976acdb1c3a0df26552e969187d32f4af52555eeb9685d6bc2.yml +openapi_spec_hash: b3d4d81f84221c6bc87065590a907004 +config_hash: 040d180c4960ee032ba08946d86c8764 From 2f96313f1dffdb1ded6efbb73063f63b34bec3d3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Aug 2025 13:52:28 +0000 Subject: [PATCH 040/125] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 878cd0fc..27d4d89c 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-5e37410c61128e976acdb1c3a0df26552e969187d32f4af52555eeb9685d6bc2.yml -openapi_spec_hash: b3d4d81f84221c6bc87065590a907004 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-4bc3e70493ee36b6dd29a92334f55232a5429d1bf03139d1f072f854c3ba5a6e.yml +openapi_spec_hash: 9b8384f2a421b73c3f03d1ca84c26113 config_hash: 040d180c4960ee032ba08946d86c8764 From 1de1f71dd48ce0b5f3a00c2343a44d2b4b516fa4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 03:03:27 +0000 Subject: [PATCH 041/125] feat(api): manual updates --- .stats.yml | 4 +- .../api/models/assets/AssetListResponse.kt | 332 ++++++++++++------ .../api/models/files/FileGetResponse.kt | 198 +++++++++-- .../api/models/files/FileUpdateResponse.kt | 197 +++++++++-- .../files/versions/VersionGetResponse.kt | 198 +++++++++-- .../files/versions/VersionListResponse.kt | 198 +++++++++-- .../files/versions/VersionRestoreResponse.kt | 198 +++++++++-- .../models/assets/AssetListResponseTest.kt | 51 +-- .../api/models/files/FileGetResponseTest.kt | 33 +- .../models/files/FileUpdateResponseTest.kt | 33 +- .../files/versions/VersionGetResponseTest.kt | 33 +- .../files/versions/VersionListResponseTest.kt | 33 +- .../versions/VersionRestoreResponseTest.kt | 21 +- .../api/proguard/ProGuardCompatibilityTest.kt | 21 +- 14 files changed, 1193 insertions(+), 357 deletions(-) diff --git a/.stats.yml b/.stats.yml index 27d4d89c..9ac0471d 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-4bc3e70493ee36b6dd29a92334f55232a5429d1bf03139d1f072f854c3ba5a6e.yml -openapi_spec_hash: 9b8384f2a421b73c3f03d1ca84c26113 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml +openapi_spec_hash: 98642308bee81ac776b7b1843089b888 config_hash: 040d180c4960ee032ba08946d86c8764 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 index 64fb5acf..6835c6e7 100644 --- 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 @@ -20,11 +20,11 @@ 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.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -36,30 +36,30 @@ import kotlin.jvm.optionals.getOrNull class AssetListResponse private constructor( private val fileDetails: FileDetails? = null, - private val folderDetails: FolderDetails? = null, + private val folder: Folder? = null, private val _json: JsonValue? = null, ) { /** Object containing details of a file or file version. */ fun fileDetails(): Optional = Optional.ofNullable(fileDetails) - fun folderDetails(): Optional = Optional.ofNullable(folderDetails) + fun folder(): Optional = Optional.ofNullable(folder) fun isFileDetails(): Boolean = fileDetails != null - fun isFolderDetails(): Boolean = folderDetails != null + fun isFolder(): Boolean = folder != null /** Object containing details of a file or file version. */ fun asFileDetails(): FileDetails = fileDetails.getOrThrow("fileDetails") - fun asFolderDetails(): FolderDetails = folderDetails.getOrThrow("folderDetails") + fun asFolder(): Folder = folder.getOrThrow("folder") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { fileDetails != null -> visitor.visitFileDetails(fileDetails) - folderDetails != null -> visitor.visitFolderDetails(folderDetails) + folder != null -> visitor.visitFolder(folder) else -> visitor.unknown(_json) } @@ -76,8 +76,8 @@ private constructor( fileDetails.validate() } - override fun visitFolderDetails(folderDetails: FolderDetails) { - folderDetails.validate() + override fun visitFolder(folder: Folder) { + folder.validate() } } ) @@ -103,8 +103,7 @@ private constructor( object : Visitor { override fun visitFileDetails(fileDetails: FileDetails) = fileDetails.validity() - override fun visitFolderDetails(folderDetails: FolderDetails) = - folderDetails.validity() + override fun visitFolder(folder: Folder) = folder.validity() override fun unknown(json: JsonValue?) = 0 } @@ -117,15 +116,15 @@ private constructor( return other is AssetListResponse && fileDetails == other.fileDetails && - folderDetails == other.folderDetails + folder == other.folder } - override fun hashCode(): Int = Objects.hash(fileDetails, folderDetails) + override fun hashCode(): Int = Objects.hash(fileDetails, folder) override fun toString(): String = when { fileDetails != null -> "AssetListResponse{fileDetails=$fileDetails}" - folderDetails != null -> "AssetListResponse{folderDetails=$folderDetails}" + folder != null -> "AssetListResponse{folder=$folder}" _json != null -> "AssetListResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid AssetListResponse") } @@ -136,9 +135,7 @@ private constructor( @JvmStatic fun ofFileDetails(fileDetails: FileDetails) = AssetListResponse(fileDetails = fileDetails) - @JvmStatic - fun ofFolderDetails(folderDetails: FolderDetails) = - AssetListResponse(folderDetails = folderDetails) + @JvmStatic fun ofFolder(folder: Folder) = AssetListResponse(folder = folder) } /** @@ -150,7 +147,7 @@ private constructor( /** Object containing details of a file or file version. */ fun visitFileDetails(fileDetails: FileDetails): T - fun visitFolderDetails(folderDetails: FolderDetails): T + fun visitFolder(folder: Folder): T /** * Maps an unknown variant of [AssetListResponse] to a value of type [T]. @@ -171,28 +168,17 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): AssetListResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - AssetListResponse(fileDetails = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - AssetListResponse(folderDetails = 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 -> AssetListResponse(_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 (type == "folder") { + return tryDeserialize(node, jacksonTypeRef())?.let { + AssetListResponse(folder = it, _json = json) + } ?: AssetListResponse(_json = json) } + + return tryDeserialize(node, jacksonTypeRef())?.let { + AssetListResponse(fileDetails = it, _json = json) + } ?: AssetListResponse(_json = json) } } @@ -205,7 +191,7 @@ private constructor( ) { when { value.fileDetails != null -> generator.writeObject(value.fileDetails) - value.folderDetails != null -> generator.writeObject(value.folderDetails) + value.folder != null -> generator.writeObject(value.folder) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid AssetListResponse") } @@ -216,7 +202,7 @@ private constructor( class FileDetails private constructor( private val aiTags: JsonField>, - private val createdAt: JsonField, + private val createdAt: JsonField, private val customCoordinates: JsonField, private val customMetadata: JsonField, private val fileId: JsonField, @@ -231,8 +217,8 @@ private constructor( private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, - private val type: JsonField, - private val updatedAt: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, private val url: JsonField, private val versionInfo: JsonField, private val width: JsonField, @@ -246,7 +232,7 @@ private constructor( aiTags: JsonField> = JsonMissing.of(), @JsonProperty("createdAt") @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), + createdAt: JsonField = JsonMissing.of(), @JsonProperty("customCoordinates") @ExcludeMissing customCoordinates: JsonField = JsonMissing.of(), @@ -277,10 +263,10 @@ private constructor( @JsonProperty("thumbnail") @ExcludeMissing thumbnail: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("updatedAt") @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), + updatedAt: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), @JsonProperty("versionInfo") @ExcludeMissing @@ -325,7 +311,7 @@ private constructor( * @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") + fun createdAt(): Optional = createdAt.getOptional("createdAt") /** * An string with custom coordinates of the file. @@ -451,7 +437,7 @@ private constructor( * @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") + fun type(): Optional = type.getOptional("type") /** * Date and time when the file was last updated. The date and time is in ISO8601 format. @@ -459,7 +445,7 @@ private constructor( * @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") + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") /** * URL of the file. @@ -497,7 +483,9 @@ private constructor( * * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + @JsonProperty("createdAt") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * Returns the raw JSON value of [customCoordinates]. @@ -613,14 +601,16 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = 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 + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt /** * Returns the raw JSON value of [url]. @@ -667,7 +657,7 @@ private constructor( class Builder internal constructor() { private var aiTags: JsonField>? = null - private var createdAt: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() @@ -682,8 +672,8 @@ private constructor( 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 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() @@ -745,16 +735,18 @@ private constructor( } /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * 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 createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } /** An string with custom coordinates of the file. */ fun customCoordinates(customCoordinates: String?) = @@ -967,30 +959,32 @@ private constructor( fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } /** Type of the asset. */ - fun type(type: String) = type(JsonField.of(type)) + 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 [String] value instead. This + * 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 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: String) = updatedAt(JsonField.of(updatedAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * 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 updatedAt(updatedAt: JsonField) = apply { + this.updatedAt = updatedAt + } /** URL of the file. */ fun url(url: String) = url(JsonField.of(url)) @@ -1104,7 +1098,7 @@ private constructor( size() tags() thumbnail() - type() + type().ifPresent { it.validate() } updatedAt() url() versionInfo().ifPresent { it.validate() } @@ -1144,7 +1138,7 @@ private constructor( (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnail.asKnown().isPresent) 1 else 0) + - (if (type.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) + @@ -1479,6 +1473,134 @@ private constructor( 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( @@ -1722,14 +1844,14 @@ private constructor( "FileDetails{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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}" } - class FolderDetails + class Folder private constructor( - private val createdAt: JsonField, + 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 updatedAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -1737,7 +1859,7 @@ private constructor( private constructor( @JsonProperty("createdAt") @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), + createdAt: JsonField = JsonMissing.of(), @JsonProperty("folderId") @ExcludeMissing folderId: JsonField = JsonMissing.of(), @@ -1748,7 +1870,7 @@ private constructor( @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("updatedAt") @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), + updatedAt: JsonField = JsonMissing.of(), ) : this(createdAt, folderId, folderPath, name, type, updatedAt, mutableMapOf()) /** @@ -1757,7 +1879,7 @@ private constructor( * @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") + fun createdAt(): Optional = createdAt.getOptional("createdAt") /** * Unique identifier of the asset. @@ -1799,14 +1921,16 @@ private constructor( * @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") + 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 + @JsonProperty("createdAt") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * Returns the raw JSON value of [folderId]. @@ -1843,7 +1967,9 @@ private constructor( * * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("updatedAt") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1859,45 +1985,47 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [FolderDetails]. */ + /** Returns a mutable builder for constructing an instance of [Folder]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [FolderDetails]. */ + /** A builder for [Folder]. */ class Builder internal constructor() { - private var createdAt: JsonField = JsonMissing.of() + 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 updatedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(folderDetails: FolderDetails) = apply { - createdAt = folderDetails.createdAt - folderId = folderDetails.folderId - folderPath = folderDetails.folderPath - name = folderDetails.name - type = folderDetails.type - updatedAt = folderDetails.updatedAt - additionalProperties = folderDetails.additionalProperties.toMutableMap() + 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: String) = createdAt(JsonField.of(createdAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * 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 createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } /** Unique identifier of the asset. */ fun folderId(folderId: String) = folderId(JsonField.of(folderId)) @@ -1956,16 +2084,18 @@ private constructor( * Date and time when the folder was last updated. The date and time is in ISO8601 * format. */ - fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * 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 updatedAt(updatedAt: JsonField) = apply { + this.updatedAt = updatedAt + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1987,12 +2117,12 @@ private constructor( } /** - * Returns an immutable instance of [FolderDetails]. + * Returns an immutable instance of [Folder]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): FolderDetails = - FolderDetails( + fun build(): Folder = + Folder( createdAt, folderId, folderPath, @@ -2005,7 +2135,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FolderDetails = apply { + fun validate(): Folder = apply { if (validated) { return@apply } @@ -2169,7 +2299,7 @@ private constructor( return true } - return other is FolderDetails && + return other is Folder && createdAt == other.createdAt && folderId == other.folderId && folderPath == other.folderPath && @@ -2194,6 +2324,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FolderDetails{createdAt=$createdAt, folderId=$folderId, folderPath=$folderPath, name=$name, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "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/FileGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt index 55ef2d30..76170cdb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.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 @@ -13,6 +14,7 @@ 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 @@ -22,7 +24,7 @@ import kotlin.jvm.optionals.getOrNull class FileGetResponse private constructor( private val aiTags: JsonField>, - private val createdAt: JsonField, + private val createdAt: JsonField, private val customCoordinates: JsonField, private val customMetadata: JsonField, private val fileId: JsonField, @@ -37,8 +39,8 @@ private constructor( private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, - private val type: JsonField, - private val updatedAt: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, private val url: JsonField, private val versionInfo: JsonField, private val width: JsonField, @@ -48,7 +50,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), - @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), @JsonProperty("customCoordinates") @ExcludeMissing customCoordinates: JsonField = JsonMissing.of(), @@ -71,8 +75,10 @@ private constructor( @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("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), @JsonProperty("versionInfo") @ExcludeMissing @@ -117,7 +123,7 @@ private constructor( * @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") + fun createdAt(): Optional = createdAt.getOptional("createdAt") /** * An string with custom coordinates of the file. @@ -240,7 +246,7 @@ private constructor( * @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") + fun type(): Optional = type.getOptional("type") /** * Date and time when the file was last updated. The date and time is in ISO8601 format. @@ -248,7 +254,7 @@ private constructor( * @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") + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") /** * URL of the file. @@ -286,7 +292,9 @@ private constructor( * * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + @JsonProperty("createdAt") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * Returns the raw JSON value of [customCoordinates]. @@ -400,14 +408,16 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = 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 + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt /** * Returns the raw JSON value of [url]. @@ -454,7 +464,7 @@ private constructor( class Builder internal constructor() { private var aiTags: JsonField>? = null - private var createdAt: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() @@ -469,8 +479,8 @@ private constructor( 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 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() @@ -532,16 +542,16 @@ private constructor( } /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } /** An string with custom coordinates of the file. */ fun customCoordinates(customCoordinates: String?) = @@ -741,27 +751,27 @@ private constructor( fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } /** Type of the asset. */ - fun type(type: String) = type(JsonField.of(type)) + 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 [String] value instead. This + * 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 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: String) = updatedAt(JsonField.of(updatedAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } /** URL of the file. */ fun url(url: String) = url(JsonField.of(url)) @@ -873,7 +883,7 @@ private constructor( size() tags() thumbnail() - type() + type().ifPresent { it.validate() } updatedAt() url() versionInfo().ifPresent { it.validate() } @@ -912,7 +922,7 @@ private constructor( (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnail.asKnown().isPresent) 1 else 0) + - (if (type.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) + @@ -1237,6 +1247,134 @@ private constructor( 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( 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 cbe3e5df..57b85ea4 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,7 @@ 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 @@ -22,7 +23,7 @@ import kotlin.jvm.optionals.getOrNull class FileUpdateResponse private constructor( private val aiTags: JsonField>, - private val createdAt: JsonField, + private val createdAt: JsonField, private val customCoordinates: JsonField, private val customMetadata: JsonField, private val extensionStatus: JsonField, @@ -38,8 +39,8 @@ private constructor( private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, - private val type: JsonField, - private val updatedAt: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, private val url: JsonField, private val versionInfo: JsonField, private val width: JsonField, @@ -49,7 +50,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), - @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), @JsonProperty("customCoordinates") @ExcludeMissing customCoordinates: JsonField = JsonMissing.of(), @@ -75,8 +78,10 @@ private constructor( @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("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), @JsonProperty("versionInfo") @ExcludeMissing @@ -122,7 +127,7 @@ private constructor( * @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") + fun createdAt(): Optional = createdAt.getOptional("createdAt") /** * An string with custom coordinates of the file. @@ -252,7 +257,7 @@ private constructor( * @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") + fun type(): Optional = type.getOptional("type") /** * Date and time when the file was last updated. The date and time is in ISO8601 format. @@ -260,7 +265,7 @@ private constructor( * @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") + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") /** * URL of the file. @@ -298,7 +303,9 @@ private constructor( * * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + @JsonProperty("createdAt") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * Returns the raw JSON value of [customCoordinates]. @@ -421,14 +428,16 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = 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 + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt /** * Returns the raw JSON value of [url]. @@ -475,7 +484,7 @@ private constructor( class Builder internal constructor() { private var aiTags: JsonField>? = null - private var createdAt: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var extensionStatus: JsonField = JsonMissing.of() @@ -491,8 +500,8 @@ private constructor( 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 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() @@ -555,16 +564,16 @@ private constructor( } /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } /** An string with custom coordinates of the file. */ fun customCoordinates(customCoordinates: String?) = @@ -778,27 +787,27 @@ private constructor( fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } /** Type of the asset. */ - fun type(type: String) = type(JsonField.of(type)) + 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 [String] value instead. This + * 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 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: String) = updatedAt(JsonField.of(updatedAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } /** URL of the file. */ fun url(url: String) = url(JsonField.of(url)) @@ -912,7 +921,7 @@ private constructor( size() tags() thumbnail() - type() + type().ifPresent { it.validate() } updatedAt() url() versionInfo().ifPresent { it.validate() } @@ -952,7 +961,7 @@ private constructor( (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnail.asKnown().isPresent) 1 else 0) + - (if (type.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) + @@ -2105,6 +2114,134 @@ private constructor( "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, 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( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt index 324fdcc4..0f87292d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.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 @@ -13,6 +14,7 @@ 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 @@ -22,7 +24,7 @@ import kotlin.jvm.optionals.getOrNull class VersionGetResponse private constructor( private val aiTags: JsonField>, - private val createdAt: JsonField, + private val createdAt: JsonField, private val customCoordinates: JsonField, private val customMetadata: JsonField, private val fileId: JsonField, @@ -37,8 +39,8 @@ private constructor( private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, - private val type: JsonField, - private val updatedAt: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, private val url: JsonField, private val versionInfo: JsonField, private val width: JsonField, @@ -48,7 +50,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), - @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), @JsonProperty("customCoordinates") @ExcludeMissing customCoordinates: JsonField = JsonMissing.of(), @@ -71,8 +75,10 @@ private constructor( @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("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), @JsonProperty("versionInfo") @ExcludeMissing @@ -117,7 +123,7 @@ private constructor( * @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") + fun createdAt(): Optional = createdAt.getOptional("createdAt") /** * An string with custom coordinates of the file. @@ -240,7 +246,7 @@ private constructor( * @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") + fun type(): Optional = type.getOptional("type") /** * Date and time when the file was last updated. The date and time is in ISO8601 format. @@ -248,7 +254,7 @@ private constructor( * @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") + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") /** * URL of the file. @@ -286,7 +292,9 @@ private constructor( * * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + @JsonProperty("createdAt") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * Returns the raw JSON value of [customCoordinates]. @@ -400,14 +408,16 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = 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 + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt /** * Returns the raw JSON value of [url]. @@ -454,7 +464,7 @@ private constructor( class Builder internal constructor() { private var aiTags: JsonField>? = null - private var createdAt: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() @@ -469,8 +479,8 @@ private constructor( 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 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() @@ -532,16 +542,16 @@ private constructor( } /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } /** An string with custom coordinates of the file. */ fun customCoordinates(customCoordinates: String?) = @@ -741,27 +751,27 @@ private constructor( fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } /** Type of the asset. */ - fun type(type: String) = type(JsonField.of(type)) + 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 [String] value instead. This + * 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 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: String) = updatedAt(JsonField.of(updatedAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } /** URL of the file. */ fun url(url: String) = url(JsonField.of(url)) @@ -873,7 +883,7 @@ private constructor( size() tags() thumbnail() - type() + type().ifPresent { it.validate() } updatedAt() url() versionInfo().ifPresent { it.validate() } @@ -912,7 +922,7 @@ private constructor( (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnail.asKnown().isPresent) 1 else 0) + - (if (type.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) + @@ -1237,6 +1247,134 @@ private constructor( 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( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt index 843cb6e7..30f29846 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.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 @@ -13,6 +14,7 @@ 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 @@ -22,7 +24,7 @@ import kotlin.jvm.optionals.getOrNull class VersionListResponse private constructor( private val aiTags: JsonField>, - private val createdAt: JsonField, + private val createdAt: JsonField, private val customCoordinates: JsonField, private val customMetadata: JsonField, private val fileId: JsonField, @@ -37,8 +39,8 @@ private constructor( private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, - private val type: JsonField, - private val updatedAt: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, private val url: JsonField, private val versionInfo: JsonField, private val width: JsonField, @@ -48,7 +50,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), - @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), @JsonProperty("customCoordinates") @ExcludeMissing customCoordinates: JsonField = JsonMissing.of(), @@ -71,8 +75,10 @@ private constructor( @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("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), @JsonProperty("versionInfo") @ExcludeMissing @@ -117,7 +123,7 @@ private constructor( * @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") + fun createdAt(): Optional = createdAt.getOptional("createdAt") /** * An string with custom coordinates of the file. @@ -240,7 +246,7 @@ private constructor( * @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") + fun type(): Optional = type.getOptional("type") /** * Date and time when the file was last updated. The date and time is in ISO8601 format. @@ -248,7 +254,7 @@ private constructor( * @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") + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") /** * URL of the file. @@ -286,7 +292,9 @@ private constructor( * * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + @JsonProperty("createdAt") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * Returns the raw JSON value of [customCoordinates]. @@ -400,14 +408,16 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = 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 + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt /** * Returns the raw JSON value of [url]. @@ -454,7 +464,7 @@ private constructor( class Builder internal constructor() { private var aiTags: JsonField>? = null - private var createdAt: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() @@ -469,8 +479,8 @@ private constructor( 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 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() @@ -532,16 +542,16 @@ private constructor( } /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } /** An string with custom coordinates of the file. */ fun customCoordinates(customCoordinates: String?) = @@ -741,27 +751,27 @@ private constructor( fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } /** Type of the asset. */ - fun type(type: String) = type(JsonField.of(type)) + 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 [String] value instead. This + * 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 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: String) = updatedAt(JsonField.of(updatedAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } /** URL of the file. */ fun url(url: String) = url(JsonField.of(url)) @@ -873,7 +883,7 @@ private constructor( size() tags() thumbnail() - type() + type().ifPresent { it.validate() } updatedAt() url() versionInfo().ifPresent { it.validate() } @@ -912,7 +922,7 @@ private constructor( (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnail.asKnown().isPresent) 1 else 0) + - (if (type.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) + @@ -1237,6 +1247,134 @@ private constructor( 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( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt index 0b67d818..738918ca 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.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 @@ -13,6 +14,7 @@ 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 @@ -22,7 +24,7 @@ import kotlin.jvm.optionals.getOrNull class VersionRestoreResponse private constructor( private val aiTags: JsonField>, - private val createdAt: JsonField, + private val createdAt: JsonField, private val customCoordinates: JsonField, private val customMetadata: JsonField, private val fileId: JsonField, @@ -37,8 +39,8 @@ private constructor( private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, - private val type: JsonField, - private val updatedAt: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, private val url: JsonField, private val versionInfo: JsonField, private val width: JsonField, @@ -48,7 +50,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), - @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), @JsonProperty("customCoordinates") @ExcludeMissing customCoordinates: JsonField = JsonMissing.of(), @@ -71,8 +75,10 @@ private constructor( @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("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), @JsonProperty("versionInfo") @ExcludeMissing @@ -117,7 +123,7 @@ private constructor( * @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") + fun createdAt(): Optional = createdAt.getOptional("createdAt") /** * An string with custom coordinates of the file. @@ -240,7 +246,7 @@ private constructor( * @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") + fun type(): Optional = type.getOptional("type") /** * Date and time when the file was last updated. The date and time is in ISO8601 format. @@ -248,7 +254,7 @@ private constructor( * @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") + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") /** * URL of the file. @@ -286,7 +292,9 @@ private constructor( * * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + @JsonProperty("createdAt") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * Returns the raw JSON value of [customCoordinates]. @@ -400,14 +408,16 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = 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 + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt /** * Returns the raw JSON value of [url]. @@ -454,7 +464,7 @@ private constructor( class Builder internal constructor() { private var aiTags: JsonField>? = null - private var createdAt: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() @@ -469,8 +479,8 @@ private constructor( 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 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() @@ -532,16 +542,16 @@ private constructor( } /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } /** An string with custom coordinates of the file. */ fun customCoordinates(customCoordinates: String?) = @@ -741,27 +751,27 @@ private constructor( fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } /** Type of the asset. */ - fun type(type: String) = type(JsonField.of(type)) + 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 [String] value instead. This + * 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 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: String) = updatedAt(JsonField.of(updatedAt)) + 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 [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } /** URL of the file. */ fun url(url: String) = url(JsonField.of(url)) @@ -873,7 +883,7 @@ private constructor( size() tags() thumbnail() - type() + type().ifPresent { it.validate() } updatedAt() url() versionInfo().ifPresent { it.validate() } @@ -912,7 +922,7 @@ private constructor( (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnail.asKnown().isPresent) 1 else 0) + - (if (type.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) + @@ -1237,6 +1247,134 @@ private constructor( 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( 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 19ffd071..83382614 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,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 java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -25,7 +26,7 @@ internal class AssetListResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( AssetListResponse.FileDetails.CustomMetadata.builder() @@ -43,10 +44,10 @@ internal class AssetListResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(AssetListResponse.FileDetails.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo( AssetListResponse.FileDetails.VersionInfo.builder() .id("id") @@ -59,7 +60,7 @@ internal class AssetListResponseTest { val assetListResponse = AssetListResponse.ofFileDetails(fileDetails) assertThat(assetListResponse.fileDetails()).contains(fileDetails) - assertThat(assetListResponse.folderDetails()).isEmpty + assertThat(assetListResponse.folder()).isEmpty } @Test @@ -75,7 +76,7 @@ internal class AssetListResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( AssetListResponse.FileDetails.CustomMetadata.builder() @@ -93,10 +94,10 @@ internal class AssetListResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(AssetListResponse.FileDetails.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo( AssetListResponse.FileDetails.VersionInfo.builder() .id("id") @@ -117,35 +118,35 @@ internal class AssetListResponseTest { } @Test - fun ofFolderDetails() { - val folderDetails = - AssetListResponse.FolderDetails.builder() - .createdAt("createdAt") + fun ofFolder() { + val folder = + AssetListResponse.Folder.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .folderId("folderId") .folderPath("folderPath") .name("name") - .type(AssetListResponse.FolderDetails.Type.FOLDER) - .updatedAt("updatedAt") + .type(AssetListResponse.Folder.Type.FOLDER) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() - val assetListResponse = AssetListResponse.ofFolderDetails(folderDetails) + val assetListResponse = AssetListResponse.ofFolder(folder) assertThat(assetListResponse.fileDetails()).isEmpty - assertThat(assetListResponse.folderDetails()).contains(folderDetails) + assertThat(assetListResponse.folder()).contains(folder) } @Test - fun ofFolderDetailsRoundtrip() { + fun ofFolderRoundtrip() { val jsonMapper = jsonMapper() val assetListResponse = - AssetListResponse.ofFolderDetails( - AssetListResponse.FolderDetails.builder() - .createdAt("createdAt") + AssetListResponse.ofFolder( + AssetListResponse.Folder.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .folderId("folderId") .folderPath("folderPath") .name("name") - .type(AssetListResponse.FolderDetails.Type.FOLDER) - .updatedAt("updatedAt") + .type(AssetListResponse.Folder.Type.FOLDER) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt index 8376130c..99dd1389 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt @@ -5,6 +5,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 kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -22,7 +23,7 @@ internal class FileGetResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( FileGetResponse.CustomMetadata.builder() @@ -40,10 +41,10 @@ internal class FileGetResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(FileGetResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() @@ -56,7 +57,8 @@ internal class FileGetResponseTest { .source("source") .build() ) - assertThat(fileGetResponse.createdAt()).contains("createdAt") + assertThat(fileGetResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(fileGetResponse.customCoordinates()).contains("customCoordinates") assertThat(fileGetResponse.customMetadata()) .contains( @@ -75,10 +77,11 @@ internal class FileGetResponseTest { assertThat(fileGetResponse.name()).contains("name") assertThat(fileGetResponse.size()).contains(0.0) assertThat(fileGetResponse.tags().getOrNull()).containsExactly("string") - assertThat(fileGetResponse.thumbnail()).contains("thumbnail") - assertThat(fileGetResponse.type()).contains("type") - assertThat(fileGetResponse.updatedAt()).contains("updatedAt") - assertThat(fileGetResponse.url()).contains("url") + assertThat(fileGetResponse.thumbnail()).contains("https://example.com") + assertThat(fileGetResponse.type()).contains(FileGetResponse.Type.FILE) + assertThat(fileGetResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(fileGetResponse.url()).contains("https://example.com") assertThat(fileGetResponse.versionInfo()) .contains(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) assertThat(fileGetResponse.width()).contains(0.0) @@ -96,7 +99,7 @@ internal class FileGetResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( FileGetResponse.CustomMetadata.builder() @@ -114,10 +117,10 @@ internal class FileGetResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(FileGetResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) .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 2c53ad8d..34f030a6 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,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 kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -22,7 +23,7 @@ internal class FileUpdateResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( FileUpdateResponse.CustomMetadata.builder() @@ -52,10 +53,10 @@ internal class FileUpdateResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(FileUpdateResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() @@ -68,7 +69,8 @@ internal class FileUpdateResponseTest { .source("source") .build() ) - assertThat(fileUpdateResponse.createdAt()).contains("createdAt") + assertThat(fileUpdateResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(fileUpdateResponse.customCoordinates()).contains("customCoordinates") assertThat(fileUpdateResponse.customMetadata()) .contains( @@ -96,10 +98,11 @@ internal class FileUpdateResponseTest { assertThat(fileUpdateResponse.name()).contains("name") assertThat(fileUpdateResponse.size()).contains(0.0) assertThat(fileUpdateResponse.tags().getOrNull()).containsExactly("string") - assertThat(fileUpdateResponse.thumbnail()).contains("thumbnail") - assertThat(fileUpdateResponse.type()).contains("type") - assertThat(fileUpdateResponse.updatedAt()).contains("updatedAt") - assertThat(fileUpdateResponse.url()).contains("url") + assertThat(fileUpdateResponse.thumbnail()).contains("https://example.com") + assertThat(fileUpdateResponse.type()).contains(FileUpdateResponse.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(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) assertThat(fileUpdateResponse.width()).contains(0.0) @@ -117,7 +120,7 @@ internal class FileUpdateResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( FileUpdateResponse.CustomMetadata.builder() @@ -147,10 +150,10 @@ internal class FileUpdateResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(FileUpdateResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt index edb57d5d..c8c3e167 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.models.files.versions 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 @@ -22,7 +23,7 @@ internal class VersionGetResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( VersionGetResponse.CustomMetadata.builder() @@ -40,10 +41,10 @@ internal class VersionGetResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(VersionGetResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() @@ -56,7 +57,8 @@ internal class VersionGetResponseTest { .source("source") .build() ) - assertThat(versionGetResponse.createdAt()).contains("createdAt") + assertThat(versionGetResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(versionGetResponse.customCoordinates()).contains("customCoordinates") assertThat(versionGetResponse.customMetadata()) .contains( @@ -75,10 +77,11 @@ internal class VersionGetResponseTest { assertThat(versionGetResponse.name()).contains("name") assertThat(versionGetResponse.size()).contains(0.0) assertThat(versionGetResponse.tags().getOrNull()).containsExactly("string") - assertThat(versionGetResponse.thumbnail()).contains("thumbnail") - assertThat(versionGetResponse.type()).contains("type") - assertThat(versionGetResponse.updatedAt()).contains("updatedAt") - assertThat(versionGetResponse.url()).contains("url") + assertThat(versionGetResponse.thumbnail()).contains("https://example.com") + assertThat(versionGetResponse.type()).contains(VersionGetResponse.Type.FILE) + assertThat(versionGetResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(versionGetResponse.url()).contains("https://example.com") assertThat(versionGetResponse.versionInfo()) .contains(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) assertThat(versionGetResponse.width()).contains(0.0) @@ -96,7 +99,7 @@ internal class VersionGetResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( VersionGetResponse.CustomMetadata.builder() @@ -114,10 +117,10 @@ internal class VersionGetResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(VersionGetResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt index 5391afdb..cdcf0ad5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.models.files.versions 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 @@ -22,7 +23,7 @@ internal class VersionListResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( VersionListResponse.CustomMetadata.builder() @@ -40,10 +41,10 @@ internal class VersionListResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(VersionListResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo( VersionListResponse.VersionInfo.builder().id("id").name("name").build() ) @@ -58,7 +59,8 @@ internal class VersionListResponseTest { .source("source") .build() ) - assertThat(versionListResponse.createdAt()).contains("createdAt") + assertThat(versionListResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(versionListResponse.customCoordinates()).contains("customCoordinates") assertThat(versionListResponse.customMetadata()) .contains( @@ -77,10 +79,11 @@ internal class VersionListResponseTest { assertThat(versionListResponse.name()).contains("name") assertThat(versionListResponse.size()).contains(0.0) assertThat(versionListResponse.tags().getOrNull()).containsExactly("string") - assertThat(versionListResponse.thumbnail()).contains("thumbnail") - assertThat(versionListResponse.type()).contains("type") - assertThat(versionListResponse.updatedAt()).contains("updatedAt") - assertThat(versionListResponse.url()).contains("url") + assertThat(versionListResponse.thumbnail()).contains("https://example.com") + assertThat(versionListResponse.type()).contains(VersionListResponse.Type.FILE) + assertThat(versionListResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(versionListResponse.url()).contains("https://example.com") assertThat(versionListResponse.versionInfo()) .contains(VersionListResponse.VersionInfo.builder().id("id").name("name").build()) assertThat(versionListResponse.width()).contains(0.0) @@ -98,7 +101,7 @@ internal class VersionListResponseTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( VersionListResponse.CustomMetadata.builder() @@ -116,10 +119,10 @@ internal class VersionListResponseTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(VersionListResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo( VersionListResponse.VersionInfo.builder().id("id").name("name").build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt index 69214d98..9601681f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.models.files.versions 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 @@ -29,7 +30,7 @@ internal class VersionRestoreResponseTest { .source("aws-auto-tagging") .build() ) - .createdAt("2019-08-24T06:14:41.313Z") + .createdAt(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) .customCoordinates(null) .customMetadata( VersionRestoreResponse.CustomMetadata.builder() @@ -51,8 +52,8 @@ internal class VersionRestoreResponseTest { .thumbnail( "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" ) - .type("file") - .updatedAt("2019-08-24T06:14:41.313Z") + .type(VersionRestoreResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) .url( "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" ) @@ -78,7 +79,8 @@ internal class VersionRestoreResponseTest { .source("aws-auto-tagging") .build(), ) - assertThat(versionRestoreResponse.createdAt()).contains("2019-08-24T06:14:41.313Z") + assertThat(versionRestoreResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) assertThat(versionRestoreResponse.customCoordinates()).isEmpty assertThat(versionRestoreResponse.customMetadata()) .contains( @@ -103,8 +105,9 @@ internal class VersionRestoreResponseTest { .contains( "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" ) - assertThat(versionRestoreResponse.type()).contains("file") - assertThat(versionRestoreResponse.updatedAt()).contains("2019-08-24T06:14:41.313Z") + assertThat(versionRestoreResponse.type()).contains(VersionRestoreResponse.Type.FILE) + assertThat(versionRestoreResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) assertThat(versionRestoreResponse.url()) .contains( "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" @@ -138,7 +141,7 @@ internal class VersionRestoreResponseTest { .source("aws-auto-tagging") .build() ) - .createdAt("2019-08-24T06:14:41.313Z") + .createdAt(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) .customCoordinates(null) .customMetadata( VersionRestoreResponse.CustomMetadata.builder() @@ -160,8 +163,8 @@ internal class VersionRestoreResponseTest { .thumbnail( "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" ) - .type("file") - .updatedAt("2019-08-24T06:14:41.313Z") + .type(VersionRestoreResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) .url( "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" ) 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 f394e5b0..dcfc2cd7 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 @@ -8,6 +8,7 @@ import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.models.assets.AssetListResponse import com.imagekit.api.models.files.FileUpdateResponse +import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod import org.assertj.core.api.Assertions.assertThat @@ -75,7 +76,7 @@ internal class ProGuardCompatibilityTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( FileUpdateResponse.CustomMetadata.builder() @@ -105,10 +106,10 @@ internal class ProGuardCompatibilityTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(FileUpdateResponse.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() @@ -135,7 +136,7 @@ internal class ProGuardCompatibilityTest { .source("source") .build() ) - .createdAt("createdAt") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( AssetListResponse.FileDetails.CustomMetadata.builder() @@ -153,10 +154,10 @@ internal class ProGuardCompatibilityTest { .name("name") .size(0.0) .addTag("string") - .thumbnail("thumbnail") - .type("type") - .updatedAt("updatedAt") - .url("url") + .thumbnail("https://example.com") + .type(AssetListResponse.FileDetails.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") .versionInfo( AssetListResponse.FileDetails.VersionInfo.builder() .id("id") From f8a3d33a6a813262795c98ff6ddcd034ff6aebd0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 03:16:25 +0000 Subject: [PATCH 042/125] feat(api): manual updates --- .stats.yml | 2 +- ...eateResponse.kt => CustomMetadataField.kt} | 35 +- .../CustomMetadataFieldCreateParams.kt | 74 +- .../CustomMetadataFieldListResponse.kt | 1989 ----------------- .../CustomMetadataFieldUpdateParams.kt | 74 +- .../CustomMetadataFieldUpdateResponse.kt | 1989 ----------------- .../async/CustomMetadataFieldServiceAsync.kt | 67 +- .../CustomMetadataFieldServiceAsyncImpl.kt | 28 +- .../blocking/CustomMetadataFieldService.kt | 61 +- .../CustomMetadataFieldServiceImpl.kt | 28 +- .../CustomMetadataFieldCreateResponseTest.kt | 131 -- .../CustomMetadataFieldListResponseTest.kt | 121 - .../CustomMetadataFieldTest.kt | 108 + .../CustomMetadataFieldUpdateResponseTest.kt | 131 -- 14 files changed, 277 insertions(+), 4561 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/{CustomMetadataFieldCreateResponse.kt => CustomMetadataField.kt} (98%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 9ac0471d..ec9a7553 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-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml openapi_spec_hash: 98642308bee81ac776b7b1843089b888 -config_hash: 040d180c4960ee032ba08946d86c8764 +config_hash: 733231d3642f7945a9459fbc90ddfb8e diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt index 09699509..f69779fe 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt @@ -32,7 +32,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Object containing details of a custom metadata field. */ -class CustomMetadataFieldCreateResponse +class CustomMetadataField private constructor( private val id: JsonField, private val label: JsonField, @@ -126,8 +126,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CustomMetadataFieldCreateResponse]. + * Returns a mutable builder for constructing an instance of [CustomMetadataField]. * * The following fields are required: * ```java @@ -140,7 +139,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CustomMetadataFieldCreateResponse]. */ + /** A builder for [CustomMetadataField]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -150,15 +149,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(customMetadataFieldCreateResponse: CustomMetadataFieldCreateResponse) = - apply { - id = customMetadataFieldCreateResponse.id - label = customMetadataFieldCreateResponse.label - name = customMetadataFieldCreateResponse.name - schema = customMetadataFieldCreateResponse.schema - additionalProperties = - customMetadataFieldCreateResponse.additionalProperties.toMutableMap() - } + 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)) @@ -230,7 +227,7 @@ private constructor( } /** - * Returns an immutable instance of [CustomMetadataFieldCreateResponse]. + * Returns an immutable instance of [CustomMetadataField]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -244,8 +241,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CustomMetadataFieldCreateResponse = - CustomMetadataFieldCreateResponse( + fun build(): CustomMetadataField = + CustomMetadataField( checkRequired("id", id), checkRequired("label", label), checkRequired("name", name), @@ -256,7 +253,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CustomMetadataFieldCreateResponse = apply { + fun validate(): CustomMetadataField = apply { if (validated) { return@apply } @@ -1970,7 +1967,7 @@ private constructor( return true } - return other is CustomMetadataFieldCreateResponse && + return other is CustomMetadataField && id == other.id && label == other.label && name == other.name && @@ -1985,5 +1982,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomMetadataFieldCreateResponse{id=$id, label=$label, name=$name, schema=$schema, additionalProperties=$additionalProperties}" + "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 index 2d9f5f1a..fa4d61fe 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 = 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 string: String? = null, private val number: Double? = null, @@ -1518,7 +1518,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent3 = apply { + fun validate(): UnnamedSchemaWithArrayParent1 = apply { if (validated) { return@apply } @@ -1568,7 +1568,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent3 && + return other is UnnamedSchemaWithArrayParent1 && string == other.string && number == other.number && bool == other.bool @@ -1578,28 +1578,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 -> "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) = UnnamedSchemaWithArrayParent3(string = string) + fun ofString(string: String) = UnnamedSchemaWithArrayParent1(string = string) @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent3(number = number) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent1(number = number) @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent3(bool = bool) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent1(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + * [UnnamedSchemaWithArrayParent1] to a value of type [T]. */ interface Visitor { @@ -1610,10 +1610,10 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type + * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type * [T]. * - * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant + * 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. @@ -1622,31 +1622,31 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent3: $json" + "Unknown UnnamedSchemaWithArrayParent1: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent3::class + BaseDeserializer( + UnnamedSchemaWithArrayParent1::class ) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent3 { + ): UnnamedSchemaWithArrayParent1 { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(string = it, _json = json) + UnnamedSchemaWithArrayParent1(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(number = it, _json = json) + UnnamedSchemaWithArrayParent1(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(bool = it, _json = json) + UnnamedSchemaWithArrayParent1(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 -> UnnamedSchemaWithArrayParent3(_json = json) + 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 @@ -1667,12 +1667,12 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent3::class + BaseSerializer( + UnnamedSchemaWithArrayParent1::class ) { override fun serialize( - value: UnnamedSchemaWithArrayParent3, + value: UnnamedSchemaWithArrayParent1, 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 UnnamedSchemaWithArrayParent3") + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt deleted file mode 100644 index b3cb6e49..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponse.kt +++ /dev/null @@ -1,1989 +0,0 @@ -// 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 CustomMetadataFieldListResponse -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 - * [CustomMetadataFieldListResponse]. - * - * The following fields are required: - * ```java - * .id() - * .label() - * .name() - * .schema() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadataFieldListResponse]. */ - 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(customMetadataFieldListResponse: CustomMetadataFieldListResponse) = - apply { - id = customMetadataFieldListResponse.id - label = customMetadataFieldListResponse.label - name = customMetadataFieldListResponse.name - schema = customMetadataFieldListResponse.schema - additionalProperties = - customMetadataFieldListResponse.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 [CustomMetadataFieldListResponse]. - * - * 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(): CustomMetadataFieldListResponse = - CustomMetadataFieldListResponse( - checkRequired("id", id), - checkRequired("label", label), - checkRequired("name", name), - checkRequired("schema", schema), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadataFieldListResponse = 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 = 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 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 CustomMetadataFieldListResponse && - 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() = - "CustomMetadataFieldListResponse{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/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index e74ec85e..2cedf446 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 = UnnamedSchemaWithArrayParent4.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) - class UnnamedSchemaWithArrayParent4 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) + class UnnamedSchemaWithArrayParent2 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(): UnnamedSchemaWithArrayParent4 = apply { + fun validate(): UnnamedSchemaWithArrayParent2 = apply { if (validated) { return@apply } @@ -1290,7 +1290,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent4 && + return other is UnnamedSchemaWithArrayParent2 && string == other.string && number == other.number && bool == other.bool @@ -1300,28 +1300,28 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent4{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent4{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent4{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") + 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) = UnnamedSchemaWithArrayParent4(string = string) + fun ofString(string: String) = UnnamedSchemaWithArrayParent2(string = string) @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent4(number = number) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent2(number = number) @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent4(bool = bool) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent2(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent4] to a value of type [T]. + * [UnnamedSchemaWithArrayParent2] to a value of type [T]. */ interface Visitor { @@ -1332,10 +1332,10 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type + * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of type * [T]. * - * An instance of [UnnamedSchemaWithArrayParent4] 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. @@ -1344,31 +1344,31 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent4: $json" + "Unknown UnnamedSchemaWithArrayParent2: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent4::class + BaseDeserializer( + UnnamedSchemaWithArrayParent2::class ) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent4 { + ): UnnamedSchemaWithArrayParent2 { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(string = it, _json = json) + UnnamedSchemaWithArrayParent2(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(number = it, _json = json) + UnnamedSchemaWithArrayParent2(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(bool = it, _json = json) + UnnamedSchemaWithArrayParent2(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 -> UnnamedSchemaWithArrayParent4(_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 @@ -1389,12 +1389,12 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent4::class + BaseSerializer( + UnnamedSchemaWithArrayParent2::class ) { override fun serialize( - value: UnnamedSchemaWithArrayParent4, + value: UnnamedSchemaWithArrayParent2, 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 UnnamedSchemaWithArrayParent4") + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt deleted file mode 100644 index bc45b595..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponse.kt +++ /dev/null @@ -1,1989 +0,0 @@ -// 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 CustomMetadataFieldUpdateResponse -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 - * [CustomMetadataFieldUpdateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .label() - * .name() - * .schema() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadataFieldUpdateResponse]. */ - 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(customMetadataFieldUpdateResponse: CustomMetadataFieldUpdateResponse) = - apply { - id = customMetadataFieldUpdateResponse.id - label = customMetadataFieldUpdateResponse.label - name = customMetadataFieldUpdateResponse.name - schema = customMetadataFieldUpdateResponse.schema - additionalProperties = - customMetadataFieldUpdateResponse.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 [CustomMetadataFieldUpdateResponse]. - * - * 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(): CustomMetadataFieldUpdateResponse = - CustomMetadataFieldUpdateResponse( - checkRequired("id", id), - checkRequired("label", label), - checkRequired("name", name), - checkRequired("schema", schema), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadataFieldUpdateResponse = 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 = 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 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 CustomMetadataFieldUpdateResponse && - 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() = - "CustomMetadataFieldUpdateResponse{id=$id, label=$label, name=$name, schema=$schema, additionalProperties=$additionalProperties}" -} 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 58153e22..6d7d7c13 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 @@ -5,14 +5,12 @@ 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.CustomMetadataFieldCreateResponse 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.CustomMetadataFieldListResponse import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -36,18 +34,17 @@ interface CustomMetadataFieldServiceAsync { * 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()) + fun create(params: CustomMetadataFieldCreateParams): CompletableFuture = + create(params, RequestOptions.none()) /** @see create */ fun create( params: CustomMetadataFieldCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** This API updates the label or schema of an existing custom metadata field. */ - fun update(id: String): CompletableFuture = + fun update(id: String): CompletableFuture = update(id, CustomMetadataFieldUpdateParams.none()) /** @see update */ @@ -55,32 +52,27 @@ interface CustomMetadataFieldServiceAsync { id: String, params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ fun update( id: String, params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), - ): CompletableFuture = - update(id, params, RequestOptions.none()) + ): CompletableFuture = update(id, params, RequestOptions.none()) /** @see update */ fun update( params: CustomMetadataFieldUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see update */ - fun update( - params: CustomMetadataFieldUpdateParams - ): CompletableFuture = update(params, RequestOptions.none()) + fun update(params: CustomMetadataFieldUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) /** @see update */ - fun update( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture = + fun update(id: String, requestOptions: RequestOptions): CompletableFuture = update(id, CustomMetadataFieldUpdateParams.none(), requestOptions) /** @@ -88,25 +80,22 @@ interface CustomMetadataFieldServiceAsync { * returns only non deleted field objects, but you can include deleted fields in the API * response. */ - fun list(): CompletableFuture> = + fun list(): CompletableFuture> = list(CustomMetadataFieldListParams.none()) /** @see list */ fun list( params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see list */ fun list( params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + ): CompletableFuture> = list(params, RequestOptions.none()) /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = + fun list(requestOptions: RequestOptions): CompletableFuture> = list(CustomMetadataFieldListParams.none(), requestOptions) /** @@ -170,22 +159,20 @@ interface CustomMetadataFieldServiceAsync { */ fun create( params: CustomMetadataFieldCreateParams - ): CompletableFuture> = + ): CompletableFuture> = create(params, RequestOptions.none()) /** @see create */ fun create( params: CustomMetadataFieldCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `patch /v1/customMetadataFields/{id}`, but is otherwise * the same as [CustomMetadataFieldServiceAsync.update]. */ - fun update( - id: String - ): CompletableFuture> = + fun update(id: String): CompletableFuture> = update(id, CustomMetadataFieldUpdateParams.none()) /** @see update */ @@ -193,58 +180,58 @@ interface CustomMetadataFieldServiceAsync { id: String, params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ fun update( id: String, params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = update(id, params, RequestOptions.none()) /** @see update */ fun update( params: CustomMetadataFieldUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see update */ fun update( params: CustomMetadataFieldUpdateParams - ): CompletableFuture> = + ): CompletableFuture> = update(params, RequestOptions.none()) /** @see update */ fun update( id: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): 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>> = + fun list(): CompletableFuture>> = list(CustomMetadataFieldListParams.none()) /** @see list */ fun list( params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + ): CompletableFuture>> /** @see list */ fun list( params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none() - ): CompletableFuture>> = + ): CompletableFuture>> = list(params, RequestOptions.none()) /** @see list */ fun list( requestOptions: RequestOptions - ): CompletableFuture>> = + ): CompletableFuture>> = list(CustomMetadataFieldListParams.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 index c6e6494f..35d3ee2c 100644 --- 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 @@ -16,14 +16,12 @@ 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.CustomMetadataFieldCreateResponse 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.CustomMetadataFieldListResponse import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -48,21 +46,21 @@ internal constructor(private val clientOptions: ClientOptions) : CustomMetadataF override fun create( params: CustomMetadataFieldCreateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/customMetadataFields withRawResponse().create(params, requestOptions).thenApply { it.parse() } override fun update( params: CustomMetadataFieldUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // patch /v1/customMetadataFields/{id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } override fun list( params: CustomMetadataFieldListParams, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = // get /v1/customMetadataFields withRawResponse().list(params, requestOptions).thenApply { it.parse() } @@ -86,13 +84,13 @@ internal constructor(private val clientOptions: ClientOptions) : CustomMetadataF clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: CustomMetadataFieldCreateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -117,13 +115,13 @@ internal constructor(private val clientOptions: ClientOptions) : CustomMetadataF } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: CustomMetadataFieldUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -151,13 +149,13 @@ internal constructor(private val clientOptions: ClientOptions) : CustomMetadataF } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: CustomMetadataFieldListParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture>> { val request = HttpRequest.builder() .method(HttpMethod.GET) 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 c672e78b..bd644eeb 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 @@ -6,14 +6,12 @@ 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.CustomMetadataFieldCreateResponse 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.CustomMetadataFieldListResponse import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateResponse import java.util.function.Consumer interface CustomMetadataFieldService { @@ -36,44 +34,43 @@ interface CustomMetadataFieldService { * 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): CustomMetadataFieldCreateResponse = + fun create(params: CustomMetadataFieldCreateParams): CustomMetadataField = create(params, RequestOptions.none()) /** @see create */ fun create( params: CustomMetadataFieldCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomMetadataFieldCreateResponse + ): CustomMetadataField /** This API updates the label or schema of an existing custom metadata field. */ - fun update(id: String): CustomMetadataFieldUpdateResponse = - update(id, CustomMetadataFieldUpdateParams.none()) + fun update(id: String): CustomMetadataField = update(id, CustomMetadataFieldUpdateParams.none()) /** @see update */ fun update( id: String, params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CustomMetadataFieldUpdateResponse = update(params.toBuilder().id(id).build(), requestOptions) + ): CustomMetadataField = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ fun update( id: String, params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), - ): CustomMetadataFieldUpdateResponse = update(id, params, RequestOptions.none()) + ): CustomMetadataField = update(id, params, RequestOptions.none()) /** @see update */ fun update( params: CustomMetadataFieldUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomMetadataFieldUpdateResponse + ): CustomMetadataField /** @see update */ - fun update(params: CustomMetadataFieldUpdateParams): CustomMetadataFieldUpdateResponse = + fun update(params: CustomMetadataFieldUpdateParams): CustomMetadataField = update(params, RequestOptions.none()) /** @see update */ - fun update(id: String, requestOptions: RequestOptions): CustomMetadataFieldUpdateResponse = + fun update(id: String, requestOptions: RequestOptions): CustomMetadataField = update(id, CustomMetadataFieldUpdateParams.none(), requestOptions) /** @@ -81,21 +78,21 @@ interface CustomMetadataFieldService { * returns only non deleted field objects, but you can include deleted fields in the API * response. */ - fun list(): List = list(CustomMetadataFieldListParams.none()) + fun list(): List = list(CustomMetadataFieldListParams.none()) /** @see list */ fun list( params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): List + ): List /** @see list */ fun list( params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none() - ): List = list(params, RequestOptions.none()) + ): List = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): List = + fun list(requestOptions: RequestOptions): List = list(CustomMetadataFieldListParams.none(), requestOptions) /** @@ -152,9 +149,7 @@ interface CustomMetadataFieldService { * same as [CustomMetadataFieldService.create]. */ @MustBeClosed - fun create( - params: CustomMetadataFieldCreateParams - ): HttpResponseFor = + fun create(params: CustomMetadataFieldCreateParams): HttpResponseFor = create(params, RequestOptions.none()) /** @see create */ @@ -162,14 +157,14 @@ interface CustomMetadataFieldService { fun create( params: CustomMetadataFieldCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun update(id: String): HttpResponseFor = update(id, CustomMetadataFieldUpdateParams.none()) /** @see update */ @@ -178,7 +173,7 @@ interface CustomMetadataFieldService { id: String, params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ @@ -186,21 +181,18 @@ interface CustomMetadataFieldService { fun update( id: String, params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), - ): HttpResponseFor = - update(id, params, RequestOptions.none()) + ): HttpResponseFor = update(id, params, RequestOptions.none()) /** @see update */ @MustBeClosed fun update( params: CustomMetadataFieldUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see update */ @MustBeClosed - fun update( - params: CustomMetadataFieldUpdateParams - ): HttpResponseFor = + fun update(params: CustomMetadataFieldUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) /** @see update */ @@ -208,7 +200,7 @@ interface CustomMetadataFieldService { fun update( id: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = update(id, CustomMetadataFieldUpdateParams.none(), requestOptions) /** @@ -216,7 +208,7 @@ interface CustomMetadataFieldService { * as [CustomMetadataFieldService.list]. */ @MustBeClosed - fun list(): HttpResponseFor> = + fun list(): HttpResponseFor> = list(CustomMetadataFieldListParams.none()) /** @see list */ @@ -224,20 +216,17 @@ interface CustomMetadataFieldService { fun list( params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + ): HttpResponseFor> /** @see list */ @MustBeClosed fun list( params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none() - ): HttpResponseFor> = - list(params, RequestOptions.none()) + ): HttpResponseFor> = list(params, RequestOptions.none()) /** @see list */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): HttpResponseFor> = + fun list(requestOptions: RequestOptions): HttpResponseFor> = list(CustomMetadataFieldListParams.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 index a5a307ad..ac2e2357 100644 --- 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 @@ -16,14 +16,12 @@ 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.CustomMetadataFieldCreateResponse 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.CustomMetadataFieldListResponse import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -44,21 +42,21 @@ internal constructor(private val clientOptions: ClientOptions) : CustomMetadataF override fun create( params: CustomMetadataFieldCreateParams, requestOptions: RequestOptions, - ): CustomMetadataFieldCreateResponse = + ): CustomMetadataField = // post /v1/customMetadataFields withRawResponse().create(params, requestOptions).parse() override fun update( params: CustomMetadataFieldUpdateParams, requestOptions: RequestOptions, - ): CustomMetadataFieldUpdateResponse = + ): CustomMetadataField = // patch /v1/customMetadataFields/{id} withRawResponse().update(params, requestOptions).parse() override fun list( params: CustomMetadataFieldListParams, requestOptions: RequestOptions, - ): List = + ): List = // get /v1/customMetadataFields withRawResponse().list(params, requestOptions).parse() @@ -82,13 +80,13 @@ internal constructor(private val clientOptions: ClientOptions) : CustomMetadataF clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: CustomMetadataFieldCreateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -110,13 +108,13 @@ internal constructor(private val clientOptions: ClientOptions) : CustomMetadataF } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: CustomMetadataFieldUpdateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -141,13 +139,13 @@ internal constructor(private val clientOptions: ClientOptions) : CustomMetadataF } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: CustomMetadataFieldListParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor> { val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt deleted file mode 100644 index 0fa0ea81..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateResponseTest.kt +++ /dev/null @@ -1,131 +0,0 @@ -// 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 CustomMetadataFieldCreateResponseTest { - - @Test - fun create() { - val customMetadataFieldCreateResponse = - CustomMetadataFieldCreateResponse.builder() - .id("id") - .label("label") - .name("name") - .schema( - CustomMetadataFieldCreateResponse.Schema.builder() - .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( - "small" - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( - "medium" - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( - "large" - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber( - 30.0 - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber( - 40.0 - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - .build() - - assertThat(customMetadataFieldCreateResponse.id()).isEqualTo("id") - assertThat(customMetadataFieldCreateResponse.label()).isEqualTo("label") - assertThat(customMetadataFieldCreateResponse.name()).isEqualTo("name") - assertThat(customMetadataFieldCreateResponse.schema()) - .isEqualTo( - CustomMetadataFieldCreateResponse.Schema.builder() - .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString("small"), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( - "medium" - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString("large"), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber(30.0), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber(40.0), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val customMetadataFieldCreateResponse = - CustomMetadataFieldCreateResponse.builder() - .id("id") - .label("label") - .name("name") - .schema( - CustomMetadataFieldCreateResponse.Schema.builder() - .type(CustomMetadataFieldCreateResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( - "small" - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( - "medium" - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofString( - "large" - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber( - 30.0 - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofNumber( - 40.0 - ), - CustomMetadataFieldCreateResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - .build() - - val roundtrippedCustomMetadataFieldCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(customMetadataFieldCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedCustomMetadataFieldCreateResponse) - .isEqualTo(customMetadataFieldCreateResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt deleted file mode 100644 index 6dd28045..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListResponseTest.kt +++ /dev/null @@ -1,121 +0,0 @@ -// 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 CustomMetadataFieldListResponseTest { - - @Test - fun create() { - val customMetadataFieldListResponse = - CustomMetadataFieldListResponse.builder() - .id("id") - .label("label") - .name("name") - .schema( - CustomMetadataFieldListResponse.Schema.builder() - .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldListResponse.Schema.SelectOption.ofString( - "small" - ), - CustomMetadataFieldListResponse.Schema.SelectOption.ofString( - "medium" - ), - CustomMetadataFieldListResponse.Schema.SelectOption.ofString( - "large" - ), - CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(30.0), - CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(40.0), - CustomMetadataFieldListResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - .build() - - assertThat(customMetadataFieldListResponse.id()).isEqualTo("id") - assertThat(customMetadataFieldListResponse.label()).isEqualTo("label") - assertThat(customMetadataFieldListResponse.name()).isEqualTo("name") - assertThat(customMetadataFieldListResponse.schema()) - .isEqualTo( - CustomMetadataFieldListResponse.Schema.builder() - .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldListResponse.Schema.SelectOption.ofString("small"), - CustomMetadataFieldListResponse.Schema.SelectOption.ofString("medium"), - CustomMetadataFieldListResponse.Schema.SelectOption.ofString("large"), - CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(30.0), - CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(40.0), - CustomMetadataFieldListResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val customMetadataFieldListResponse = - CustomMetadataFieldListResponse.builder() - .id("id") - .label("label") - .name("name") - .schema( - CustomMetadataFieldListResponse.Schema.builder() - .type(CustomMetadataFieldListResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldListResponse.Schema.SelectOption.ofString( - "small" - ), - CustomMetadataFieldListResponse.Schema.SelectOption.ofString( - "medium" - ), - CustomMetadataFieldListResponse.Schema.SelectOption.ofString( - "large" - ), - CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(30.0), - CustomMetadataFieldListResponse.Schema.SelectOption.ofNumber(40.0), - CustomMetadataFieldListResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - .build() - - val roundtrippedCustomMetadataFieldListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(customMetadataFieldListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedCustomMetadataFieldListResponse) - .isEqualTo(customMetadataFieldListResponse) - } -} 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/CustomMetadataFieldUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt deleted file mode 100644 index 2ce6e88a..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateResponseTest.kt +++ /dev/null @@ -1,131 +0,0 @@ -// 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 CustomMetadataFieldUpdateResponseTest { - - @Test - fun create() { - val customMetadataFieldUpdateResponse = - CustomMetadataFieldUpdateResponse.builder() - .id("id") - .label("label") - .name("name") - .schema( - CustomMetadataFieldUpdateResponse.Schema.builder() - .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( - "small" - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( - "medium" - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( - "large" - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber( - 30.0 - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber( - 40.0 - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - .build() - - assertThat(customMetadataFieldUpdateResponse.id()).isEqualTo("id") - assertThat(customMetadataFieldUpdateResponse.label()).isEqualTo("label") - assertThat(customMetadataFieldUpdateResponse.name()).isEqualTo("name") - assertThat(customMetadataFieldUpdateResponse.schema()) - .isEqualTo( - CustomMetadataFieldUpdateResponse.Schema.builder() - .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString("small"), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( - "medium" - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString("large"), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber(30.0), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber(40.0), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val customMetadataFieldUpdateResponse = - CustomMetadataFieldUpdateResponse.builder() - .id("id") - .label("label") - .name("name") - .schema( - CustomMetadataFieldUpdateResponse.Schema.builder() - .type(CustomMetadataFieldUpdateResponse.Schema.Type.TEXT) - .defaultValue("string") - .isValueRequired(true) - .maxLength(0.0) - .maxValue("string") - .minLength(0.0) - .minValue("string") - .selectOptions( - listOf( - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( - "small" - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( - "medium" - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofString( - "large" - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber( - 30.0 - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofNumber( - 40.0 - ), - CustomMetadataFieldUpdateResponse.Schema.SelectOption.ofBool(true), - ) - ) - .build() - ) - .build() - - val roundtrippedCustomMetadataFieldUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(customMetadataFieldUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedCustomMetadataFieldUpdateResponse) - .isEqualTo(customMetadataFieldUpdateResponse) - } -} From 0c7f3d3594826047307128e4e12a688a4e3328ed Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 03:21:07 +0000 Subject: [PATCH 043/125] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/assets/AssetListResponse.kt | 2178 +---------------- .../files/{FileGetResponse.kt => File.kt} | 64 +- .../api/models/files/FileUpdateResponse.kt | 1086 ++------ .../com/imagekit/api/models/files/Folder.kt | 478 ++++ .../files/versions/VersionGetResponse.kt | 1615 ------------ .../files/versions/VersionListResponse.kt | 1615 ------------ .../files/versions/VersionRestoreResponse.kt | 1615 ------------ .../api/services/async/FileServiceAsync.kt | 33 +- .../services/async/FileServiceAsyncImpl.kt | 9 +- .../async/files/VersionServiceAsync.kt | 74 +- .../async/files/VersionServiceAsyncImpl.kt | 26 +- .../api/services/blocking/FileService.kt | 32 +- .../api/services/blocking/FileServiceImpl.kt | 9 +- .../services/blocking/files/VersionService.kt | 76 +- .../blocking/files/VersionServiceImpl.kt | 32 +- .../models/assets/AssetListResponseTest.kt | 62 +- .../api/models/files/FileGetResponseTest.kt | 136 - .../com/imagekit/api/models/files/FileTest.kt | 119 + .../models/files/FileUpdateResponseTest.kt | 102 +- .../imagekit/api/models/files/FolderTest.kt | 51 + .../files/versions/VersionGetResponseTest.kt | 136 - .../files/versions/VersionListResponseTest.kt | 140 -- .../versions/VersionRestoreResponseTest.kt | 188 -- .../async/files/VersionServiceAsyncTest.kt | 18 +- .../blocking/files/VersionServiceTest.kt | 12 +- .../api/proguard/ProGuardCompatibilityTest.kt | 62 +- 27 files changed, 1162 insertions(+), 8808 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{FileGetResponse.kt => File.kt} (96%) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.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/FolderTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt diff --git a/.stats.yml b/.stats.yml index ec9a7553..0fe111b5 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-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml openapi_spec_hash: 98642308bee81ac776b7b1843089b888 -config_hash: 733231d3642f7945a9459fbc90ddfb8e +config_hash: 91cbeb97fdb75393dffd187ec25a4080 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 index 6835c6e7..8e1fbee8 100644 --- 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 @@ -2,10 +2,6 @@ package com.imagekit.api.models.assets -import 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 @@ -15,17 +11,11 @@ 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.checkKnown import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import java.time.OffsetDateTime -import java.util.Collections +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 @@ -35,22 +25,22 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = AssetListResponse.Serializer::class) class AssetListResponse private constructor( - private val fileDetails: FileDetails? = null, + 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 fileDetails(): Optional = Optional.ofNullable(fileDetails) + fun file(): Optional = Optional.ofNullable(file) fun folder(): Optional = Optional.ofNullable(folder) - fun isFileDetails(): Boolean = fileDetails != null + fun isFile(): Boolean = file != null fun isFolder(): Boolean = folder != null /** Object containing details of a file or file version. */ - fun asFileDetails(): FileDetails = fileDetails.getOrThrow("fileDetails") + fun asFile(): File = file.getOrThrow("file") fun asFolder(): Folder = folder.getOrThrow("folder") @@ -58,7 +48,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - fileDetails != null -> visitor.visitFileDetails(fileDetails) + file != null -> visitor.visitFile(file) folder != null -> visitor.visitFolder(folder) else -> visitor.unknown(_json) } @@ -72,8 +62,8 @@ private constructor( accept( object : Visitor { - override fun visitFileDetails(fileDetails: FileDetails) { - fileDetails.validate() + override fun visitFile(file: File) { + file.validate() } override fun visitFolder(folder: Folder) { @@ -101,7 +91,7 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitFileDetails(fileDetails: FileDetails) = fileDetails.validity() + override fun visitFile(file: File) = file.validity() override fun visitFolder(folder: Folder) = folder.validity() @@ -114,16 +104,14 @@ private constructor( return true } - return other is AssetListResponse && - fileDetails == other.fileDetails && - folder == other.folder + return other is AssetListResponse && file == other.file && folder == other.folder } - override fun hashCode(): Int = Objects.hash(fileDetails, folder) + override fun hashCode(): Int = Objects.hash(file, folder) override fun toString(): String = when { - fileDetails != null -> "AssetListResponse{fileDetails=$fileDetails}" + file != null -> "AssetListResponse{file=$file}" folder != null -> "AssetListResponse{folder=$folder}" _json != null -> "AssetListResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid AssetListResponse") @@ -132,8 +120,7 @@ private constructor( companion object { /** Object containing details of a file or file version. */ - @JvmStatic - fun ofFileDetails(fileDetails: FileDetails) = AssetListResponse(fileDetails = fileDetails) + @JvmStatic fun ofFile(file: File) = AssetListResponse(file = file) @JvmStatic fun ofFolder(folder: Folder) = AssetListResponse(folder = folder) } @@ -145,7 +132,7 @@ private constructor( interface Visitor { /** Object containing details of a file or file version. */ - fun visitFileDetails(fileDetails: FileDetails): T + fun visitFile(file: File): T fun visitFolder(folder: Folder): T @@ -176,8 +163,8 @@ private constructor( } ?: AssetListResponse(_json = json) } - return tryDeserialize(node, jacksonTypeRef())?.let { - AssetListResponse(fileDetails = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + AssetListResponse(file = it, _json = json) } ?: AssetListResponse(_json = json) } } @@ -190,2140 +177,11 @@ private constructor( provider: SerializerProvider, ) { when { - value.fileDetails != null -> generator.writeObject(value.fileDetails) + 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") } } } - - /** Object containing details of a file or file version. */ - class FileDetails - private constructor( - private val aiTags: JsonField>, - private val createdAt: JsonField, - private val customCoordinates: JsonField, - private val customMetadata: 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("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, - 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") - - /** - * 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 [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 [FileDetails]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileDetails]. */ - 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 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(fileDetails: FileDetails) = apply { - aiTags = fileDetails.aiTags.map { it.toMutableList() } - createdAt = fileDetails.createdAt - customCoordinates = fileDetails.customCoordinates - customMetadata = fileDetails.customMetadata - fileId = fileDetails.fileId - filePath = fileDetails.filePath - fileType = fileDetails.fileType - hasAlpha = fileDetails.hasAlpha - height = fileDetails.height - isPrivateFile = fileDetails.isPrivateFile - isPublished = fileDetails.isPublished - mime = fileDetails.mime - name = fileDetails.name - size = fileDetails.size - tags = fileDetails.tags.map { it.toMutableList() } - thumbnail = fileDetails.thumbnail - type = fileDetails.type - updatedAt = fileDetails.updatedAt - url = fileDetails.url - versionInfo = fileDetails.versionInfo - width = fileDetails.width - additionalProperties = fileDetails.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 - } - - /** 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 [FileDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FileDetails = - FileDetails( - (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, - createdAt, - customCoordinates, - customMetadata, - 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(): FileDetails = apply { - if (validated) { - return@apply - } - - aiTags().ifPresent { it.forEach { it.validate() } } - createdAt() - customCoordinates() - customMetadata().ifPresent { it.validate() } - 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 (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 FileDetails && - aiTags == other.aiTags && - createdAt == other.createdAt && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - 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, - 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() = - "FileDetails{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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}" - } - - 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/FileGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index 76170cdb..7fc5fe6b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -21,7 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Object containing details of a file or file version. */ -class FileGetResponse +class File private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, @@ -456,11 +456,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [FileGetResponse]. */ + /** Returns a mutable builder for constructing an instance of [File]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [FileGetResponse]. */ + /** A builder for [File]. */ class Builder internal constructor() { private var aiTags: JsonField>? = null @@ -487,29 +487,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileGetResponse: FileGetResponse) = apply { - aiTags = fileGetResponse.aiTags.map { it.toMutableList() } - createdAt = fileGetResponse.createdAt - customCoordinates = fileGetResponse.customCoordinates - customMetadata = fileGetResponse.customMetadata - fileId = fileGetResponse.fileId - filePath = fileGetResponse.filePath - fileType = fileGetResponse.fileType - hasAlpha = fileGetResponse.hasAlpha - height = fileGetResponse.height - isPrivateFile = fileGetResponse.isPrivateFile - isPublished = fileGetResponse.isPublished - mime = fileGetResponse.mime - name = fileGetResponse.name - size = fileGetResponse.size - tags = fileGetResponse.tags.map { it.toMutableList() } - thumbnail = fileGetResponse.thumbnail - type = fileGetResponse.type - updatedAt = fileGetResponse.updatedAt - url = fileGetResponse.url - versionInfo = fileGetResponse.versionInfo - width = fileGetResponse.width - additionalProperties = fileGetResponse.additionalProperties.toMutableMap() + internal fun from(file: File) = apply { + aiTags = file.aiTags.map { it.toMutableList() } + createdAt = file.createdAt + customCoordinates = file.customCoordinates + customMetadata = file.customMetadata + 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. */ @@ -829,12 +829,12 @@ private constructor( } /** - * Returns an immutable instance of [FileGetResponse]. + * Returns an immutable instance of [File]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): FileGetResponse = - FileGetResponse( + fun build(): File = + File( (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, createdAt, customCoordinates, @@ -862,7 +862,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileGetResponse = apply { + fun validate(): File = apply { if (validated) { return@apply } @@ -1556,7 +1556,7 @@ private constructor( return true } - return other is FileGetResponse && + return other is File && aiTags == other.aiTags && createdAt == other.createdAt && customCoordinates == other.customCoordinates && @@ -1611,5 +1611,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileGetResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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, 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/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index 57b85ea4..b09444fd 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 @@ -20,13 +20,13 @@ 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 aiTags: JsonField>, private val createdAt: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonField, - private val extensionStatus: JsonField, + private val customMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -39,17 +39,20 @@ private constructor( private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, - private val type: JsonField, + private val type: JsonField, private val updatedAt: JsonField, private val url: JsonField, - private val versionInfo: 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("AITags") + @ExcludeMissing + aiTags: JsonField> = JsonMissing.of(), @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -58,10 +61,7 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonField = JsonMissing.of(), - @JsonProperty("extensionStatus") - @ExcludeMissing - extensionStatus: JsonField = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), @@ -78,21 +78,23 @@ private constructor( @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("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(), + versionInfo: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + @JsonProperty("extensionStatus") + @ExcludeMissing + extensionStatus: JsonField = JsonMissing.of(), ) : this( aiTags, createdAt, customCoordinates, customMetadata, - extensionStatus, fileId, filePath, fileType, @@ -110,16 +112,42 @@ private constructor( url, versionInfo, width, + extensionStatus, mutableMapOf(), ) + fun toFile(): File = + File.builder() + .aiTags(aiTags) + .createdAt(createdAt) + .customCoordinates(customCoordinates) + .customMetadata(customMetadata) + .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") + fun aiTags(): Optional> = aiTags.getOptional("AITags") /** * Date and time when the file was uploaded. The date and time is in ISO8601 format. @@ -143,14 +171,8 @@ 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") - - /** - * @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") + fun customMetadata(): Optional = + customMetadata.getOptional("customMetadata") /** * Unique identifier of the asset. @@ -257,7 +279,7 @@ private constructor( * @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") + fun type(): Optional = type.getOptional("type") /** * Date and time when the file was last updated. The date and time is in ISO8601 format. @@ -281,7 +303,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") /** * Width of the file. @@ -291,12 +313,19 @@ private constructor( */ 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 + @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags /** * Returns the raw JSON value of [createdAt]. @@ -324,16 +353,7 @@ private constructor( */ @JsonProperty("customMetadata") @ExcludeMissing - fun _customMetadata(): JsonField = customMetadata - - /** - * 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 + fun _customMetadata(): JsonField = customMetadata /** * Returns the raw JSON value of [fileId]. @@ -428,7 +448,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [updatedAt]. @@ -453,7 +473,7 @@ private constructor( */ @JsonProperty("versionInfo") @ExcludeMissing - fun _versionInfo(): JsonField = versionInfo + fun _versionInfo(): JsonField = versionInfo /** * Returns the raw JSON value of [width]. @@ -462,6 +482,15 @@ private constructor( */ @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) @@ -483,11 +512,10 @@ private constructor( /** A builder for [FileUpdateResponse]. */ class Builder internal constructor() { - private var aiTags: JsonField>? = null + 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 extensionStatus: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -500,11 +528,12 @@ private constructor( 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 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 width: JsonField = JsonMissing.of() + private var extensionStatus: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -513,7 +542,6 @@ private constructor( createdAt = fileUpdateResponse.createdAt customCoordinates = fileUpdateResponse.customCoordinates customMetadata = fileUpdateResponse.customMetadata - extensionStatus = fileUpdateResponse.extensionStatus fileId = fileUpdateResponse.fileId filePath = fileUpdateResponse.filePath fileType = fileUpdateResponse.fileType @@ -531,32 +559,33 @@ private constructor( 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)) + 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 [AiTag] to [aiTags]. + * Adds a single [File.AiTag] to [aiTags]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addAiTag(aiTag: AiTag) = apply { + fun addAiTag(aiTag: File.AiTag) = apply { aiTags = (aiTags ?: JsonField.of(mutableListOf())).also { checkKnown("aiTags", it).add(aiTag) @@ -595,32 +624,18 @@ private constructor( } /** An object with custom metadata for the file. */ - fun customMetadata(customMetadata: CustomMetadata) = + 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 [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 - } - - 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] + * 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 extensionStatus(extensionStatus: JsonField) = apply { - this.extensionStatus = extensionStatus + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata } /** Unique identifier of the asset. */ @@ -787,15 +802,15 @@ private constructor( fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } /** Type of the asset. */ - fun type(type: Type) = type(JsonField.of(type)) + 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 [Type] value instead. This + * 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 } + 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)) @@ -821,16 +836,16 @@ private constructor( fun url(url: JsonField) = apply { this.url = url } /** An object with details of the file version. */ - fun versionInfo(versionInfo: VersionInfo) = versionInfo(JsonField.of(versionInfo)) + 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 [VersionInfo] 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 { + fun versionInfo(versionInfo: JsonField) = apply { this.versionInfo = versionInfo } @@ -845,6 +860,20 @@ private constructor( */ 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) @@ -875,7 +904,6 @@ private constructor( createdAt, customCoordinates, customMetadata, - extensionStatus, fileId, filePath, fileType, @@ -893,6 +921,7 @@ private constructor( url, versionInfo, width, + extensionStatus, additionalProperties.toMutableMap(), ) } @@ -908,7 +937,6 @@ private constructor( createdAt() customCoordinates() customMetadata().ifPresent { it.validate() } - extensionStatus().ifPresent { it.validate() } fileId() filePath() fileType() @@ -926,6 +954,7 @@ private constructor( url() versionInfo().ifPresent { it.validate() } width() + extensionStatus().ifPresent { it.validate() } validated = true } @@ -948,7 +977,6 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (if (customCoordinates.asKnown().isPresent) 1 else 0) + (customMetadata.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) + @@ -965,71 +993,97 @@ private constructor( (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) + (if (width.asKnown().isPresent) 1 else 0) + + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) - class AiTag + class ExtensionStatus private constructor( - private val confidence: JsonField, - private val name: JsonField, - private val source: JsonField, + private val aiAutoDescription: JsonField, + private val awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("confidence") + @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 - confidence: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - ) : this(confidence, name, source, mutableMapOf()) + removeBg: JsonField = JsonMissing.of(), + ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, 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") + fun aiAutoDescription(): Optional = + aiAutoDescription.getOptional("ai-auto-description") /** - * 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") + 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") /** - * 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") + 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 [confidence]. + * Returns the raw JSON value of [awsAutoTagging]. * - * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [awsAutoTagging], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("confidence") + @JsonProperty("aws-auto-tagging") @ExcludeMissing - fun _confidence(): JsonField = confidence + fun _awsAutoTagging(): JsonField = awsAutoTagging /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [googleAutoTagging]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [googleAutoTagging], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("google-auto-tagging") + @ExcludeMissing + fun _googleAutoTagging(): JsonField = googleAutoTagging /** - * Returns the raw JSON value of [source]. + * Returns the raw JSON value of [removeBg]. * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [removeBg], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + @JsonProperty("remove-bg") @ExcludeMissing fun _removeBg(): JsonField = removeBg @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1045,63 +1099,80 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [AiTag]. */ + /** Returns a mutable builder for constructing an instance of [ExtensionStatus]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [AiTag]. */ + /** A builder for [ExtensionStatus]. */ class Builder internal constructor() { - private var confidence: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() + 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(aiTag: AiTag) = apply { - confidence = aiTag.confidence - name = aiTag.name - source = aiTag.source - additionalProperties = aiTag.additionalProperties.toMutableMap() + internal fun from(extensionStatus: ExtensionStatus) = apply { + aiAutoDescription = extensionStatus.aiAutoDescription + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() } - /** Confidence score of the tag. */ - fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) + fun aiAutoDescription(aiAutoDescription: AiAutoDescription) = + aiAutoDescription(JsonField.of(aiAutoDescription)) /** - * Sets [Builder.confidence] to an arbitrary JSON value. + * Sets [Builder.aiAutoDescription] 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. + * 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 confidence(confidence: JsonField) = apply { this.confidence = confidence } + fun aiAutoDescription(aiAutoDescription: JsonField) = apply { + this.aiAutoDescription = aiAutoDescription + } - /** Name of the tag. */ - fun name(name: String) = name(JsonField.of(name)) + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = + awsAutoTagging(JsonField.of(awsAutoTagging)) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.awsAutoTagging] to an arbitrary JSON value. * - * You should usually call [Builder.name] 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.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 name(name: JsonField) = apply { this.name = name } + fun awsAutoTagging(awsAutoTagging: JsonField) = apply { + this.awsAutoTagging = awsAutoTagging + } + + fun googleAutoTagging(googleAutoTagging: GoogleAutoTagging) = + googleAutoTagging(JsonField.of(googleAutoTagging)) /** - * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + * 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 source(source: String) = source(JsonField.of(source)) + fun googleAutoTagging(googleAutoTagging: JsonField) = apply { + this.googleAutoTagging = googleAutoTagging + } + + fun removeBg(removeBg: RemoveBg) = removeBg(JsonField.of(removeBg)) /** - * Sets [Builder.source] to an arbitrary JSON value. + * Sets [Builder.removeBg] 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 + * 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 source(source: JsonField) = apply { this.source = source } + fun removeBg(removeBg: JsonField) = apply { this.removeBg = removeBg } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1123,24 +1194,31 @@ private constructor( } /** - * Returns an immutable instance of [AiTag]. + * Returns an immutable instance of [ExtensionStatus]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): AiTag = - AiTag(confidence, name, source, additionalProperties.toMutableMap()) + fun build(): ExtensionStatus = + ExtensionStatus( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): AiTag = apply { + fun validate(): ExtensionStatus = apply { if (validated) { return@apply } - confidence() - name() - source() + aiAutoDescription().ifPresent { it.validate() } + awsAutoTagging().ifPresent { it.validate() } + googleAutoTagging().ifPresent { it.validate() } + removeBg().ifPresent { it.validate() } validated = true } @@ -1160,402 +1238,34 @@ private constructor( */ @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 - ) { + (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + class AiAutoDescription + @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 { + companion object { - /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ - @JvmStatic fun builder() = Builder() - } + @JvmField val SUCCESS = of("success") - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { + @JvmField val PENDING = of("pending") - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val FAILED = of("failed") - @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}" - } - - 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)) + @JvmStatic fun of(value: String) = AiAutoDescription(JsonField.of(value)) } /** An enum containing [AiAutoDescription]'s known values. */ @@ -2114,310 +1824,6 @@ private constructor( "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, 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 @@ -2428,7 +1834,6 @@ private constructor( createdAt == other.createdAt && customCoordinates == other.customCoordinates && customMetadata == other.customMetadata && - extensionStatus == other.extensionStatus && fileId == other.fileId && filePath == other.filePath && fileType == other.fileType && @@ -2446,6 +1851,7 @@ private constructor( url == other.url && versionInfo == other.versionInfo && width == other.width && + extensionStatus == other.extensionStatus && additionalProperties == other.additionalProperties } @@ -2455,7 +1861,6 @@ private constructor( createdAt, customCoordinates, customMetadata, - extensionStatus, fileId, filePath, fileType, @@ -2473,6 +1878,7 @@ private constructor( url, versionInfo, width, + extensionStatus, additionalProperties, ) } @@ -2480,5 +1886,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, extensionStatus=$extensionStatus, 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}" + "FileUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/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/versions/VersionGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt deleted file mode 100644 index 0f87292d..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetResponse.kt +++ /dev/null @@ -1,1615 +0,0 @@ -// 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.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 VersionGetResponse -private constructor( - private val aiTags: JsonField>, - private val createdAt: JsonField, - private val customCoordinates: JsonField, - private val customMetadata: 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("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, - 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") - - /** - * 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 [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 [VersionGetResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VersionGetResponse]. */ - 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 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(versionGetResponse: VersionGetResponse) = apply { - aiTags = versionGetResponse.aiTags.map { it.toMutableList() } - createdAt = versionGetResponse.createdAt - customCoordinates = versionGetResponse.customCoordinates - customMetadata = versionGetResponse.customMetadata - fileId = versionGetResponse.fileId - filePath = versionGetResponse.filePath - fileType = versionGetResponse.fileType - hasAlpha = versionGetResponse.hasAlpha - height = versionGetResponse.height - isPrivateFile = versionGetResponse.isPrivateFile - isPublished = versionGetResponse.isPublished - mime = versionGetResponse.mime - name = versionGetResponse.name - size = versionGetResponse.size - tags = versionGetResponse.tags.map { it.toMutableList() } - thumbnail = versionGetResponse.thumbnail - type = versionGetResponse.type - updatedAt = versionGetResponse.updatedAt - url = versionGetResponse.url - versionInfo = versionGetResponse.versionInfo - width = versionGetResponse.width - additionalProperties = versionGetResponse.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 - } - - /** 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 [VersionGetResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VersionGetResponse = - VersionGetResponse( - (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, - createdAt, - customCoordinates, - customMetadata, - 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(): VersionGetResponse = apply { - if (validated) { - return@apply - } - - aiTags().ifPresent { it.forEach { it.validate() } } - createdAt() - customCoordinates() - customMetadata().ifPresent { it.validate() } - 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 (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 VersionGetResponse && - aiTags == other.aiTags && - createdAt == other.createdAt && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - 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, - 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() = - "VersionGetResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/versions/VersionListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt deleted file mode 100644 index 30f29846..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListResponse.kt +++ /dev/null @@ -1,1615 +0,0 @@ -// 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.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 VersionListResponse -private constructor( - private val aiTags: JsonField>, - private val createdAt: JsonField, - private val customCoordinates: JsonField, - private val customMetadata: 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("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, - 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") - - /** - * 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 [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 [VersionListResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VersionListResponse]. */ - 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 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(versionListResponse: VersionListResponse) = apply { - aiTags = versionListResponse.aiTags.map { it.toMutableList() } - createdAt = versionListResponse.createdAt - customCoordinates = versionListResponse.customCoordinates - customMetadata = versionListResponse.customMetadata - fileId = versionListResponse.fileId - filePath = versionListResponse.filePath - fileType = versionListResponse.fileType - hasAlpha = versionListResponse.hasAlpha - height = versionListResponse.height - isPrivateFile = versionListResponse.isPrivateFile - isPublished = versionListResponse.isPublished - mime = versionListResponse.mime - name = versionListResponse.name - size = versionListResponse.size - tags = versionListResponse.tags.map { it.toMutableList() } - thumbnail = versionListResponse.thumbnail - type = versionListResponse.type - updatedAt = versionListResponse.updatedAt - url = versionListResponse.url - versionInfo = versionListResponse.versionInfo - width = versionListResponse.width - additionalProperties = versionListResponse.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 - } - - /** 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 [VersionListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VersionListResponse = - VersionListResponse( - (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, - createdAt, - customCoordinates, - customMetadata, - 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(): VersionListResponse = apply { - if (validated) { - return@apply - } - - aiTags().ifPresent { it.forEach { it.validate() } } - createdAt() - customCoordinates() - customMetadata().ifPresent { it.validate() } - 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 (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 VersionListResponse && - aiTags == other.aiTags && - createdAt == other.createdAt && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - 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, - 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() = - "VersionListResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/versions/VersionRestoreResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt deleted file mode 100644 index 738918ca..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponse.kt +++ /dev/null @@ -1,1615 +0,0 @@ -// 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.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 VersionRestoreResponse -private constructor( - private val aiTags: JsonField>, - private val createdAt: JsonField, - private val customCoordinates: JsonField, - private val customMetadata: 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("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, - 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") - - /** - * 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 [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 [VersionRestoreResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VersionRestoreResponse]. */ - 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 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(versionRestoreResponse: VersionRestoreResponse) = apply { - aiTags = versionRestoreResponse.aiTags.map { it.toMutableList() } - createdAt = versionRestoreResponse.createdAt - customCoordinates = versionRestoreResponse.customCoordinates - customMetadata = versionRestoreResponse.customMetadata - fileId = versionRestoreResponse.fileId - filePath = versionRestoreResponse.filePath - fileType = versionRestoreResponse.fileType - hasAlpha = versionRestoreResponse.hasAlpha - height = versionRestoreResponse.height - isPrivateFile = versionRestoreResponse.isPrivateFile - isPublished = versionRestoreResponse.isPublished - mime = versionRestoreResponse.mime - name = versionRestoreResponse.name - size = versionRestoreResponse.size - tags = versionRestoreResponse.tags.map { it.toMutableList() } - thumbnail = versionRestoreResponse.thumbnail - type = versionRestoreResponse.type - updatedAt = versionRestoreResponse.updatedAt - url = versionRestoreResponse.url - versionInfo = versionRestoreResponse.versionInfo - width = versionRestoreResponse.width - additionalProperties = versionRestoreResponse.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 - } - - /** 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 [VersionRestoreResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VersionRestoreResponse = - VersionRestoreResponse( - (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, - createdAt, - customCoordinates, - customMetadata, - 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(): VersionRestoreResponse = apply { - if (validated) { - return@apply - } - - aiTags().ifPresent { it.forEach { it.validate() } } - createdAt() - customCoordinates() - customMetadata().ifPresent { it.validate() } - 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 (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 VersionRestoreResponse && - aiTags == other.aiTags && - createdAt == other.createdAt && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - 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, - 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() = - "VersionRestoreResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index c0bc8bf4..3695f29f 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 @@ -6,11 +6,11 @@ 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.FileGetResponse import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileMoveResponse import com.imagekit.api.models.files.FileRenameParams @@ -139,34 +139,30 @@ interface FileServiceAsync { /** * 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()) + 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) + ): CompletableFuture = get(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see get */ - fun get( - fileId: String, - params: FileGetParams = FileGetParams.none(), - ): CompletableFuture = get(fileId, params, RequestOptions.none()) + 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 + ): CompletableFuture /** @see get */ - fun get(params: FileGetParams): CompletableFuture = - get(params, RequestOptions.none()) + fun get(params: FileGetParams): CompletableFuture = get(params, RequestOptions.none()) /** @see get */ - fun get(fileId: String, requestOptions: RequestOptions): CompletableFuture = + fun get(fileId: String, requestOptions: RequestOptions): CompletableFuture = get(fileId, FileGetParams.none(), requestOptions) /** @@ -344,7 +340,7 @@ interface FileServiceAsync { * Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the * same as [FileServiceAsync.get]. */ - fun get(fileId: String): CompletableFuture> = + fun get(fileId: String): CompletableFuture> = get(fileId, FileGetParams.none()) /** @see get */ @@ -352,31 +348,30 @@ interface FileServiceAsync { fileId: String, params: FileGetParams = FileGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see get */ fun get( fileId: String, params: FileGetParams = FileGetParams.none(), - ): CompletableFuture> = - get(fileId, params, RequestOptions.none()) + ): CompletableFuture> = get(fileId, params, RequestOptions.none()) /** @see get */ fun get( params: FileGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see get */ - fun get(params: FileGetParams): CompletableFuture> = + fun get(params: FileGetParams): CompletableFuture> = get(params, RequestOptions.none()) /** @see get */ fun get( fileId: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = get(fileId, FileGetParams.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 31626710..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 @@ -18,11 +18,11 @@ 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.FileGetResponse import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileMoveResponse import com.imagekit.api.models.files.FileRenameParams @@ -89,7 +89,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun get( params: FileGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/files/{fileId}/details withRawResponse().get(params, requestOptions).thenApply { it.parse() } @@ -237,13 +237,12 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun get( params: FileGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fileId", params.fileId().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/com/imagekit/api/services/async/files/VersionServiceAsync.kt index a758ec66..62bdd118 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/com/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -5,14 +5,12 @@ 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.VersionGetResponse import com.imagekit.api.models.files.versions.VersionListParams -import com.imagekit.api.models.files.versions.VersionListResponse import com.imagekit.api.models.files.versions.VersionRestoreParams -import com.imagekit.api.models.files.versions.VersionRestoreResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -31,38 +29,34 @@ interface VersionServiceAsync { fun withOptions(modifier: Consumer): VersionServiceAsync /** This API returns details of all versions of a file. */ - fun list(fileId: String): CompletableFuture> = - list(fileId, VersionListParams.none()) + fun list(fileId: String): CompletableFuture> = list(fileId, VersionListParams.none()) /** @see list */ fun list( fileId: String, params: VersionListParams = VersionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = list(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see list */ fun list( fileId: String, params: VersionListParams = VersionListParams.none(), - ): CompletableFuture> = list(fileId, params, RequestOptions.none()) + ): CompletableFuture> = list(fileId, params, RequestOptions.none()) /** @see list */ fun list( params: VersionListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see list */ - fun list(params: VersionListParams): CompletableFuture> = + fun list(params: VersionListParams): CompletableFuture> = list(params, RequestOptions.none()) /** @see list */ - fun list( - fileId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = + fun list(fileId: String, requestOptions: RequestOptions): CompletableFuture> = list(fileId, VersionListParams.none(), requestOptions) /** @@ -94,7 +88,7 @@ interface VersionServiceAsync { ): CompletableFuture /** This API returns an object with details or attributes of a file version. */ - fun get(versionId: String, params: VersionGetParams): CompletableFuture = + fun get(versionId: String, params: VersionGetParams): CompletableFuture = get(versionId, params, RequestOptions.none()) /** @see get */ @@ -102,42 +96,39 @@ interface VersionServiceAsync { versionId: String, params: VersionGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = get(params.toBuilder().versionId(versionId).build(), requestOptions) /** @see get */ - fun get(params: VersionGetParams): CompletableFuture = - get(params, RequestOptions.none()) + fun get(params: VersionGetParams): CompletableFuture = get(params, RequestOptions.none()) /** @see get */ fun get( params: VersionGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** This API restores a file version as the current file version. */ - fun restore( - versionId: String, - params: VersionRestoreParams, - ): CompletableFuture = restore(versionId, params, RequestOptions.none()) + 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 = + ): CompletableFuture = restore(params.toBuilder().versionId(versionId).build(), requestOptions) /** @see restore */ - fun restore(params: VersionRestoreParams): CompletableFuture = + fun restore(params: VersionRestoreParams): CompletableFuture = restore(params, RequestOptions.none()) /** @see restore */ fun restore( params: VersionRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [VersionServiceAsync] that provides access to raw HTTP responses for each method. @@ -157,7 +148,7 @@ interface VersionServiceAsync { * Returns a raw HTTP response for `get /v1/files/{fileId}/versions`, but is otherwise the * same as [VersionServiceAsync.list]. */ - fun list(fileId: String): CompletableFuture>> = + fun list(fileId: String): CompletableFuture>> = list(fileId, VersionListParams.none()) /** @see list */ @@ -165,33 +156,31 @@ interface VersionServiceAsync { fileId: String, params: VersionListParams = VersionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> = + ): CompletableFuture>> = list(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see list */ fun list( fileId: String, params: VersionListParams = VersionListParams.none(), - ): CompletableFuture>> = + ): CompletableFuture>> = list(fileId, params, RequestOptions.none()) /** @see list */ fun list( params: VersionListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + ): CompletableFuture>> /** @see list */ - fun list( - params: VersionListParams - ): CompletableFuture>> = + fun list(params: VersionListParams): CompletableFuture>> = list(params, RequestOptions.none()) /** @see list */ fun list( fileId: String, requestOptions: RequestOptions, - ): CompletableFuture>> = + ): CompletableFuture>> = list(fileId, VersionListParams.none(), requestOptions) /** @@ -231,26 +220,25 @@ interface VersionServiceAsync { fun get( versionId: String, params: VersionGetParams, - ): CompletableFuture> = - get(versionId, params, RequestOptions.none()) + ): CompletableFuture> = get(versionId, params, RequestOptions.none()) /** @see get */ fun get( versionId: String, params: VersionGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(params.toBuilder().versionId(versionId).build(), requestOptions) /** @see get */ - fun get(params: VersionGetParams): CompletableFuture> = + fun get(params: VersionGetParams): CompletableFuture> = get(params, RequestOptions.none()) /** @see get */ fun get( params: VersionGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/files/{fileId}/versions/{versionId}/restore`, @@ -259,7 +247,7 @@ interface VersionServiceAsync { fun restore( versionId: String, params: VersionRestoreParams, - ): CompletableFuture> = + ): CompletableFuture> = restore(versionId, params, RequestOptions.none()) /** @see restore */ @@ -267,19 +255,17 @@ interface VersionServiceAsync { versionId: String, params: VersionRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = restore(params.toBuilder().versionId(versionId).build(), requestOptions) /** @see restore */ - fun restore( - params: VersionRestoreParams - ): CompletableFuture> = + fun restore(params: VersionRestoreParams): CompletableFuture> = restore(params, RequestOptions.none()) /** @see restore */ fun restore( params: VersionRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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 index 31a75208..c601ebe2 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/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -16,14 +16,12 @@ 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.VersionGetResponse import com.imagekit.api.models.files.versions.VersionListParams -import com.imagekit.api.models.files.versions.VersionListResponse import com.imagekit.api.models.files.versions.VersionRestoreParams -import com.imagekit.api.models.files.versions.VersionRestoreResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -43,7 +41,7 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun list( params: VersionListParams, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = // get /v1/files/{fileId}/versions withRawResponse().list(params, requestOptions).thenApply { it.parse() } @@ -57,14 +55,14 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun get( params: VersionGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/files/{fileId}/versions/{versionId} withRawResponse().get(params, requestOptions).thenApply { it.parse() } override fun restore( params: VersionRestoreParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // put /v1/files/{fileId}/versions/{versionId}/restore withRawResponse().restore(params, requestOptions).thenApply { it.parse() } @@ -81,13 +79,13 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl clientOptions.toBuilder().apply(modifier::accept).build() ) - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: VersionListParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture>> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fileId", params.fileId().getOrNull()) @@ -154,13 +152,12 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun get( params: VersionGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("versionId", params.versionId().getOrNull()) @@ -193,13 +190,12 @@ class VersionServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val restoreHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val restoreHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun restore( params: VersionRestoreParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("versionId", params.versionId().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/com/imagekit/api/services/blocking/FileService.kt index d4b2ff80..0aba8894 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 @@ -7,11 +7,11 @@ 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.FileGetResponse import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileMoveResponse import com.imagekit.api.models.files.FileRenameParams @@ -126,30 +126,27 @@ interface FileService { /** * This API returns an object with details or attributes about the current version of the file. */ - fun get(fileId: String): FileGetResponse = get(fileId, FileGetParams.none()) + fun get(fileId: String): File = get(fileId, FileGetParams.none()) /** @see get */ fun get( fileId: String, params: FileGetParams = FileGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): FileGetResponse = get(params.toBuilder().fileId(fileId).build(), requestOptions) + ): File = get(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see get */ - fun get(fileId: String, params: FileGetParams = FileGetParams.none()): FileGetResponse = + fun get(fileId: String, params: FileGetParams = FileGetParams.none()): File = get(fileId, params, RequestOptions.none()) /** @see get */ - fun get( - params: FileGetParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FileGetResponse + fun get(params: FileGetParams, requestOptions: RequestOptions = RequestOptions.none()): File /** @see get */ - fun get(params: FileGetParams): FileGetResponse = get(params, RequestOptions.none()) + fun get(params: FileGetParams): File = get(params, RequestOptions.none()) /** @see get */ - fun get(fileId: String, requestOptions: RequestOptions): FileGetResponse = + fun get(fileId: String, requestOptions: RequestOptions): File = get(fileId, FileGetParams.none(), requestOptions) /** @@ -331,8 +328,7 @@ interface FileService { * same as [FileService.get]. */ @MustBeClosed - fun get(fileId: String): HttpResponseFor = - get(fileId, FileGetParams.none()) + fun get(fileId: String): HttpResponseFor = get(fileId, FileGetParams.none()) /** @see get */ @MustBeClosed @@ -340,31 +336,29 @@ interface FileService { fileId: String, params: FileGetParams = FileGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - get(params.toBuilder().fileId(fileId).build(), requestOptions) + ): 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()) + ): HttpResponseFor = get(fileId, params, RequestOptions.none()) /** @see get */ @MustBeClosed fun get( params: FileGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see get */ @MustBeClosed - fun get(params: FileGetParams): HttpResponseFor = - get(params, RequestOptions.none()) + fun get(params: FileGetParams): HttpResponseFor = get(params, RequestOptions.none()) /** @see get */ @MustBeClosed - fun get(fileId: String, requestOptions: RequestOptions): HttpResponseFor = + fun get(fileId: String, requestOptions: RequestOptions): HttpResponseFor = get(fileId, FileGetParams.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 80924dcf..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 @@ -18,11 +18,11 @@ 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.FileGetResponse import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileMoveResponse import com.imagekit.api.models.files.FileRenameParams @@ -79,7 +79,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti // post /v1/files/copy withRawResponse().copy(params, requestOptions).parse() - override fun get(params: FileGetParams, requestOptions: RequestOptions): FileGetResponse = + override fun get(params: FileGetParams, requestOptions: RequestOptions): File = // get /v1/files/{fileId}/details withRawResponse().get(params, requestOptions).parse() @@ -215,13 +215,12 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun get( params: FileGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fileId", params.fileId().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/com/imagekit/api/services/blocking/files/VersionService.kt index 9ce3b6c4..eb1195eb 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/com/imagekit/api/services/blocking/files/VersionService.kt @@ -6,14 +6,12 @@ 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.VersionGetResponse import com.imagekit.api.models.files.versions.VersionListParams -import com.imagekit.api.models.files.versions.VersionListResponse import com.imagekit.api.models.files.versions.VersionRestoreParams -import com.imagekit.api.models.files.versions.VersionRestoreResponse import java.util.function.Consumer interface VersionService { @@ -31,33 +29,30 @@ interface VersionService { fun withOptions(modifier: Consumer): VersionService /** This API returns details of all versions of a file. */ - fun list(fileId: String): List = list(fileId, VersionListParams.none()) + 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) + ): List = list(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see list */ - fun list( - fileId: String, - params: VersionListParams = VersionListParams.none(), - ): List = list(fileId, params, RequestOptions.none()) + 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 + ): List /** @see list */ - fun list(params: VersionListParams): List = - list(params, RequestOptions.none()) + fun list(params: VersionListParams): List = list(params, RequestOptions.none()) /** @see list */ - fun list(fileId: String, requestOptions: RequestOptions): List = + fun list(fileId: String, requestOptions: RequestOptions): List = list(fileId, VersionListParams.none(), requestOptions) /** @@ -87,7 +82,7 @@ interface VersionService { ): VersionDeleteResponse /** This API returns an object with details or attributes of a file version. */ - fun get(versionId: String, params: VersionGetParams): VersionGetResponse = + fun get(versionId: String, params: VersionGetParams): File = get(versionId, params, RequestOptions.none()) /** @see get */ @@ -95,19 +90,16 @@ interface VersionService { versionId: String, params: VersionGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): VersionGetResponse = get(params.toBuilder().versionId(versionId).build(), requestOptions) + ): File = get(params.toBuilder().versionId(versionId).build(), requestOptions) /** @see get */ - fun get(params: VersionGetParams): VersionGetResponse = get(params, RequestOptions.none()) + fun get(params: VersionGetParams): File = get(params, RequestOptions.none()) /** @see get */ - fun get( - params: VersionGetParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): VersionGetResponse + 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): VersionRestoreResponse = + fun restore(versionId: String, params: VersionRestoreParams): File = restore(versionId, params, RequestOptions.none()) /** @see restore */ @@ -115,18 +107,16 @@ interface VersionService { versionId: String, params: VersionRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), - ): VersionRestoreResponse = - restore(params.toBuilder().versionId(versionId).build(), requestOptions) + ): File = restore(params.toBuilder().versionId(versionId).build(), requestOptions) /** @see restore */ - fun restore(params: VersionRestoreParams): VersionRestoreResponse = - restore(params, RequestOptions.none()) + fun restore(params: VersionRestoreParams): File = restore(params, RequestOptions.none()) /** @see restore */ fun restore( params: VersionRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), - ): VersionRestoreResponse + ): File /** A view of [VersionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -143,7 +133,7 @@ interface VersionService { * same as [VersionService.list]. */ @MustBeClosed - fun list(fileId: String): HttpResponseFor> = + fun list(fileId: String): HttpResponseFor> = list(fileId, VersionListParams.none()) /** @see list */ @@ -152,7 +142,7 @@ interface VersionService { fileId: String, params: VersionListParams = VersionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> = + ): HttpResponseFor> = list(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see list */ @@ -160,26 +150,23 @@ interface VersionService { fun list( fileId: String, params: VersionListParams = VersionListParams.none(), - ): HttpResponseFor> = list(fileId, params, RequestOptions.none()) + ): HttpResponseFor> = list(fileId, params, RequestOptions.none()) /** @see list */ @MustBeClosed fun list( params: VersionListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + ): HttpResponseFor> /** @see list */ @MustBeClosed - fun list(params: VersionListParams): HttpResponseFor> = + fun list(params: VersionListParams): HttpResponseFor> = list(params, RequestOptions.none()) /** @see list */ @MustBeClosed - fun list( - fileId: String, - requestOptions: RequestOptions, - ): HttpResponseFor> = + fun list(fileId: String, requestOptions: RequestOptions): HttpResponseFor> = list(fileId, VersionListParams.none(), requestOptions) /** @@ -218,7 +205,7 @@ interface VersionService { * otherwise the same as [VersionService.get]. */ @MustBeClosed - fun get(versionId: String, params: VersionGetParams): HttpResponseFor = + fun get(versionId: String, params: VersionGetParams): HttpResponseFor = get(versionId, params, RequestOptions.none()) /** @see get */ @@ -227,12 +214,12 @@ interface VersionService { versionId: String, params: VersionGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = get(params.toBuilder().versionId(versionId).build(), requestOptions) /** @see get */ @MustBeClosed - fun get(params: VersionGetParams): HttpResponseFor = + fun get(params: VersionGetParams): HttpResponseFor = get(params, RequestOptions.none()) /** @see get */ @@ -240,17 +227,14 @@ interface VersionService { fun get( params: VersionGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun restore(versionId: String, params: VersionRestoreParams): HttpResponseFor = restore(versionId, params, RequestOptions.none()) /** @see restore */ @@ -259,12 +243,12 @@ interface VersionService { versionId: String, params: VersionRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = restore(params.toBuilder().versionId(versionId).build(), requestOptions) /** @see restore */ @MustBeClosed - fun restore(params: VersionRestoreParams): HttpResponseFor = + fun restore(params: VersionRestoreParams): HttpResponseFor = restore(params, RequestOptions.none()) /** @see restore */ @@ -272,6 +256,6 @@ interface VersionService { fun restore( params: VersionRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 index 73ddc647..2637882f 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/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -16,14 +16,12 @@ 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.VersionGetResponse import com.imagekit.api.models.files.versions.VersionListParams -import com.imagekit.api.models.files.versions.VersionListResponse import com.imagekit.api.models.files.versions.VersionRestoreParams -import com.imagekit.api.models.files.versions.VersionRestoreResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -39,10 +37,7 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO override fun withOptions(modifier: Consumer): VersionService = VersionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun list( - params: VersionListParams, - requestOptions: RequestOptions, - ): List = + override fun list(params: VersionListParams, requestOptions: RequestOptions): List = // get /v1/files/{fileId}/versions withRawResponse().list(params, requestOptions).parse() @@ -53,14 +48,11 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO // delete /v1/files/{fileId}/versions/{versionId} withRawResponse().delete(params, requestOptions).parse() - override fun get(params: VersionGetParams, requestOptions: RequestOptions): VersionGetResponse = + 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, - ): VersionRestoreResponse = + override fun restore(params: VersionRestoreParams, requestOptions: RequestOptions): File = // put /v1/files/{fileId}/versions/{versionId}/restore withRawResponse().restore(params, requestOptions).parse() @@ -77,13 +69,13 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO clientOptions.toBuilder().apply(modifier::accept).build() ) - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: VersionListParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fileId", params.fileId().getOrNull()) @@ -144,13 +136,12 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun get( params: VersionGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("versionId", params.versionId().getOrNull()) @@ -180,13 +171,12 @@ class VersionServiceImpl internal constructor(private val clientOptions: ClientO } } - private val restoreHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val restoreHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun restore( params: VersionRestoreParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("versionId", params.versionId().getOrNull()) 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 83382614..309be429 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,8 @@ 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 @@ -16,20 +18,16 @@ import org.junit.jupiter.params.provider.EnumSource internal class AssetListResponseTest { @Test - fun ofFileDetails() { - val fileDetails = - AssetListResponse.FileDetails.builder() + fun ofFile() { + val file = + File.builder() .addAiTag( - AssetListResponse.FileDetails.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - AssetListResponse.FileDetails.CustomMetadata.builder() + File.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -45,41 +43,32 @@ internal class AssetListResponseTest { .size(0.0) .addTag("string") .thumbnail("https://example.com") - .type(AssetListResponse.FileDetails.Type.FILE) + .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo( - AssetListResponse.FileDetails.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() - val assetListResponse = AssetListResponse.ofFileDetails(fileDetails) + val assetListResponse = AssetListResponse.ofFile(file) - assertThat(assetListResponse.fileDetails()).contains(fileDetails) + assertThat(assetListResponse.file()).contains(file) assertThat(assetListResponse.folder()).isEmpty } @Test - fun ofFileDetailsRoundtrip() { + fun ofFileRoundtrip() { val jsonMapper = jsonMapper() val assetListResponse = - AssetListResponse.ofFileDetails( - AssetListResponse.FileDetails.builder() + AssetListResponse.ofFile( + File.builder() .addAiTag( - AssetListResponse.FileDetails.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - AssetListResponse.FileDetails.CustomMetadata.builder() + File.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -95,15 +84,10 @@ internal class AssetListResponseTest { .size(0.0) .addTag("string") .thumbnail("https://example.com") - .type(AssetListResponse.FileDetails.Type.FILE) + .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo( - AssetListResponse.FileDetails.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() ) @@ -120,18 +104,18 @@ internal class AssetListResponseTest { @Test fun ofFolder() { val folder = - AssetListResponse.Folder.builder() + Folder.builder() .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .folderId("folderId") .folderPath("folderPath") .name("name") - .type(AssetListResponse.Folder.Type.FOLDER) + .type(Folder.Type.FOLDER) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() val assetListResponse = AssetListResponse.ofFolder(folder) - assertThat(assetListResponse.fileDetails()).isEmpty + assertThat(assetListResponse.file()).isEmpty assertThat(assetListResponse.folder()).contains(folder) } @@ -140,12 +124,12 @@ internal class AssetListResponseTest { val jsonMapper = jsonMapper() val assetListResponse = AssetListResponse.ofFolder( - AssetListResponse.Folder.builder() + Folder.builder() .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .folderId("folderId") .folderPath("folderPath") .name("name") - .type(AssetListResponse.Folder.Type.FOLDER) + .type(Folder.Type.FOLDER) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt deleted file mode 100644 index 99dd1389..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetResponseTest.kt +++ /dev/null @@ -1,136 +0,0 @@ -// 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 FileGetResponseTest { - - @Test - fun create() { - val fileGetResponse = - FileGetResponse.builder() - .addAiTag( - FileGetResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customCoordinates("customCoordinates") - .customMetadata( - FileGetResponse.CustomMetadata.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") - .size(0.0) - .addTag("string") - .thumbnail("https://example.com") - .type(FileGetResponse.Type.FILE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .url("https://example.com") - .versionInfo(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) - .width(0.0) - .build() - - assertThat(fileGetResponse.aiTags().getOrNull()) - .containsExactly( - FileGetResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - assertThat(fileGetResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(fileGetResponse.customCoordinates()).contains("customCoordinates") - assertThat(fileGetResponse.customMetadata()) - .contains( - FileGetResponse.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(fileGetResponse.fileId()).contains("fileId") - assertThat(fileGetResponse.filePath()).contains("filePath") - assertThat(fileGetResponse.fileType()).contains("fileType") - assertThat(fileGetResponse.hasAlpha()).contains(true) - assertThat(fileGetResponse.height()).contains(0.0) - assertThat(fileGetResponse.isPrivateFile()).contains(true) - assertThat(fileGetResponse.isPublished()).contains(true) - assertThat(fileGetResponse.mime()).contains("mime") - assertThat(fileGetResponse.name()).contains("name") - assertThat(fileGetResponse.size()).contains(0.0) - assertThat(fileGetResponse.tags().getOrNull()).containsExactly("string") - assertThat(fileGetResponse.thumbnail()).contains("https://example.com") - assertThat(fileGetResponse.type()).contains(FileGetResponse.Type.FILE) - assertThat(fileGetResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(fileGetResponse.url()).contains("https://example.com") - assertThat(fileGetResponse.versionInfo()) - .contains(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) - assertThat(fileGetResponse.width()).contains(0.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val fileGetResponse = - FileGetResponse.builder() - .addAiTag( - FileGetResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customCoordinates("customCoordinates") - .customMetadata( - FileGetResponse.CustomMetadata.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") - .size(0.0) - .addTag("string") - .thumbnail("https://example.com") - .type(FileGetResponse.Type.FILE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .url("https://example.com") - .versionInfo(FileGetResponse.VersionInfo.builder().id("id").name("name").build()) - .width(0.0) - .build() - - val roundtrippedFileGetResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fileGetResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFileGetResponse).isEqualTo(fileGetResponse) - } -} 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..744e6ec1 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt @@ -0,0 +1,119 @@ +// 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() + ) + .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.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() + ) + .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/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index 34f030a6..28d9d15c 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 @@ -17,31 +17,15 @@ internal class FileUpdateResponseTest { val fileUpdateResponse = FileUpdateResponse.builder() .addAiTag( - FileUpdateResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - FileUpdateResponse.CustomMetadata.builder() + File.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .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() - ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -54,39 +38,38 @@ internal class FileUpdateResponseTest { .size(0.0) .addTag("string") .thumbnail("https://example.com") - .type(FileUpdateResponse.Type.FILE) + .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + .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( - FileUpdateResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + 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( - FileUpdateResponse.CustomMetadata.builder() + File.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - 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() - ) assertThat(fileUpdateResponse.fileId()).contains("fileId") assertThat(fileUpdateResponse.filePath()).contains("filePath") assertThat(fileUpdateResponse.fileType()).contains("fileType") @@ -99,13 +82,22 @@ internal class FileUpdateResponseTest { assertThat(fileUpdateResponse.size()).contains(0.0) assertThat(fileUpdateResponse.tags().getOrNull()).containsExactly("string") assertThat(fileUpdateResponse.thumbnail()).contains("https://example.com") - assertThat(fileUpdateResponse.type()).contains(FileUpdateResponse.Type.FILE) + 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(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + .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 @@ -114,31 +106,15 @@ internal class FileUpdateResponseTest { val fileUpdateResponse = FileUpdateResponse.builder() .addAiTag( - FileUpdateResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - FileUpdateResponse.CustomMetadata.builder() + File.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .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() - ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -151,11 +127,23 @@ internal class FileUpdateResponseTest { .size(0.0) .addTag("string") .thumbnail("https://example.com") - .type(FileUpdateResponse.Type.FILE) + .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + .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 = 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/versions/VersionGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt deleted file mode 100644 index c8c3e167..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetResponseTest.kt +++ /dev/null @@ -1,136 +0,0 @@ -// 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.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 VersionGetResponseTest { - - @Test - fun create() { - val versionGetResponse = - VersionGetResponse.builder() - .addAiTag( - VersionGetResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customCoordinates("customCoordinates") - .customMetadata( - VersionGetResponse.CustomMetadata.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") - .size(0.0) - .addTag("string") - .thumbnail("https://example.com") - .type(VersionGetResponse.Type.FILE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .url("https://example.com") - .versionInfo(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) - .width(0.0) - .build() - - assertThat(versionGetResponse.aiTags().getOrNull()) - .containsExactly( - VersionGetResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - assertThat(versionGetResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(versionGetResponse.customCoordinates()).contains("customCoordinates") - assertThat(versionGetResponse.customMetadata()) - .contains( - VersionGetResponse.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(versionGetResponse.fileId()).contains("fileId") - assertThat(versionGetResponse.filePath()).contains("filePath") - assertThat(versionGetResponse.fileType()).contains("fileType") - assertThat(versionGetResponse.hasAlpha()).contains(true) - assertThat(versionGetResponse.height()).contains(0.0) - assertThat(versionGetResponse.isPrivateFile()).contains(true) - assertThat(versionGetResponse.isPublished()).contains(true) - assertThat(versionGetResponse.mime()).contains("mime") - assertThat(versionGetResponse.name()).contains("name") - assertThat(versionGetResponse.size()).contains(0.0) - assertThat(versionGetResponse.tags().getOrNull()).containsExactly("string") - assertThat(versionGetResponse.thumbnail()).contains("https://example.com") - assertThat(versionGetResponse.type()).contains(VersionGetResponse.Type.FILE) - assertThat(versionGetResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(versionGetResponse.url()).contains("https://example.com") - assertThat(versionGetResponse.versionInfo()) - .contains(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) - assertThat(versionGetResponse.width()).contains(0.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val versionGetResponse = - VersionGetResponse.builder() - .addAiTag( - VersionGetResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customCoordinates("customCoordinates") - .customMetadata( - VersionGetResponse.CustomMetadata.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") - .size(0.0) - .addTag("string") - .thumbnail("https://example.com") - .type(VersionGetResponse.Type.FILE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .url("https://example.com") - .versionInfo(VersionGetResponse.VersionInfo.builder().id("id").name("name").build()) - .width(0.0) - .build() - - val roundtrippedVersionGetResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(versionGetResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedVersionGetResponse).isEqualTo(versionGetResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt deleted file mode 100644 index cdcf0ad5..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListResponseTest.kt +++ /dev/null @@ -1,140 +0,0 @@ -// 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.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 VersionListResponseTest { - - @Test - fun create() { - val versionListResponse = - VersionListResponse.builder() - .addAiTag( - VersionListResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customCoordinates("customCoordinates") - .customMetadata( - VersionListResponse.CustomMetadata.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") - .size(0.0) - .addTag("string") - .thumbnail("https://example.com") - .type(VersionListResponse.Type.FILE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .url("https://example.com") - .versionInfo( - VersionListResponse.VersionInfo.builder().id("id").name("name").build() - ) - .width(0.0) - .build() - - assertThat(versionListResponse.aiTags().getOrNull()) - .containsExactly( - VersionListResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - assertThat(versionListResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(versionListResponse.customCoordinates()).contains("customCoordinates") - assertThat(versionListResponse.customMetadata()) - .contains( - VersionListResponse.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(versionListResponse.fileId()).contains("fileId") - assertThat(versionListResponse.filePath()).contains("filePath") - assertThat(versionListResponse.fileType()).contains("fileType") - assertThat(versionListResponse.hasAlpha()).contains(true) - assertThat(versionListResponse.height()).contains(0.0) - assertThat(versionListResponse.isPrivateFile()).contains(true) - assertThat(versionListResponse.isPublished()).contains(true) - assertThat(versionListResponse.mime()).contains("mime") - assertThat(versionListResponse.name()).contains("name") - assertThat(versionListResponse.size()).contains(0.0) - assertThat(versionListResponse.tags().getOrNull()).containsExactly("string") - assertThat(versionListResponse.thumbnail()).contains("https://example.com") - assertThat(versionListResponse.type()).contains(VersionListResponse.Type.FILE) - assertThat(versionListResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(versionListResponse.url()).contains("https://example.com") - assertThat(versionListResponse.versionInfo()) - .contains(VersionListResponse.VersionInfo.builder().id("id").name("name").build()) - assertThat(versionListResponse.width()).contains(0.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val versionListResponse = - VersionListResponse.builder() - .addAiTag( - VersionListResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customCoordinates("customCoordinates") - .customMetadata( - VersionListResponse.CustomMetadata.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") - .size(0.0) - .addTag("string") - .thumbnail("https://example.com") - .type(VersionListResponse.Type.FILE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .url("https://example.com") - .versionInfo( - VersionListResponse.VersionInfo.builder().id("id").name("name").build() - ) - .width(0.0) - .build() - - val roundtrippedVersionListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(versionListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedVersionListResponse).isEqualTo(versionListResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt deleted file mode 100644 index 9601681f..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreResponseTest.kt +++ /dev/null @@ -1,188 +0,0 @@ -// 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.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 VersionRestoreResponseTest { - - @Test - fun create() { - val versionRestoreResponse = - VersionRestoreResponse.builder() - .addAiTag( - VersionRestoreResponse.AiTag.builder() - .confidence(90.12) - .name("Shirt") - .source("google-auto-tagging") - .build() - ) - .addAiTag( - VersionRestoreResponse.AiTag.builder() - .confidence(80.12) - .name("T-shirt") - .source("aws-auto-tagging") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) - .customCoordinates(null) - .customMetadata( - VersionRestoreResponse.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .fileId("598821f949c0a938d57563bd") - .filePath("/images/products/file.jpg") - .fileType("image") - .hasAlpha(false) - .height(100.0) - .isPrivateFile(false) - .isPublished(true) - .mime("image/jpeg") - .name("file.jpg") - .size(100.0) - .tags(listOf("t-shirt", "round-neck", "sale2019")) - .thumbnail( - "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" - ) - .type(VersionRestoreResponse.Type.FILE) - .updatedAt(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) - .url( - "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" - ) - .versionInfo( - VersionRestoreResponse.VersionInfo.builder() - .id("598821f949c0a938d57563bd") - .name("Version 2") - .build() - ) - .width(100.0) - .build() - - assertThat(versionRestoreResponse.aiTags().getOrNull()) - .containsExactly( - VersionRestoreResponse.AiTag.builder() - .confidence(90.12) - .name("Shirt") - .source("google-auto-tagging") - .build(), - VersionRestoreResponse.AiTag.builder() - .confidence(80.12) - .name("T-shirt") - .source("aws-auto-tagging") - .build(), - ) - assertThat(versionRestoreResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) - assertThat(versionRestoreResponse.customCoordinates()).isEmpty - assertThat(versionRestoreResponse.customMetadata()) - .contains( - VersionRestoreResponse.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - assertThat(versionRestoreResponse.fileId()).contains("598821f949c0a938d57563bd") - assertThat(versionRestoreResponse.filePath()).contains("/images/products/file.jpg") - assertThat(versionRestoreResponse.fileType()).contains("image") - assertThat(versionRestoreResponse.hasAlpha()).contains(false) - assertThat(versionRestoreResponse.height()).contains(100.0) - assertThat(versionRestoreResponse.isPrivateFile()).contains(false) - assertThat(versionRestoreResponse.isPublished()).contains(true) - assertThat(versionRestoreResponse.mime()).contains("image/jpeg") - assertThat(versionRestoreResponse.name()).contains("file.jpg") - assertThat(versionRestoreResponse.size()).contains(100.0) - assertThat(versionRestoreResponse.tags().getOrNull()) - .containsExactly("t-shirt", "round-neck", "sale2019") - assertThat(versionRestoreResponse.thumbnail()) - .contains( - "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" - ) - assertThat(versionRestoreResponse.type()).contains(VersionRestoreResponse.Type.FILE) - assertThat(versionRestoreResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) - assertThat(versionRestoreResponse.url()) - .contains( - "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" - ) - assertThat(versionRestoreResponse.versionInfo()) - .contains( - VersionRestoreResponse.VersionInfo.builder() - .id("598821f949c0a938d57563bd") - .name("Version 2") - .build() - ) - assertThat(versionRestoreResponse.width()).contains(100.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val versionRestoreResponse = - VersionRestoreResponse.builder() - .addAiTag( - VersionRestoreResponse.AiTag.builder() - .confidence(90.12) - .name("Shirt") - .source("google-auto-tagging") - .build() - ) - .addAiTag( - VersionRestoreResponse.AiTag.builder() - .confidence(80.12) - .name("T-shirt") - .source("aws-auto-tagging") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) - .customCoordinates(null) - .customMetadata( - VersionRestoreResponse.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .fileId("598821f949c0a938d57563bd") - .filePath("/images/products/file.jpg") - .fileType("image") - .hasAlpha(false) - .height(100.0) - .isPrivateFile(false) - .isPublished(true) - .mime("image/jpeg") - .name("file.jpg") - .size(100.0) - .tags(listOf("t-shirt", "round-neck", "sale2019")) - .thumbnail( - "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail" - ) - .type(VersionRestoreResponse.Type.FILE) - .updatedAt(OffsetDateTime.parse("2019-08-24T06:14:41.313Z")) - .url( - "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313" - ) - .versionInfo( - VersionRestoreResponse.VersionInfo.builder() - .id("598821f949c0a938d57563bd") - .name("Version 2") - .build() - ) - .width(100.0) - .build() - - val roundtrippedVersionRestoreResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(versionRestoreResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedVersionRestoreResponse).isEqualTo(versionRestoreResponse) - } -} 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 7e2882f8..afbefeb0 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 @@ -25,10 +25,10 @@ internal class VersionServiceAsyncTest { .build() val versionServiceAsync = client.files().versions() - val versionsFuture = versionServiceAsync.list("fileId") + val filesFuture = versionServiceAsync.list("fileId") - val versions = versionsFuture.get() - versions.forEach { it.validate() } + val files = filesFuture.get() + files.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -62,13 +62,13 @@ internal class VersionServiceAsyncTest { .build() val versionServiceAsync = client.files().versions() - val versionFuture = + val fileFuture = versionServiceAsync.get( VersionGetParams.builder().fileId("fileId").versionId("versionId").build() ) - val version = versionFuture.get() - version.validate() + val file = fileFuture.get() + file.validate() } @Disabled("Prism tests are disabled") @@ -82,12 +82,12 @@ internal class VersionServiceAsyncTest { .build() val versionServiceAsync = client.files().versions() - val responseFuture = + val fileFuture = versionServiceAsync.restore( VersionRestoreParams.builder().fileId("fileId").versionId("versionId").build() ) - val response = responseFuture.get() - response.validate() + val file = fileFuture.get() + file.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 index da360905..a8d311ca 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 @@ -25,9 +25,9 @@ internal class VersionServiceTest { .build() val versionService = client.files().versions() - val versions = versionService.list("fileId") + val files = versionService.list("fileId") - versions.forEach { it.validate() } + files.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -60,12 +60,12 @@ internal class VersionServiceTest { .build() val versionService = client.files().versions() - val version = + val file = versionService.get( VersionGetParams.builder().fileId("fileId").versionId("versionId").build() ) - version.validate() + file.validate() } @Disabled("Prism tests are disabled") @@ -79,11 +79,11 @@ internal class VersionServiceTest { .build() val versionService = client.files().versions() - val response = + val file = versionService.restore( VersionRestoreParams.builder().fileId("fileId").versionId("versionId").build() ) - response.validate() + file.validate() } } 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 dcfc2cd7..fc696c50 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.assets.AssetListResponse -import com.imagekit.api.models.files.FileUpdateResponse +import com.imagekit.api.models.files.File import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -65,36 +65,20 @@ internal class ProGuardCompatibilityTest { } @Test - fun fileUpdateResponseRoundtrip() { + fun fileRoundtrip() { val jsonMapper = jsonMapper() - val fileUpdateResponse = - FileUpdateResponse.builder() + val file = + File.builder() .addAiTag( - FileUpdateResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - FileUpdateResponse.CustomMetadata.builder() + File.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .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() - ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -107,39 +91,32 @@ internal class ProGuardCompatibilityTest { .size(0.0) .addTag("string") .thumbnail("https://example.com") - .type(FileUpdateResponse.Type.FILE) + .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(FileUpdateResponse.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() - val roundtrippedFileUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fileUpdateResponse), - jacksonTypeRef(), - ) + val roundtrippedFile = + jsonMapper.readValue(jsonMapper.writeValueAsString(file), jacksonTypeRef()) - assertThat(roundtrippedFileUpdateResponse).isEqualTo(fileUpdateResponse) + assertThat(roundtrippedFile).isEqualTo(file) } @Test fun assetListResponseRoundtrip() { val jsonMapper = jsonMapper() val assetListResponse = - AssetListResponse.ofFileDetails( - AssetListResponse.FileDetails.builder() + AssetListResponse.ofFile( + File.builder() .addAiTag( - AssetListResponse.FileDetails.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - AssetListResponse.FileDetails.CustomMetadata.builder() + File.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -155,15 +132,10 @@ internal class ProGuardCompatibilityTest { .size(0.0) .addTag("string") .thumbnail("https://example.com") - .type(AssetListResponse.FileDetails.Type.FILE) + .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo( - AssetListResponse.FileDetails.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) .width(0.0) .build() ) From 6db0b42b354af5499e823650a29bcac5edb00405 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 03:23:14 +0000 Subject: [PATCH 044/125] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/assets/AssetListResponse.kt | 2 - .../com/imagekit/api/models/assets/File.kt | 1615 +++++++++++++++++ .../com/imagekit/api/models/assets/Folder.kt | 478 +++++ .../api/models/files/FileUpdateResponse.kt | 1 + .../api/services/async/FileServiceAsync.kt | 2 +- .../services/async/FileServiceAsyncImpl.kt | 2 +- .../async/files/VersionServiceAsync.kt | 2 +- .../async/files/VersionServiceAsyncImpl.kt | 2 +- .../api/services/blocking/FileService.kt | 2 +- .../api/services/blocking/FileServiceImpl.kt | 2 +- .../services/blocking/files/VersionService.kt | 2 +- .../blocking/files/VersionServiceImpl.kt | 2 +- .../models/assets/AssetListResponseTest.kt | 2 - .../imagekit/api/models/assets/FileTest.kt | 119 ++ .../imagekit/api/models/assets/FolderTest.kt | 51 + .../models/files/FileUpdateResponseTest.kt | 1 + .../api/proguard/ProGuardCompatibilityTest.kt | 1 + 18 files changed, 2275 insertions(+), 13 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/File.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/Folder.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FileTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FolderTest.kt diff --git a/.stats.yml b/.stats.yml index 0fe111b5..cf2fe471 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-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml openapi_spec_hash: 98642308bee81ac776b7b1843089b888 -config_hash: 91cbeb97fdb75393dffd187ec25a4080 +config_hash: 734b211088fdf0d30e3d6c8788ac83bc 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 index 8e1fbee8..9ecc18f4 100644 --- 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 @@ -14,8 +14,6 @@ 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/File.kt new file mode 100644 index 00000000..dc45f669 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/File.kt @@ -0,0 +1,1615 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.assets + +import 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 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("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, + 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") + + /** + * 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 [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 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 + 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 + } + + /** 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, + 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() } + 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 (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 && + 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, + 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, 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/assets/Folder.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/Folder.kt new file mode 100644 index 00000000..b7c07208 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/Folder.kt @@ -0,0 +1,478 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.assets + +import 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/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index b09444fd..42156ae9 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,7 @@ 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.assets.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/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index 3695f29f..6f599101 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 @@ -6,7 +6,7 @@ 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.assets.File import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileCopyResponse import com.imagekit.api.models.files.FileDeleteParams 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..8bd2ecd1 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 @@ -18,7 +18,7 @@ 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.assets.File import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileCopyResponse import com.imagekit.api.models.files.FileDeleteParams 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 index 62bdd118..65284117 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/com/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -5,7 +5,7 @@ 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.assets.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 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 index c601ebe2..4cd7b824 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/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -16,7 +16,7 @@ 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.assets.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 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 0aba8894..a7aaf1ae 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 @@ -7,7 +7,7 @@ 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.assets.File import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileCopyResponse import com.imagekit.api.models.files.FileDeleteParams 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..c568f7d1 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 @@ -18,7 +18,7 @@ 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.assets.File import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileCopyResponse import com.imagekit.api.models.files.FileDeleteParams 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 index eb1195eb..807a4a23 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/com/imagekit/api/services/blocking/files/VersionService.kt @@ -6,7 +6,7 @@ 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.assets.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 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 index 2637882f..0aa0c224 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/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -16,7 +16,7 @@ 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.assets.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 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 309be429..b06eed3c 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,8 +6,6 @@ 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 diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FileTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FileTest.kt new file mode 100644 index 00000000..e35e6ca9 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FileTest.kt @@ -0,0 +1,119 @@ +// 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 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() + ) + .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.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() + ) + .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/assets/FolderTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FolderTest.kt new file mode 100644 index 00000000..614c8af9 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FolderTest.kt @@ -0,0 +1,51 @@ +// 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.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/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index 28d9d15c..805ca49d 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,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 com.imagekit.api.models.assets.File import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat 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 fc696c50..202c30f2 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,6 +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.assets.AssetListResponse +import com.imagekit.api.models.assets.File import com.imagekit.api.models.files.File import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions From d4f7a4b1ea5ff6a11a65772e3757417b1c6b6a53 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 03:25:35 +0000 Subject: [PATCH 045/125] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/assets/AssetListResponse.kt | 2 + .../com/imagekit/api/models/assets/File.kt | 1615 ----------------- .../com/imagekit/api/models/assets/Folder.kt | 478 ----- .../api/models/files/FileUpdateResponse.kt | 1 - .../api/services/async/FileServiceAsync.kt | 2 +- .../services/async/FileServiceAsyncImpl.kt | 2 +- .../async/files/VersionServiceAsync.kt | 2 +- .../async/files/VersionServiceAsyncImpl.kt | 2 +- .../api/services/blocking/FileService.kt | 2 +- .../api/services/blocking/FileServiceImpl.kt | 2 +- .../services/blocking/files/VersionService.kt | 2 +- .../blocking/files/VersionServiceImpl.kt | 2 +- .../models/assets/AssetListResponseTest.kt | 2 + .../imagekit/api/models/assets/FileTest.kt | 119 -- .../imagekit/api/models/assets/FolderTest.kt | 51 - .../models/files/FileUpdateResponseTest.kt | 1 - .../api/proguard/ProGuardCompatibilityTest.kt | 1 - 18 files changed, 13 insertions(+), 2275 deletions(-) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/File.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/Folder.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FileTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FolderTest.kt diff --git a/.stats.yml b/.stats.yml index cf2fe471..0fe111b5 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-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml openapi_spec_hash: 98642308bee81ac776b7b1843089b888 -config_hash: 734b211088fdf0d30e3d6c8788ac83bc +config_hash: 91cbeb97fdb75393dffd187ec25a4080 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 index 9ecc18f4..8e1fbee8 100644 --- 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 @@ -14,6 +14,8 @@ 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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/File.kt deleted file mode 100644 index dc45f669..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/File.kt +++ /dev/null @@ -1,1615 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.assets - -import 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 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("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, - 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") - - /** - * 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 [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 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 - 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 - } - - /** 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, - 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() } - 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 (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 && - 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, - 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, 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/assets/Folder.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/Folder.kt deleted file mode 100644 index b7c07208..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/Folder.kt +++ /dev/null @@ -1,478 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.assets - -import 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/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index 42156ae9..b09444fd 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,7 +14,6 @@ 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.assets.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/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index 6f599101..3695f29f 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 @@ -6,7 +6,7 @@ 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.assets.File +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 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 8bd2ecd1..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 @@ -18,7 +18,7 @@ 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.assets.File +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 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 index 65284117..62bdd118 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/com/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -5,7 +5,7 @@ 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.assets.File +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 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 index 4cd7b824..c601ebe2 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/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -16,7 +16,7 @@ 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.assets.File +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 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 a7aaf1ae..0aba8894 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 @@ -7,7 +7,7 @@ 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.assets.File +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 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 c568f7d1..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 @@ -18,7 +18,7 @@ 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.assets.File +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 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 index 807a4a23..eb1195eb 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/com/imagekit/api/services/blocking/files/VersionService.kt @@ -6,7 +6,7 @@ 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.File +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 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 index 0aa0c224..2637882f 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/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -16,7 +16,7 @@ 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.assets.File +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 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 b06eed3c..309be429 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,8 @@ 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 diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FileTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FileTest.kt deleted file mode 100644 index e35e6ca9..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FileTest.kt +++ /dev/null @@ -1,119 +0,0 @@ -// 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 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() - ) - .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.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() - ) - .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/assets/FolderTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FolderTest.kt deleted file mode 100644 index 614c8af9..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/FolderTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -// 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.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/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index 805ca49d..28d9d15c 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,7 +5,6 @@ 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.assets.File import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat 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 202c30f2..fc696c50 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,6 @@ import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.models.assets.AssetListResponse -import com.imagekit.api.models.assets.File import com.imagekit.api.models.files.File import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions From 99734c3eade7e02c91b696a748c6c5938819297a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 03:30:27 +0000 Subject: [PATCH 046/125] feat(api): manual updates --- .stats.yml | 6 +- .../api/models/accounts/origins/Origin.kt | 3906 ++++++++++++++++ .../accounts/origins/OriginCreateParams.kt | 4012 ----------------- .../accounts/origins/OriginCreateResponse.kt | 2325 ++++++---- .../accounts/origins/OriginGetResponse.kt | 2324 ++++++---- .../accounts/origins/OriginListResponse.kt | 2324 ++++++---- .../accounts/origins/OriginUpdateParams.kt | 4010 ---------------- .../accounts/origins/OriginUpdateResponse.kt | 2325 ++++++---- .../origins/OriginCreateParamsTest.kt | 14 +- .../origins/OriginCreateResponseTest.kt | 173 +- .../accounts/origins/OriginGetResponseTest.kt | 172 +- .../origins/OriginListResponseTest.kt | 172 +- .../api/models/accounts/origins/OriginTest.kt | 403 ++ .../origins/OriginUpdateParamsTest.kt | 16 +- .../origins/OriginUpdateResponseTest.kt | 173 +- .../async/accounts/OriginServiceAsyncTest.kt | 5 +- .../blocking/accounts/OriginServiceTest.kt | 5 +- 17 files changed, 10171 insertions(+), 12194 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt diff --git a/.stats.yml b/.stats.yml index 0fe111b5..53bd25d3 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-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml -openapi_spec_hash: 98642308bee81ac776b7b1843089b888 -config_hash: 91cbeb97fdb75393dffd187ec25a4080 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d65a790786704dc315c1fded8ee24d61a55d96054fbbf1e6da429ec96b3e0c88.yml +openapi_spec_hash: 0fa9ee90455e183ec3b5d4e36f1351a9 +config_hash: 89ffae9ef2878c981a64f42cadb85186 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt new file mode 100644 index 00000000..e03765d9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt @@ -0,0 +1,3906 @@ +// 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 resources. */ +@JsonDeserialize(using = Origin.Deserializer::class) +@JsonSerialize(using = Origin.Serializer::class) +class Origin +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(): Origin = 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 Origin && + 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 -> "Origin{s3=$s3}" + s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "Origin{webFolder=$webFolder}" + webProxy != null -> "Origin{webProxy=$webProxy}" + gcs != null -> "Origin{gcs=$gcs}" + azureBlob != null -> "Origin{azureBlob=$azureBlob}" + akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" + _json != null -> "Origin{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Origin") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + Origin(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) + + @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) + + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) + } + + /** An interface that defines how to map each variant of [Origin] 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 [Origin] to a value of type [T]. + * + * An instance of [Origin] 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 Origin: $json") + } + } + + internal class Deserializer : BaseDeserializer(Origin::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Origin { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3 = it, _json = json) + } ?: Origin(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3Compatible = it, _json = json) + } ?: Origin(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(cloudinaryBackup = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webFolder = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webProxy = it, _json = json) + } ?: Origin(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(gcs = it, _json = json) + } ?: Origin(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(azureBlob = it, _json = json) + } ?: Origin(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(akeneoPim = it, _json = json) + } ?: Origin(_json = json) + } + } + + return Origin(_json = json) + } + } + + internal class Serializer : BaseSerializer(Origin::class) { + + override fun serialize( + value: Origin, + 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 Origin") + } + } + } + + 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/OriginCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt index f11dbf68..71bcb378 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 @@ -2,33 +2,11 @@ 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.Params 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.errors.ImageKitInvalidDataException -import java.util.Collections import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams @@ -238,3996 +216,6 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - /** Schema for origin resources. */ - @JsonDeserialize(using = Origin.Deserializer::class) - @JsonSerialize(using = Origin.Serializer::class) - class Origin - 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(): Origin = 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 Origin && - 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 -> "Origin{s3=$s3}" - s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "Origin{webFolder=$webFolder}" - webProxy != null -> "Origin{webProxy=$webProxy}" - gcs != null -> "Origin{gcs=$gcs}" - azureBlob != null -> "Origin{azureBlob=$azureBlob}" - akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" - _json != null -> "Origin{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Origin") - } - - companion object { - - @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) - - @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) - - @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - Origin(cloudinaryBackup = cloudinaryBackup) - - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) - - @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) - - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) - - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) - } - - /** An interface that defines how to map each variant of [Origin] 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 [Origin] to a value of type [T]. - * - * An instance of [Origin] 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 Origin: $json") - } - } - - internal class Deserializer : BaseDeserializer(Origin::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Origin { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3 = it, _json = json) - } ?: Origin(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3Compatible = it, _json = json) - } ?: Origin(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(cloudinaryBackup = it, _json = json) - } ?: Origin(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webFolder = it, _json = json) - } ?: Origin(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webProxy = it, _json = json) - } ?: Origin(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(gcs = it, _json = json) - } ?: Origin(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(azureBlob = it, _json = json) - } ?: Origin(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(akeneoPim = it, _json = json) - } ?: Origin(_json = json) - } - } - - return Origin(_json = json) - } - } - - internal class Serializer : BaseSerializer(Origin::class) { - - override fun serialize( - value: Origin, - 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 Origin") - } - } - } - - 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}" - } - } - 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/accounts/origins/OriginCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt index 4eb17b1b..af82b8e9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt @@ -19,15 +19,14 @@ 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.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 = OriginCreateResponse.Deserializer::class) @JsonSerialize(using = OriginCreateResponse.Serializer::class) class OriginCreateResponse @@ -37,8 +36,8 @@ private constructor( 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -53,9 +52,10 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun gcs(): Optional = Optional.ofNullable(gcs) + fun googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) - fun azureBlob(): Optional = Optional.ofNullable(azureBlob) + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -69,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGcs(): Boolean = gcs != null + fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null - fun isAzureBlob(): Boolean = azureBlob != null + fun isAzureBlobStorage(): Boolean = azureBlobStorage != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -85,9 +85,10 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGcs(): Gcs = gcs.getOrThrow("gcs") + fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") - fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -100,8 +101,9 @@ private constructor( 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -135,12 +137,14 @@ private constructor( webProxy.validate() } - override fun visitGcs(gcs: Gcs) { - gcs.validate() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() } - override fun visitAzureBlob(azureBlob: AzureBlob) { - azureBlob.validate() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -179,9 +183,12 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGcs(gcs: Gcs) = gcs.validity() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() - override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -200,8 +207,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - gcs == other.gcs && - azureBlob == other.azureBlob && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && akeneoPim == other.akeneoPim } @@ -212,8 +219,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - gcs, - azureBlob, + googleCloudStorageGcs, + azureBlobStorage, akeneoPim, ) @@ -224,8 +231,9 @@ private constructor( cloudinaryBackup != null -> "OriginCreateResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginCreateResponse{webFolder=$webFolder}" webProxy != null -> "OriginCreateResponse{webProxy=$webProxy}" - gcs != null -> "OriginCreateResponse{gcs=$gcs}" - azureBlob != null -> "OriginCreateResponse{azureBlob=$azureBlob}" + googleCloudStorageGcs != null -> + "OriginCreateResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "OriginCreateResponse{azureBlobStorage=$azureBlobStorage}" akeneoPim != null -> "OriginCreateResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginCreateResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginCreateResponse") @@ -248,10 +256,13 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginCreateResponse(webProxy = webProxy) - @JvmStatic fun ofGcs(gcs: Gcs) = OriginCreateResponse(gcs = gcs) + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + OriginCreateResponse(googleCloudStorageGcs = googleCloudStorageGcs) @JvmStatic - fun ofAzureBlob(azureBlob: AzureBlob) = OriginCreateResponse(azureBlob = azureBlob) + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + OriginCreateResponse(azureBlobStorage = azureBlobStorage) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginCreateResponse(akeneoPim = akeneoPim) @@ -273,9 +284,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGcs(gcs: Gcs): T + fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T - fun visitAzureBlob(azureBlob: AzureBlob): T + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -299,52 +310,46 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginCreateResponse { val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(s3 = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(s3Compatible = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(cloudinaryBackup = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(webFolder = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(webProxy = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(gcs = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(azureBlob = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(akeneoPim = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(akeneoPim = 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 -> OriginCreateResponse(_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() } - - return OriginCreateResponse(_json = json) } } @@ -361,8 +366,9 @@ private constructor( 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) value.akeneoPim != null -> generator.writeObject(value.akeneoPim) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid OriginCreateResponse") @@ -372,48 +378,57 @@ private constructor( class S3 private constructor( - private val id: JsonField, + private val accessKey: JsonField, private val bucket: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonField, + private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("accessKey") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -423,15 +438,6 @@ private constructor( */ 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. * @@ -441,12 +447,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Path prefix inside the bucket. + * 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 prefix(): String = prefix.getRequired("prefix") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -459,6 +465,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -469,28 +481,35 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [accessKey]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @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]. @@ -500,11 +519,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [secretKey]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * 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 [baseUrlForCanonicalHeader]. @@ -516,6 +542,23 @@ private constructor( @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) @@ -535,11 +578,10 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -548,41 +590,42 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: JsonField? = null private var bucket: JsonField? = null - private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonField? = null + private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3") + private var id: JsonField = JsonMissing.of() 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 { - id = s3.id + accessKey = s3.accessKey bucket = s3.bucket - includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - prefix = s3.prefix + secretKey = s3.secretKey type = s3.type + id = s3.id baseUrlForCanonicalHeader = s3.baseUrlForCanonicalHeader + includeCanonicalHeader = s3.includeCanonicalHeader + prefix = s3.prefix 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -596,21 +639,6 @@ private constructor( */ 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)) @@ -623,17 +651,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -649,6 +677,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -664,6 +703,33 @@ private constructor( 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) @@ -690,24 +756,25 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } @@ -719,17 +786,19 @@ private constructor( return@apply } - id() + accessKey() bucket() - includeCanonicalHeader() name() - prefix() + secretKey() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -749,13 +818,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -763,25 +834,29 @@ private constructor( } return other is S3 && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -789,63 +864,72 @@ private constructor( 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}" + "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val id: JsonField, + private val accessKey: 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 secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val s3ForcePathStyle: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: 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, + accessKey, bucket, endpoint, - includeCanonicalHeader, name, - prefix, - s3ForcePathStyle, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -863,15 +947,6 @@ private constructor( */ 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. * @@ -881,20 +956,12 @@ private constructor( 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? + * 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 s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -907,6 +974,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -917,18 +990,43 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + 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]. @@ -938,21 +1036,45 @@ private constructor( @JsonProperty("endpoint") @ExcludeMissing fun _endpoint(): JsonField = endpoint /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * 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 [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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [prefix]. @@ -971,16 +1093,6 @@ private constructor( @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) @@ -1000,13 +1112,11 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() * .endpoint() - * .includeCanonicalHeader() * .name() - * .prefix() - * .s3ForcePathStyle() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -1015,45 +1125,46 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: 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 secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") + private var id: JsonField = JsonMissing.of() 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 { - id = s3Compatible.id + accessKey = s3Compatible.accessKey bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - includeCanonicalHeader = s3Compatible.includeCanonicalHeader name = s3Compatible.name - prefix = s3Compatible.prefix - s3ForcePathStyle = s3Compatible.s3ForcePathStyle + secretKey = s3Compatible.secretKey type = s3Compatible.type + id = s3Compatible.id baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader + includeCanonicalHeader = s3Compatible.includeCanonicalHeader + prefix = s3Compatible.prefix + s3ForcePathStyle = s3Compatible.s3ForcePathStyle 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1079,21 +1190,6 @@ private constructor( */ 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)) @@ -1106,32 +1202,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -1147,6 +1228,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1162,6 +1254,48 @@ private constructor( 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) @@ -1188,28 +1322,28 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() * .endpoint() - * .includeCanonicalHeader() * .name() - * .prefix() - * .s3ForcePathStyle() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), - checkRequired("s3ForcePathStyle", s3ForcePathStyle), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1221,19 +1355,21 @@ private constructor( return@apply } - id() + accessKey() bucket() endpoint() - includeCanonicalHeader() name() - prefix() - s3ForcePathStyle() + secretKey() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + s3ForcePathStyle() validated = true } @@ -1253,15 +1389,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -1269,29 +1407,33 @@ private constructor( } return other is S3Compatible && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && endpoint == other.endpoint && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && - s3ForcePathStyle == other.s3ForcePathStyle && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + s3ForcePathStyle == other.s3ForcePathStyle && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, endpoint, - includeCanonicalHeader, name, - prefix, - s3ForcePathStyle, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, additionalProperties, ) } @@ -1299,53 +1441,62 @@ private constructor( 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}" + "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" } class CloudinaryBackup private constructor( - private val id: JsonField, + private val accessKey: JsonField, private val bucket: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonField, + private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("accessKey") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -1355,15 +1506,6 @@ private constructor( */ 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. * @@ -1373,12 +1515,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Path prefix inside the bucket. + * 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 prefix(): String = prefix.getRequired("prefix") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -1391,6 +1533,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -1401,28 +1549,35 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [accessKey]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @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]. @@ -1432,11 +1587,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [secretKey]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * 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 [baseUrlForCanonicalHeader]. @@ -1448,6 +1610,23 @@ private constructor( @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) @@ -1467,11 +1646,10 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -1480,41 +1658,42 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: JsonField? = null private var bucket: JsonField? = null - private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonField? = null + private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") + private var id: JsonField = JsonMissing.of() 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 { - id = cloudinaryBackup.id + accessKey = cloudinaryBackup.accessKey bucket = cloudinaryBackup.bucket - includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - prefix = cloudinaryBackup.prefix + secretKey = cloudinaryBackup.secretKey type = cloudinaryBackup.type + id = cloudinaryBackup.id baseUrlForCanonicalHeader = cloudinaryBackup.baseUrlForCanonicalHeader + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader + prefix = cloudinaryBackup.prefix 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1528,21 +1707,6 @@ private constructor( */ 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)) @@ -1555,17 +1719,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -1581,6 +1745,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1596,6 +1771,33 @@ private constructor( 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) @@ -1622,24 +1824,25 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } @@ -1651,17 +1854,19 @@ private constructor( return@apply } - id() + accessKey() bucket() - includeCanonicalHeader() name() - prefix() + secretKey() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -1681,13 +1886,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -1695,25 +1902,29 @@ private constructor( } return other is CloudinaryBackup && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -1721,56 +1932,47 @@ private constructor( 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}" + "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, 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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: 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, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, 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. * @@ -1779,24 +1981,6 @@ private constructor( */ 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. * @@ -1816,6 +2000,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -1826,11 +2016,22 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Forward the Host header to origin? * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -1840,41 +2041,48 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** - * Returns the raw JSON value of [forwardHostHeaderToOrigin]. + * Returns the raw JSON value of [name]. * - * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("forwardHostHeaderToOrigin") - @ExcludeMissing - fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [id]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [forwardHostHeaderToOrigin]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1895,10 +2103,7 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .forwardHostHeaderToOrigin() - * .includeCanonicalHeader() * .name() * ``` */ @@ -1908,42 +2113,27 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { - 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 } - + @JvmSynthetic + internal fun from(webFolder: WebFolder) = apply { + baseUrl = webFolder.baseUrl + name = webFolder.name + type = webFolder.type + id = webFolder.id + 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)) @@ -1956,36 +2146,6 @@ private constructor( */ 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)) @@ -2012,6 +2172,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2027,6 +2198,36 @@ private constructor( 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) @@ -2053,10 +2254,7 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .forwardHostHeaderToOrigin() - * .includeCanonicalHeader() * .name() * ``` * @@ -2064,13 +2262,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( - checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2082,17 +2280,17 @@ private constructor( return@apply } - id() baseUrl() - forwardHostHeaderToOrigin() - includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + forwardHostHeaderToOrigin() + includeCanonicalHeader() validated = true } @@ -2112,13 +2310,13 @@ private constructor( */ @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 (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 (id.asKnown().isPresent) 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) { @@ -2126,25 +2324,25 @@ private constructor( } return other is WebFolder && - id == other.id && baseUrl == other.baseUrl && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, baseUrl, - forwardHostHeaderToOrigin, - includeCanonicalHeader, name, type, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, additionalProperties, ) } @@ -2152,49 +2350,31 @@ private constructor( 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}" + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } class WebProxy private constructor( - private val id: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = 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") + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) /** * Display name of the origin. @@ -2215,6 +2395,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -2225,28 +2411,27 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [id]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2258,6 +2443,16 @@ private constructor( @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) @@ -2277,8 +2472,6 @@ private constructor( * * The following fields are required: * ```java - * .id() - * .includeCanonicalHeader() * .name() * ``` */ @@ -2288,53 +2481,23 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: 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 + id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader + includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2361,6 +2524,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2376,6 +2550,21 @@ private constructor( 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) @@ -2402,8 +2591,6 @@ private constructor( * * The following fields are required: * ```java - * .id() - * .includeCanonicalHeader() * .name() * ``` * @@ -2411,11 +2598,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( - checkRequired("id", id), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2427,15 +2614,15 @@ private constructor( return@apply } - id() - includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() validated = true } @@ -2455,11 +2642,11 @@ private constructor( */ @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) + + (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 (id.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) { @@ -2467,21 +2654,21 @@ private constructor( } return other is WebProxy && - id == other.id && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, - includeCanonicalHeader, name, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties, ) } @@ -2489,59 +2676,55 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class Gcs + class GoogleCloudStorageGcs 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 privateKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: 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("privateKey") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, bucket, clientEmail, - includeCanonicalHeader, name, - prefix, + privateKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, 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). @@ -2554,15 +2737,6 @@ private constructor( */ 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. * @@ -2575,7 +2749,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 prefix(): String = prefix.getRequired("prefix") + fun privateKey(): String = privateKey.getRequired("privateKey") /** * Expected to always return the following: @@ -2588,6 +2762,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -2598,11 +2778,19 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -2621,28 +2809,27 @@ private constructor( fun _clientEmail(): JsonField = clientEmail /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [privateKey]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("privateKey") + @ExcludeMissing + fun _privateKey(): JsonField = privateKey /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [id]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2654,6 +2841,23 @@ private constructor( @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) @@ -2669,62 +2873,47 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Gcs]. + * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. * * The following fields are required: * ```java - * .id() * .bucket() * .clientEmail() - * .includeCanonicalHeader() * .name() - * .prefix() + * .privateKey() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Gcs]. */ + /** A builder for [GoogleCloudStorageGcs]. */ 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 privateKey: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") + private var id: JsonField = JsonMissing.of() 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 { - 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() + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + id = googleCloudStorageGcs.id + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.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)) /** @@ -2749,21 +2938,6 @@ private constructor( 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)) @@ -2776,16 +2950,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.privateKey] 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 + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } /** * Sets the field to an arbitrary JSON value. @@ -2801,6 +2975,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2816,6 +3001,32 @@ private constructor( 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) @@ -2836,55 +3047,55 @@ private constructor( } /** - * Returns an immutable instance of [Gcs]. + * Returns an immutable instance of [GoogleCloudStorageGcs]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() * .bucket() * .clientEmail() - * .includeCanonicalHeader() * .name() - * .prefix() + * .privateKey() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Gcs = - Gcs( - checkRequired("id", id), + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("privateKey", privateKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Gcs = apply { + fun validate(): GoogleCloudStorageGcs = apply { if (validated) { return@apply } - id() bucket() clientEmail() - includeCanonicalHeader() name() - prefix() + privateKey() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -2904,42 +3115,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (bucket.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) + + (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 (id.asKnown().isPresent) 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 && - id == other.id && + return other is GoogleCloudStorageGcs && bucket == other.bucket && clientEmail == other.clientEmail && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + privateKey == other.privateKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, bucket, clientEmail, - includeCanonicalHeader, name, - prefix, + privateKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -2947,61 +3161,57 @@ private constructor( 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}" + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlob + class AzureBlobStorage 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 sasToken: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: 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("sasToken") + @ExcludeMissing + sasToken: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, accountName, container, - includeCanonicalHeader, name, - prefix, + sasToken, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, 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). @@ -3014,15 +3224,6 @@ private constructor( */ 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. * @@ -3035,7 +3236,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 prefix(): String = prefix.getRequired("prefix") + fun sasToken(): String = sasToken.getRequired("sasToken") /** * Expected to always return the following: @@ -3048,6 +3249,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -3058,11 +3265,19 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -3081,28 +3296,25 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [sasToken]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [id]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3114,6 +3326,23 @@ private constructor( @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) @@ -3129,61 +3358,46 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlob]. + * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. * * The following fields are required: * ```java - * .id() * .accountName() * .container() - * .includeCanonicalHeader() * .name() - * .prefix() + * .sasToken() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlob]. */ + /** A builder for [AzureBlobStorage]. */ 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 sasToken: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") + private var id: JsonField = JsonMissing.of() 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 { - 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 } + @JvmSynthetic + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + id = azureBlobStorage.id + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + } fun accountName(accountName: String) = accountName(JsonField.of(accountName)) @@ -3209,21 +3423,6 @@ private constructor( */ 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)) @@ -3236,16 +3435,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.sasToken] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } /** * Sets the field to an arbitrary JSON value. @@ -3261,6 +3460,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3276,6 +3486,32 @@ private constructor( 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) @@ -3296,55 +3532,55 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlob]. + * Returns an immutable instance of [AzureBlobStorage]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() * .accountName() * .container() - * .includeCanonicalHeader() * .name() - * .prefix() + * .sasToken() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlob = - AzureBlob( - checkRequired("id", id), + fun build(): AzureBlobStorage = + AzureBlobStorage( checkRequired("accountName", accountName), checkRequired("container", container), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("sasToken", sasToken), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AzureBlob = apply { + fun validate(): AzureBlobStorage = apply { if (validated) { return@apply } - id() accountName() container() - includeCanonicalHeader() name() - prefix() + sasToken() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -3364,42 +3600,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (accountName.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) + + (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 (id.asKnown().isPresent) 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 && - id == other.id && + return other is AzureBlobStorage && accountName == other.accountName && container == other.container && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + sasToken == other.sasToken && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, accountName, container, - includeCanonicalHeader, name, - prefix, + sasToken, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -3407,67 +3646,85 @@ private constructor( 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}" + "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim private constructor( - private val id: JsonField, private val baseUrl: JsonField, - private val includeCanonicalHeader: 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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("clientId") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( - id, baseUrl, - includeCanonicalHeader, + clientId, + clientSecret, name, + password, type, + username, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun clientId(): String = clientId.getRequired("clientId") /** - * Whether to send a Canonical header. + * 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 includeCanonicalHeader(): Boolean = - includeCanonicalHeader.getRequired("includeCanonicalHeader") + fun clientSecret(): String = clientSecret.getRequired("clientSecret") /** * Display name of the origin. @@ -3477,6 +3734,14 @@ private constructor( */ 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 @@ -3488,6 +3753,20 @@ private constructor( */ @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") + + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -3498,11 +3777,13 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** * Returns the raw JSON value of [baseUrl]. @@ -3512,14 +3793,21 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [clientId]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @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 _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _clientSecret(): JsonField = clientSecret /** * Returns the raw JSON value of [name]. @@ -3528,6 +3816,27 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3538,6 +3847,16 @@ private constructor( @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) @@ -3557,10 +3876,12 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .includeCanonicalHeader() + * .clientId() + * .clientSecret() * .name() + * .password() + * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3569,40 +3890,33 @@ private constructor( /** 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 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { - id = akeneoPim.id baseUrl = akeneoPim.baseUrl - includeCanonicalHeader = akeneoPim.includeCanonicalHeader + clientId = akeneoPim.clientId + clientSecret = akeneoPim.clientSecret name = akeneoPim.name + password = akeneoPim.password type = akeneoPim.type + username = akeneoPim.username + id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader + includeCanonicalHeader = akeneoPim.includeCanonicalHeader 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)) @@ -3615,19 +3929,30 @@ private constructor( */ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Whether to send a Canonical header. */ - fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = - includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + /** Akeneo API client ID. */ + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) /** - * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * Sets [Builder.clientId] 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. + * 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 includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { - this.includeCanonicalHeader = includeCanonicalHeader + 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. */ @@ -3642,6 +3967,18 @@ private constructor( */ 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. * @@ -3656,6 +3993,29 @@ private constructor( */ 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 } + + 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3671,6 +4031,21 @@ private constructor( 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) @@ -3697,22 +4072,28 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .includeCanonicalHeader() + * .clientId() + * .clientSecret() * .name() + * .password() + * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( - checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("clientId", clientId), + checkRequired("clientSecret", clientSecret), checkRequired("name", name), + checkRequired("password", password), type, + checkRequired("username", username), + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -3724,16 +4105,20 @@ private constructor( return@apply } - id() baseUrl() - includeCanonicalHeader() + clientId() + clientSecret() name() + password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + username() + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() validated = true } @@ -3753,12 +4138,16 @@ private constructor( */ @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 (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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (username.asKnown().isPresent) 1 else 0) + + (if (id.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) { @@ -3766,23 +4155,31 @@ private constructor( } return other is AkeneoPim && - id == other.id && baseUrl == other.baseUrl && - includeCanonicalHeader == other.includeCanonicalHeader && + clientId == other.clientId && + clientSecret == other.clientSecret && name == other.name && + password == other.password && type == other.type && + username == other.username && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, baseUrl, - includeCanonicalHeader, + clientId, + clientSecret, name, + password, type, + username, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties, ) } @@ -3790,6 +4187,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{id=$id, baseUrl=$baseUrl, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt index 81dffd47..6fd68932 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt @@ -19,15 +19,14 @@ 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.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 = OriginGetResponse.Deserializer::class) @JsonSerialize(using = OriginGetResponse.Serializer::class) class OriginGetResponse @@ -37,8 +36,8 @@ private constructor( 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -53,9 +52,10 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun gcs(): Optional = Optional.ofNullable(gcs) + fun googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) - fun azureBlob(): Optional = Optional.ofNullable(azureBlob) + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -69,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGcs(): Boolean = gcs != null + fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null - fun isAzureBlob(): Boolean = azureBlob != null + fun isAzureBlobStorage(): Boolean = azureBlobStorage != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -85,9 +85,10 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGcs(): Gcs = gcs.getOrThrow("gcs") + fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") - fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -100,8 +101,9 @@ private constructor( 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -135,12 +137,14 @@ private constructor( webProxy.validate() } - override fun visitGcs(gcs: Gcs) { - gcs.validate() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() } - override fun visitAzureBlob(azureBlob: AzureBlob) { - azureBlob.validate() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -179,9 +183,12 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGcs(gcs: Gcs) = gcs.validity() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() - override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -200,8 +207,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - gcs == other.gcs && - azureBlob == other.azureBlob && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && akeneoPim == other.akeneoPim } @@ -212,8 +219,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - gcs, - azureBlob, + googleCloudStorageGcs, + azureBlobStorage, akeneoPim, ) @@ -224,8 +231,9 @@ private constructor( cloudinaryBackup != null -> "OriginGetResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginGetResponse{webFolder=$webFolder}" webProxy != null -> "OriginGetResponse{webProxy=$webProxy}" - gcs != null -> "OriginGetResponse{gcs=$gcs}" - azureBlob != null -> "OriginGetResponse{azureBlob=$azureBlob}" + googleCloudStorageGcs != null -> + "OriginGetResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "OriginGetResponse{azureBlobStorage=$azureBlobStorage}" akeneoPim != null -> "OriginGetResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginGetResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginGetResponse") @@ -247,9 +255,13 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginGetResponse(webProxy = webProxy) - @JvmStatic fun ofGcs(gcs: Gcs) = OriginGetResponse(gcs = gcs) + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + OriginGetResponse(googleCloudStorageGcs = googleCloudStorageGcs) - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginGetResponse(azureBlob = azureBlob) + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + OriginGetResponse(azureBlobStorage = azureBlobStorage) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginGetResponse(akeneoPim = akeneoPim) } @@ -270,9 +282,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGcs(gcs: Gcs): T + fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T - fun visitAzureBlob(azureBlob: AzureBlob): T + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -295,52 +307,46 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginGetResponse { val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(s3 = it, _json = json) - } ?: OriginGetResponse(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(s3Compatible = it, _json = json) - } ?: OriginGetResponse(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(cloudinaryBackup = it, _json = json) - } ?: OriginGetResponse(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(webFolder = it, _json = json) - } ?: OriginGetResponse(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(webProxy = it, _json = json) - } ?: OriginGetResponse(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(gcs = it, _json = json) - } ?: OriginGetResponse(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(azureBlob = it, _json = json) - } ?: OriginGetResponse(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(akeneoPim = it, _json = json) - } ?: OriginGetResponse(_json = json) - } + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(akeneoPim = 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 -> OriginGetResponse(_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() } - - return OriginGetResponse(_json = json) } } @@ -357,8 +363,9 @@ private constructor( 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) value.akeneoPim != null -> generator.writeObject(value.akeneoPim) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid OriginGetResponse") @@ -368,48 +375,57 @@ private constructor( class S3 private constructor( - private val id: JsonField, + private val accessKey: JsonField, private val bucket: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonField, + private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("accessKey") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -419,15 +435,6 @@ private constructor( */ 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. * @@ -437,12 +444,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Path prefix inside the bucket. + * 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 prefix(): String = prefix.getRequired("prefix") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -455,6 +462,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -465,28 +478,35 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [accessKey]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @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]. @@ -496,11 +516,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [secretKey]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * 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 [baseUrlForCanonicalHeader]. @@ -512,6 +539,23 @@ private constructor( @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) @@ -531,11 +575,10 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -544,41 +587,42 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: JsonField? = null private var bucket: JsonField? = null - private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonField? = null + private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3") + private var id: JsonField = JsonMissing.of() 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 { - id = s3.id + accessKey = s3.accessKey bucket = s3.bucket - includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - prefix = s3.prefix + secretKey = s3.secretKey type = s3.type + id = s3.id baseUrlForCanonicalHeader = s3.baseUrlForCanonicalHeader + includeCanonicalHeader = s3.includeCanonicalHeader + prefix = s3.prefix 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -592,21 +636,6 @@ private constructor( */ 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)) @@ -619,17 +648,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -645,6 +674,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -660,6 +700,33 @@ private constructor( 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) @@ -686,24 +753,25 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } @@ -715,17 +783,19 @@ private constructor( return@apply } - id() + accessKey() bucket() - includeCanonicalHeader() name() - prefix() + secretKey() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -745,13 +815,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -759,25 +831,29 @@ private constructor( } return other is S3 && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -785,63 +861,72 @@ private constructor( 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}" + "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val id: JsonField, + private val accessKey: 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 secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val s3ForcePathStyle: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: 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, + accessKey, bucket, endpoint, - includeCanonicalHeader, name, - prefix, - s3ForcePathStyle, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -859,15 +944,6 @@ private constructor( */ 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. * @@ -877,20 +953,12 @@ private constructor( 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? + * 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 s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -903,6 +971,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -913,16 +987,41 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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). + */ + 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 @@ -934,21 +1033,45 @@ private constructor( @JsonProperty("endpoint") @ExcludeMissing fun _endpoint(): JsonField = endpoint /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * 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 [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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [prefix]. @@ -967,16 +1090,6 @@ private constructor( @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) @@ -996,13 +1109,11 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() * .endpoint() - * .includeCanonicalHeader() * .name() - * .prefix() - * .s3ForcePathStyle() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -1011,45 +1122,46 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: 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 secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") + private var id: JsonField = JsonMissing.of() 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 { - id = s3Compatible.id + accessKey = s3Compatible.accessKey bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - includeCanonicalHeader = s3Compatible.includeCanonicalHeader name = s3Compatible.name - prefix = s3Compatible.prefix - s3ForcePathStyle = s3Compatible.s3ForcePathStyle + secretKey = s3Compatible.secretKey type = s3Compatible.type + id = s3Compatible.id baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader + includeCanonicalHeader = s3Compatible.includeCanonicalHeader + prefix = s3Compatible.prefix + s3ForcePathStyle = s3Compatible.s3ForcePathStyle 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1075,21 +1187,6 @@ private constructor( */ 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)) @@ -1102,32 +1199,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -1143,6 +1225,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1158,6 +1251,48 @@ private constructor( 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) @@ -1184,28 +1319,28 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() * .endpoint() - * .includeCanonicalHeader() * .name() - * .prefix() - * .s3ForcePathStyle() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), - checkRequired("s3ForcePathStyle", s3ForcePathStyle), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1217,19 +1352,21 @@ private constructor( return@apply } - id() + accessKey() bucket() endpoint() - includeCanonicalHeader() name() - prefix() - s3ForcePathStyle() + secretKey() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + s3ForcePathStyle() validated = true } @@ -1249,15 +1386,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -1265,29 +1404,33 @@ private constructor( } return other is S3Compatible && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && endpoint == other.endpoint && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && - s3ForcePathStyle == other.s3ForcePathStyle && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + s3ForcePathStyle == other.s3ForcePathStyle && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, endpoint, - includeCanonicalHeader, name, - prefix, - s3ForcePathStyle, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, additionalProperties, ) } @@ -1295,53 +1438,62 @@ private constructor( 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}" + "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" } class CloudinaryBackup private constructor( - private val id: JsonField, + private val accessKey: JsonField, private val bucket: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonField, + private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("accessKey") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -1351,15 +1503,6 @@ private constructor( */ 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. * @@ -1369,12 +1512,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Path prefix inside the bucket. + * 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 prefix(): String = prefix.getRequired("prefix") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -1387,6 +1530,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -1397,28 +1546,35 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [accessKey]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @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]. @@ -1428,11 +1584,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [secretKey]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * 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 [baseUrlForCanonicalHeader]. @@ -1444,6 +1607,23 @@ private constructor( @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) @@ -1463,11 +1643,10 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -1476,41 +1655,42 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: JsonField? = null private var bucket: JsonField? = null - private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonField? = null + private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") + private var id: JsonField = JsonMissing.of() 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 { - id = cloudinaryBackup.id + accessKey = cloudinaryBackup.accessKey bucket = cloudinaryBackup.bucket - includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - prefix = cloudinaryBackup.prefix + secretKey = cloudinaryBackup.secretKey type = cloudinaryBackup.type + id = cloudinaryBackup.id baseUrlForCanonicalHeader = cloudinaryBackup.baseUrlForCanonicalHeader + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader + prefix = cloudinaryBackup.prefix 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1524,21 +1704,6 @@ private constructor( */ 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)) @@ -1551,17 +1716,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -1577,6 +1742,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1592,6 +1768,33 @@ private constructor( 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) @@ -1618,24 +1821,25 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } @@ -1647,17 +1851,19 @@ private constructor( return@apply } - id() + accessKey() bucket() - includeCanonicalHeader() name() - prefix() + secretKey() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -1677,13 +1883,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -1691,25 +1899,29 @@ private constructor( } return other is CloudinaryBackup && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -1717,56 +1929,47 @@ private constructor( 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}" + "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, 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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: 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, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, 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. * @@ -1775,24 +1978,6 @@ private constructor( */ 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. * @@ -1812,6 +1997,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -1822,11 +2013,22 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Forward the Host header to origin? * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -1836,41 +2038,48 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** - * Returns the raw JSON value of [forwardHostHeaderToOrigin]. + * Returns the raw JSON value of [name]. * - * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("forwardHostHeaderToOrigin") - @ExcludeMissing - fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [id]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [forwardHostHeaderToOrigin]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1891,10 +2100,7 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .forwardHostHeaderToOrigin() - * .includeCanonicalHeader() * .name() * ``` */ @@ -1904,42 +2110,27 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { - 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 } - + @JvmSynthetic + internal fun from(webFolder: WebFolder) = apply { + baseUrl = webFolder.baseUrl + name = webFolder.name + type = webFolder.type + id = webFolder.id + 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)) @@ -1952,36 +2143,6 @@ private constructor( */ 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)) @@ -2008,6 +2169,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2023,6 +2195,36 @@ private constructor( 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) @@ -2049,10 +2251,7 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .forwardHostHeaderToOrigin() - * .includeCanonicalHeader() * .name() * ``` * @@ -2060,13 +2259,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( - checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2078,17 +2277,17 @@ private constructor( return@apply } - id() baseUrl() - forwardHostHeaderToOrigin() - includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + forwardHostHeaderToOrigin() + includeCanonicalHeader() validated = true } @@ -2108,13 +2307,13 @@ private constructor( */ @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 (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 (id.asKnown().isPresent) 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) { @@ -2122,25 +2321,25 @@ private constructor( } return other is WebFolder && - id == other.id && baseUrl == other.baseUrl && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, baseUrl, - forwardHostHeaderToOrigin, - includeCanonicalHeader, name, type, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, additionalProperties, ) } @@ -2148,49 +2347,31 @@ private constructor( 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}" + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } class WebProxy private constructor( - private val id: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = 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") + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) /** * Display name of the origin. @@ -2211,6 +2392,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -2221,28 +2408,27 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [id]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2254,6 +2440,16 @@ private constructor( @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) @@ -2273,8 +2469,6 @@ private constructor( * * The following fields are required: * ```java - * .id() - * .includeCanonicalHeader() * .name() * ``` */ @@ -2284,53 +2478,23 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: 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 + id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader + includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2357,6 +2521,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2372,6 +2547,21 @@ private constructor( 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) @@ -2398,8 +2588,6 @@ private constructor( * * The following fields are required: * ```java - * .id() - * .includeCanonicalHeader() * .name() * ``` * @@ -2407,11 +2595,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( - checkRequired("id", id), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2423,15 +2611,15 @@ private constructor( return@apply } - id() - includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() validated = true } @@ -2451,11 +2639,11 @@ private constructor( */ @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) + + (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 (id.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) { @@ -2463,21 +2651,21 @@ private constructor( } return other is WebProxy && - id == other.id && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, - includeCanonicalHeader, name, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties, ) } @@ -2485,59 +2673,55 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class Gcs + class GoogleCloudStorageGcs 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 privateKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: 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("privateKey") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, bucket, clientEmail, - includeCanonicalHeader, name, - prefix, + privateKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, 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). @@ -2550,15 +2734,6 @@ private constructor( */ 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. * @@ -2571,7 +2746,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 prefix(): String = prefix.getRequired("prefix") + fun privateKey(): String = privateKey.getRequired("privateKey") /** * Expected to always return the following: @@ -2584,6 +2759,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -2594,11 +2775,19 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -2617,28 +2806,27 @@ private constructor( fun _clientEmail(): JsonField = clientEmail /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [privateKey]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("privateKey") + @ExcludeMissing + fun _privateKey(): JsonField = privateKey /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [id]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2650,6 +2838,23 @@ private constructor( @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) @@ -2665,62 +2870,47 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Gcs]. + * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. * * The following fields are required: * ```java - * .id() * .bucket() * .clientEmail() - * .includeCanonicalHeader() * .name() - * .prefix() + * .privateKey() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Gcs]. */ + /** A builder for [GoogleCloudStorageGcs]. */ 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 privateKey: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") + private var id: JsonField = JsonMissing.of() 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 { - 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() + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + id = googleCloudStorageGcs.id + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.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)) /** @@ -2745,21 +2935,6 @@ private constructor( 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)) @@ -2772,16 +2947,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.privateKey] 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 + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } /** * Sets the field to an arbitrary JSON value. @@ -2797,6 +2972,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2812,6 +2998,32 @@ private constructor( 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) @@ -2832,55 +3044,55 @@ private constructor( } /** - * Returns an immutable instance of [Gcs]. + * Returns an immutable instance of [GoogleCloudStorageGcs]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() * .bucket() * .clientEmail() - * .includeCanonicalHeader() * .name() - * .prefix() + * .privateKey() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Gcs = - Gcs( - checkRequired("id", id), + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("privateKey", privateKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Gcs = apply { + fun validate(): GoogleCloudStorageGcs = apply { if (validated) { return@apply } - id() bucket() clientEmail() - includeCanonicalHeader() name() - prefix() + privateKey() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -2900,42 +3112,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (bucket.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) + + (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 (id.asKnown().isPresent) 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 && - id == other.id && + return other is GoogleCloudStorageGcs && bucket == other.bucket && clientEmail == other.clientEmail && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + privateKey == other.privateKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, bucket, clientEmail, - includeCanonicalHeader, name, - prefix, + privateKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -2943,61 +3158,57 @@ private constructor( 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}" + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlob + class AzureBlobStorage 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 sasToken: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: 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("sasToken") + @ExcludeMissing + sasToken: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, accountName, container, - includeCanonicalHeader, name, - prefix, + sasToken, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, 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). @@ -3010,15 +3221,6 @@ private constructor( */ 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. * @@ -3031,7 +3233,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 prefix(): String = prefix.getRequired("prefix") + fun sasToken(): String = sasToken.getRequired("sasToken") /** * Expected to always return the following: @@ -3044,6 +3246,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -3054,11 +3262,19 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -3077,28 +3293,25 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [sasToken]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [id]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3110,6 +3323,23 @@ private constructor( @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) @@ -3125,61 +3355,46 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlob]. + * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. * * The following fields are required: * ```java - * .id() * .accountName() * .container() - * .includeCanonicalHeader() * .name() - * .prefix() + * .sasToken() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlob]. */ + /** A builder for [AzureBlobStorage]. */ 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 sasToken: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") + private var id: JsonField = JsonMissing.of() 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 { - 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 } + @JvmSynthetic + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + id = azureBlobStorage.id + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + } fun accountName(accountName: String) = accountName(JsonField.of(accountName)) @@ -3205,21 +3420,6 @@ private constructor( */ 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)) @@ -3232,16 +3432,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.sasToken] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } /** * Sets the field to an arbitrary JSON value. @@ -3257,6 +3457,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3272,6 +3483,32 @@ private constructor( 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) @@ -3292,55 +3529,55 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlob]. + * Returns an immutable instance of [AzureBlobStorage]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() * .accountName() * .container() - * .includeCanonicalHeader() * .name() - * .prefix() + * .sasToken() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlob = - AzureBlob( - checkRequired("id", id), + fun build(): AzureBlobStorage = + AzureBlobStorage( checkRequired("accountName", accountName), checkRequired("container", container), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("sasToken", sasToken), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AzureBlob = apply { + fun validate(): AzureBlobStorage = apply { if (validated) { return@apply } - id() accountName() container() - includeCanonicalHeader() name() - prefix() + sasToken() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -3360,42 +3597,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (accountName.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) + + (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 (id.asKnown().isPresent) 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 && - id == other.id && + return other is AzureBlobStorage && accountName == other.accountName && container == other.container && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + sasToken == other.sasToken && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, accountName, container, - includeCanonicalHeader, name, - prefix, + sasToken, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -3403,67 +3643,85 @@ private constructor( 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}" + "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim private constructor( - private val id: JsonField, private val baseUrl: JsonField, - private val includeCanonicalHeader: 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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("clientId") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( - id, baseUrl, - includeCanonicalHeader, + clientId, + clientSecret, name, + password, type, + username, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun clientId(): String = clientId.getRequired("clientId") /** - * Whether to send a Canonical header. + * 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 includeCanonicalHeader(): Boolean = - includeCanonicalHeader.getRequired("includeCanonicalHeader") + fun clientSecret(): String = clientSecret.getRequired("clientSecret") /** * Display name of the origin. @@ -3473,6 +3731,14 @@ private constructor( */ 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 @@ -3484,6 +3750,20 @@ private constructor( */ @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") + + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -3494,11 +3774,13 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** * Returns the raw JSON value of [baseUrl]. @@ -3508,14 +3790,21 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [clientId]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @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 _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _clientSecret(): JsonField = clientSecret /** * Returns the raw JSON value of [name]. @@ -3524,6 +3813,27 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3534,6 +3844,16 @@ private constructor( @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) @@ -3553,10 +3873,12 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .includeCanonicalHeader() + * .clientId() + * .clientSecret() * .name() + * .password() + * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3565,40 +3887,33 @@ private constructor( /** 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 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { - id = akeneoPim.id baseUrl = akeneoPim.baseUrl - includeCanonicalHeader = akeneoPim.includeCanonicalHeader + clientId = akeneoPim.clientId + clientSecret = akeneoPim.clientSecret name = akeneoPim.name + password = akeneoPim.password type = akeneoPim.type + username = akeneoPim.username + id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader + includeCanonicalHeader = akeneoPim.includeCanonicalHeader 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)) @@ -3611,19 +3926,30 @@ private constructor( */ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Whether to send a Canonical header. */ - fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = - includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + /** Akeneo API client ID. */ + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) /** - * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * Sets [Builder.clientId] 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. + * 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 includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { - this.includeCanonicalHeader = includeCanonicalHeader + 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. */ @@ -3638,6 +3964,18 @@ private constructor( */ 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. * @@ -3652,6 +3990,29 @@ private constructor( */ 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 } + + 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3667,6 +4028,21 @@ private constructor( 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) @@ -3693,22 +4069,28 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .includeCanonicalHeader() + * .clientId() + * .clientSecret() * .name() + * .password() + * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( - checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("clientId", clientId), + checkRequired("clientSecret", clientSecret), checkRequired("name", name), + checkRequired("password", password), type, + checkRequired("username", username), + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -3720,16 +4102,20 @@ private constructor( return@apply } - id() baseUrl() - includeCanonicalHeader() + clientId() + clientSecret() name() + password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + username() + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() validated = true } @@ -3749,12 +4135,16 @@ private constructor( */ @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 (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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (username.asKnown().isPresent) 1 else 0) + + (if (id.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) { @@ -3762,23 +4152,31 @@ private constructor( } return other is AkeneoPim && - id == other.id && baseUrl == other.baseUrl && - includeCanonicalHeader == other.includeCanonicalHeader && + clientId == other.clientId && + clientSecret == other.clientSecret && name == other.name && + password == other.password && type == other.type && + username == other.username && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, baseUrl, - includeCanonicalHeader, + clientId, + clientSecret, name, + password, type, + username, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties, ) } @@ -3786,6 +4184,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{id=$id, baseUrl=$baseUrl, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt index 8ec0a69e..7ac98a64 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt @@ -19,15 +19,14 @@ 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.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 = OriginListResponse.Deserializer::class) @JsonSerialize(using = OriginListResponse.Serializer::class) class OriginListResponse @@ -37,8 +36,8 @@ private constructor( 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -53,9 +52,10 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun gcs(): Optional = Optional.ofNullable(gcs) + fun googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) - fun azureBlob(): Optional = Optional.ofNullable(azureBlob) + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -69,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGcs(): Boolean = gcs != null + fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null - fun isAzureBlob(): Boolean = azureBlob != null + fun isAzureBlobStorage(): Boolean = azureBlobStorage != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -85,9 +85,10 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGcs(): Gcs = gcs.getOrThrow("gcs") + fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") - fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -100,8 +101,9 @@ private constructor( 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -135,12 +137,14 @@ private constructor( webProxy.validate() } - override fun visitGcs(gcs: Gcs) { - gcs.validate() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() } - override fun visitAzureBlob(azureBlob: AzureBlob) { - azureBlob.validate() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -179,9 +183,12 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGcs(gcs: Gcs) = gcs.validity() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() - override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -200,8 +207,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - gcs == other.gcs && - azureBlob == other.azureBlob && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && akeneoPim == other.akeneoPim } @@ -212,8 +219,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - gcs, - azureBlob, + googleCloudStorageGcs, + azureBlobStorage, akeneoPim, ) @@ -224,8 +231,9 @@ private constructor( cloudinaryBackup != null -> "OriginListResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginListResponse{webFolder=$webFolder}" webProxy != null -> "OriginListResponse{webProxy=$webProxy}" - gcs != null -> "OriginListResponse{gcs=$gcs}" - azureBlob != null -> "OriginListResponse{azureBlob=$azureBlob}" + googleCloudStorageGcs != null -> + "OriginListResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "OriginListResponse{azureBlobStorage=$azureBlobStorage}" akeneoPim != null -> "OriginListResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginListResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginListResponse") @@ -247,9 +255,13 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginListResponse(webProxy = webProxy) - @JvmStatic fun ofGcs(gcs: Gcs) = OriginListResponse(gcs = gcs) + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + OriginListResponse(googleCloudStorageGcs = googleCloudStorageGcs) - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginListResponse(azureBlob = azureBlob) + @JvmStatic + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + OriginListResponse(azureBlobStorage = azureBlobStorage) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginListResponse(akeneoPim = akeneoPim) } @@ -270,9 +282,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGcs(gcs: Gcs): T + fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T - fun visitAzureBlob(azureBlob: AzureBlob): T + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -295,52 +307,46 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginListResponse { val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(s3 = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(s3Compatible = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(cloudinaryBackup = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(webFolder = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(webProxy = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(gcs = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(azureBlob = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(akeneoPim = it, _json = json) - } ?: OriginListResponse(_json = json) - } + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(akeneoPim = 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 -> OriginListResponse(_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() } - - return OriginListResponse(_json = json) } } @@ -357,8 +363,9 @@ private constructor( 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) value.akeneoPim != null -> generator.writeObject(value.akeneoPim) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid OriginListResponse") @@ -368,48 +375,57 @@ private constructor( class S3 private constructor( - private val id: JsonField, + private val accessKey: JsonField, private val bucket: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonField, + private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("accessKey") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -419,15 +435,6 @@ private constructor( */ 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. * @@ -437,12 +444,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Path prefix inside the bucket. + * 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 prefix(): String = prefix.getRequired("prefix") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -455,6 +462,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -465,28 +478,35 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [accessKey]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @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]. @@ -496,11 +516,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [secretKey]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * 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 [baseUrlForCanonicalHeader]. @@ -512,6 +539,23 @@ private constructor( @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) @@ -531,11 +575,10 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -544,41 +587,42 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: JsonField? = null private var bucket: JsonField? = null - private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonField? = null + private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3") + private var id: JsonField = JsonMissing.of() 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 { - id = s3.id + accessKey = s3.accessKey bucket = s3.bucket - includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - prefix = s3.prefix + secretKey = s3.secretKey type = s3.type + id = s3.id baseUrlForCanonicalHeader = s3.baseUrlForCanonicalHeader + includeCanonicalHeader = s3.includeCanonicalHeader + prefix = s3.prefix 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -592,21 +636,6 @@ private constructor( */ 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)) @@ -619,17 +648,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -645,6 +674,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -660,6 +700,33 @@ private constructor( 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) @@ -686,24 +753,25 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } @@ -715,17 +783,19 @@ private constructor( return@apply } - id() + accessKey() bucket() - includeCanonicalHeader() name() - prefix() + secretKey() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -745,13 +815,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -759,25 +831,29 @@ private constructor( } return other is S3 && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -785,63 +861,72 @@ private constructor( 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}" + "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val id: JsonField, + private val accessKey: 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 secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val s3ForcePathStyle: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: 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, + accessKey, bucket, endpoint, - includeCanonicalHeader, name, - prefix, - s3ForcePathStyle, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -859,15 +944,6 @@ private constructor( */ 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. * @@ -877,20 +953,12 @@ private constructor( 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? + * 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 s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -903,6 +971,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -913,16 +987,41 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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). + */ + 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 @@ -934,21 +1033,45 @@ private constructor( @JsonProperty("endpoint") @ExcludeMissing fun _endpoint(): JsonField = endpoint /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * 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 [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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [prefix]. @@ -967,16 +1090,6 @@ private constructor( @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) @@ -996,13 +1109,11 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() * .endpoint() - * .includeCanonicalHeader() * .name() - * .prefix() - * .s3ForcePathStyle() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -1011,45 +1122,46 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: 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 secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") + private var id: JsonField = JsonMissing.of() 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 { - id = s3Compatible.id + accessKey = s3Compatible.accessKey bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - includeCanonicalHeader = s3Compatible.includeCanonicalHeader name = s3Compatible.name - prefix = s3Compatible.prefix - s3ForcePathStyle = s3Compatible.s3ForcePathStyle + secretKey = s3Compatible.secretKey type = s3Compatible.type + id = s3Compatible.id baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader + includeCanonicalHeader = s3Compatible.includeCanonicalHeader + prefix = s3Compatible.prefix + s3ForcePathStyle = s3Compatible.s3ForcePathStyle 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1075,21 +1187,6 @@ private constructor( */ 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)) @@ -1102,32 +1199,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -1143,6 +1225,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1158,6 +1251,48 @@ private constructor( 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) @@ -1184,28 +1319,28 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() * .endpoint() - * .includeCanonicalHeader() * .name() - * .prefix() - * .s3ForcePathStyle() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), - checkRequired("s3ForcePathStyle", s3ForcePathStyle), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1217,19 +1352,21 @@ private constructor( return@apply } - id() + accessKey() bucket() endpoint() - includeCanonicalHeader() name() - prefix() - s3ForcePathStyle() + secretKey() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + s3ForcePathStyle() validated = true } @@ -1249,15 +1386,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -1265,29 +1404,33 @@ private constructor( } return other is S3Compatible && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && endpoint == other.endpoint && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && - s3ForcePathStyle == other.s3ForcePathStyle && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + s3ForcePathStyle == other.s3ForcePathStyle && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, endpoint, - includeCanonicalHeader, name, - prefix, - s3ForcePathStyle, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, additionalProperties, ) } @@ -1295,53 +1438,62 @@ private constructor( 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}" + "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" } class CloudinaryBackup private constructor( - private val id: JsonField, + private val accessKey: JsonField, private val bucket: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonField, + private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("accessKey") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -1351,15 +1503,6 @@ private constructor( */ 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. * @@ -1369,12 +1512,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Path prefix inside the bucket. + * 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 prefix(): String = prefix.getRequired("prefix") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -1387,6 +1530,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -1397,28 +1546,35 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [accessKey]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @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]. @@ -1428,11 +1584,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [secretKey]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * 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 [baseUrlForCanonicalHeader]. @@ -1444,6 +1607,23 @@ private constructor( @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) @@ -1463,11 +1643,10 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -1476,41 +1655,42 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: JsonField? = null private var bucket: JsonField? = null - private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonField? = null + private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") + private var id: JsonField = JsonMissing.of() 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 { - id = cloudinaryBackup.id + accessKey = cloudinaryBackup.accessKey bucket = cloudinaryBackup.bucket - includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - prefix = cloudinaryBackup.prefix + secretKey = cloudinaryBackup.secretKey type = cloudinaryBackup.type + id = cloudinaryBackup.id baseUrlForCanonicalHeader = cloudinaryBackup.baseUrlForCanonicalHeader + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader + prefix = cloudinaryBackup.prefix 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1524,21 +1704,6 @@ private constructor( */ 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)) @@ -1551,17 +1716,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -1577,6 +1742,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1592,6 +1768,33 @@ private constructor( 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) @@ -1618,24 +1821,25 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } @@ -1647,17 +1851,19 @@ private constructor( return@apply } - id() + accessKey() bucket() - includeCanonicalHeader() name() - prefix() + secretKey() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -1677,13 +1883,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -1691,25 +1899,29 @@ private constructor( } return other is CloudinaryBackup && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -1717,56 +1929,47 @@ private constructor( 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}" + "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, 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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: 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, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, 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. * @@ -1775,24 +1978,6 @@ private constructor( */ 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. * @@ -1812,6 +1997,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -1822,11 +2013,22 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Forward the Host header to origin? * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -1836,41 +2038,48 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** - * Returns the raw JSON value of [forwardHostHeaderToOrigin]. + * Returns the raw JSON value of [name]. * - * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("forwardHostHeaderToOrigin") - @ExcludeMissing - fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [id]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [forwardHostHeaderToOrigin]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1891,10 +2100,7 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .forwardHostHeaderToOrigin() - * .includeCanonicalHeader() * .name() * ``` */ @@ -1904,42 +2110,27 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { - 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 } - + @JvmSynthetic + internal fun from(webFolder: WebFolder) = apply { + baseUrl = webFolder.baseUrl + name = webFolder.name + type = webFolder.type + id = webFolder.id + 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)) @@ -1952,36 +2143,6 @@ private constructor( */ 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)) @@ -2008,6 +2169,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2023,6 +2195,36 @@ private constructor( 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) @@ -2049,10 +2251,7 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .forwardHostHeaderToOrigin() - * .includeCanonicalHeader() * .name() * ``` * @@ -2060,13 +2259,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( - checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2078,17 +2277,17 @@ private constructor( return@apply } - id() baseUrl() - forwardHostHeaderToOrigin() - includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + forwardHostHeaderToOrigin() + includeCanonicalHeader() validated = true } @@ -2108,13 +2307,13 @@ private constructor( */ @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 (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 (id.asKnown().isPresent) 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) { @@ -2122,25 +2321,25 @@ private constructor( } return other is WebFolder && - id == other.id && baseUrl == other.baseUrl && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, baseUrl, - forwardHostHeaderToOrigin, - includeCanonicalHeader, name, type, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, additionalProperties, ) } @@ -2148,49 +2347,31 @@ private constructor( 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}" + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } class WebProxy private constructor( - private val id: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = 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") + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) /** * Display name of the origin. @@ -2211,6 +2392,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -2221,28 +2408,27 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [id]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2254,6 +2440,16 @@ private constructor( @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) @@ -2273,8 +2469,6 @@ private constructor( * * The following fields are required: * ```java - * .id() - * .includeCanonicalHeader() * .name() * ``` */ @@ -2284,53 +2478,23 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: 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 + id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader + includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2357,6 +2521,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2372,6 +2547,21 @@ private constructor( 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) @@ -2398,8 +2588,6 @@ private constructor( * * The following fields are required: * ```java - * .id() - * .includeCanonicalHeader() * .name() * ``` * @@ -2407,11 +2595,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( - checkRequired("id", id), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2423,15 +2611,15 @@ private constructor( return@apply } - id() - includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() validated = true } @@ -2451,11 +2639,11 @@ private constructor( */ @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) + + (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 (id.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) { @@ -2463,21 +2651,21 @@ private constructor( } return other is WebProxy && - id == other.id && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, - includeCanonicalHeader, name, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties, ) } @@ -2485,59 +2673,55 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class Gcs + class GoogleCloudStorageGcs 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 privateKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: 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("privateKey") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, bucket, clientEmail, - includeCanonicalHeader, name, - prefix, + privateKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, 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). @@ -2550,15 +2734,6 @@ private constructor( */ 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. * @@ -2571,7 +2746,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 prefix(): String = prefix.getRequired("prefix") + fun privateKey(): String = privateKey.getRequired("privateKey") /** * Expected to always return the following: @@ -2584,6 +2759,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -2594,11 +2775,19 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -2617,28 +2806,27 @@ private constructor( fun _clientEmail(): JsonField = clientEmail /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [privateKey]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("privateKey") + @ExcludeMissing + fun _privateKey(): JsonField = privateKey /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [id]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2650,6 +2838,23 @@ private constructor( @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) @@ -2665,62 +2870,47 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Gcs]. + * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. * * The following fields are required: * ```java - * .id() * .bucket() * .clientEmail() - * .includeCanonicalHeader() * .name() - * .prefix() + * .privateKey() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Gcs]. */ + /** A builder for [GoogleCloudStorageGcs]. */ 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 privateKey: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") + private var id: JsonField = JsonMissing.of() 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 { - 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() + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + id = googleCloudStorageGcs.id + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.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)) /** @@ -2745,21 +2935,6 @@ private constructor( 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)) @@ -2772,16 +2947,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.privateKey] 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 + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } /** * Sets the field to an arbitrary JSON value. @@ -2797,6 +2972,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2812,6 +2998,32 @@ private constructor( 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) @@ -2832,55 +3044,55 @@ private constructor( } /** - * Returns an immutable instance of [Gcs]. + * Returns an immutable instance of [GoogleCloudStorageGcs]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() * .bucket() * .clientEmail() - * .includeCanonicalHeader() * .name() - * .prefix() + * .privateKey() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Gcs = - Gcs( - checkRequired("id", id), + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("privateKey", privateKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Gcs = apply { + fun validate(): GoogleCloudStorageGcs = apply { if (validated) { return@apply } - id() bucket() clientEmail() - includeCanonicalHeader() name() - prefix() + privateKey() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -2900,42 +3112,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (bucket.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) + + (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 (id.asKnown().isPresent) 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 && - id == other.id && + return other is GoogleCloudStorageGcs && bucket == other.bucket && clientEmail == other.clientEmail && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + privateKey == other.privateKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, bucket, clientEmail, - includeCanonicalHeader, name, - prefix, + privateKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -2943,61 +3158,57 @@ private constructor( 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}" + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlob + class AzureBlobStorage 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 sasToken: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: 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("sasToken") + @ExcludeMissing + sasToken: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, accountName, container, - includeCanonicalHeader, name, - prefix, + sasToken, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, 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). @@ -3010,15 +3221,6 @@ private constructor( */ 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. * @@ -3031,7 +3233,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 prefix(): String = prefix.getRequired("prefix") + fun sasToken(): String = sasToken.getRequired("sasToken") /** * Expected to always return the following: @@ -3044,6 +3246,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -3054,11 +3262,19 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -3077,28 +3293,25 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [sasToken]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [id]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3110,6 +3323,23 @@ private constructor( @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) @@ -3125,61 +3355,46 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlob]. + * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. * * The following fields are required: * ```java - * .id() * .accountName() * .container() - * .includeCanonicalHeader() * .name() - * .prefix() + * .sasToken() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlob]. */ + /** A builder for [AzureBlobStorage]. */ 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 sasToken: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") + private var id: JsonField = JsonMissing.of() 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 { - 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 } + @JvmSynthetic + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + id = azureBlobStorage.id + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + } fun accountName(accountName: String) = accountName(JsonField.of(accountName)) @@ -3205,21 +3420,6 @@ private constructor( */ 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)) @@ -3232,16 +3432,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.sasToken] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } /** * Sets the field to an arbitrary JSON value. @@ -3257,6 +3457,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3272,6 +3483,32 @@ private constructor( 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) @@ -3292,55 +3529,55 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlob]. + * Returns an immutable instance of [AzureBlobStorage]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() * .accountName() * .container() - * .includeCanonicalHeader() * .name() - * .prefix() + * .sasToken() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlob = - AzureBlob( - checkRequired("id", id), + fun build(): AzureBlobStorage = + AzureBlobStorage( checkRequired("accountName", accountName), checkRequired("container", container), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("sasToken", sasToken), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AzureBlob = apply { + fun validate(): AzureBlobStorage = apply { if (validated) { return@apply } - id() accountName() container() - includeCanonicalHeader() name() - prefix() + sasToken() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -3360,42 +3597,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (accountName.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) + + (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 (id.asKnown().isPresent) 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 && - id == other.id && + return other is AzureBlobStorage && accountName == other.accountName && container == other.container && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + sasToken == other.sasToken && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, accountName, container, - includeCanonicalHeader, name, - prefix, + sasToken, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -3403,67 +3643,85 @@ private constructor( 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}" + "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim private constructor( - private val id: JsonField, private val baseUrl: JsonField, - private val includeCanonicalHeader: 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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("clientId") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( - id, baseUrl, - includeCanonicalHeader, + clientId, + clientSecret, name, + password, type, + username, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun clientId(): String = clientId.getRequired("clientId") /** - * Whether to send a Canonical header. + * 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 includeCanonicalHeader(): Boolean = - includeCanonicalHeader.getRequired("includeCanonicalHeader") + fun clientSecret(): String = clientSecret.getRequired("clientSecret") /** * Display name of the origin. @@ -3473,6 +3731,14 @@ private constructor( */ 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 @@ -3484,6 +3750,20 @@ private constructor( */ @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") + + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -3494,11 +3774,13 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** * Returns the raw JSON value of [baseUrl]. @@ -3508,14 +3790,21 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [clientId]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @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 _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _clientSecret(): JsonField = clientSecret /** * Returns the raw JSON value of [name]. @@ -3524,6 +3813,27 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3534,6 +3844,16 @@ private constructor( @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) @@ -3553,10 +3873,12 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .includeCanonicalHeader() + * .clientId() + * .clientSecret() * .name() + * .password() + * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3565,40 +3887,33 @@ private constructor( /** 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 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { - id = akeneoPim.id baseUrl = akeneoPim.baseUrl - includeCanonicalHeader = akeneoPim.includeCanonicalHeader + clientId = akeneoPim.clientId + clientSecret = akeneoPim.clientSecret name = akeneoPim.name + password = akeneoPim.password type = akeneoPim.type + username = akeneoPim.username + id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader + includeCanonicalHeader = akeneoPim.includeCanonicalHeader 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)) @@ -3611,19 +3926,30 @@ private constructor( */ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Whether to send a Canonical header. */ - fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = - includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + /** Akeneo API client ID. */ + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) /** - * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * Sets [Builder.clientId] 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. + * 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 includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { - this.includeCanonicalHeader = includeCanonicalHeader + 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. */ @@ -3638,6 +3964,18 @@ private constructor( */ 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. * @@ -3652,6 +3990,29 @@ private constructor( */ 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 } + + 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3667,6 +4028,21 @@ private constructor( 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) @@ -3693,22 +4069,28 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .includeCanonicalHeader() + * .clientId() + * .clientSecret() * .name() + * .password() + * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( - checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("clientId", clientId), + checkRequired("clientSecret", clientSecret), checkRequired("name", name), + checkRequired("password", password), type, + checkRequired("username", username), + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -3720,16 +4102,20 @@ private constructor( return@apply } - id() baseUrl() - includeCanonicalHeader() + clientId() + clientSecret() name() + password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + username() + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() validated = true } @@ -3749,12 +4135,16 @@ private constructor( */ @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 (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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (username.asKnown().isPresent) 1 else 0) + + (if (id.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) { @@ -3762,23 +4152,31 @@ private constructor( } return other is AkeneoPim && - id == other.id && baseUrl == other.baseUrl && - includeCanonicalHeader == other.includeCanonicalHeader && + clientId == other.clientId && + clientSecret == other.clientSecret && name == other.name && + password == other.password && type == other.type && + username == other.username && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, baseUrl, - includeCanonicalHeader, + clientId, + clientSecret, name, + password, type, + username, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties, ) } @@ -3786,6 +4184,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{id=$id, baseUrl=$baseUrl, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, 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 index ce410564..b8b7df8d 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 @@ -2,30 +2,10 @@ 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.Params 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.errors.ImageKitInvalidDataException -import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -265,3996 +245,6 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - /** Schema for origin resources. */ - @JsonDeserialize(using = Origin.Deserializer::class) - @JsonSerialize(using = Origin.Serializer::class) - class Origin - 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(): Origin = 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 Origin && - 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 -> "Origin{s3=$s3}" - s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "Origin{webFolder=$webFolder}" - webProxy != null -> "Origin{webProxy=$webProxy}" - gcs != null -> "Origin{gcs=$gcs}" - azureBlob != null -> "Origin{azureBlob=$azureBlob}" - akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" - _json != null -> "Origin{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Origin") - } - - companion object { - - @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) - - @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) - - @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - Origin(cloudinaryBackup = cloudinaryBackup) - - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) - - @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) - - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) - - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) - } - - /** An interface that defines how to map each variant of [Origin] 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 [Origin] to a value of type [T]. - * - * An instance of [Origin] 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 Origin: $json") - } - } - - internal class Deserializer : BaseDeserializer(Origin::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Origin { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3 = it, _json = json) - } ?: Origin(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3Compatible = it, _json = json) - } ?: Origin(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(cloudinaryBackup = it, _json = json) - } ?: Origin(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webFolder = it, _json = json) - } ?: Origin(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webProxy = it, _json = json) - } ?: Origin(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(gcs = it, _json = json) - } ?: Origin(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(azureBlob = it, _json = json) - } ?: Origin(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(akeneoPim = it, _json = json) - } ?: Origin(_json = json) - } - } - - return Origin(_json = json) - } - } - - internal class Serializer : BaseSerializer(Origin::class) { - - override fun serialize( - value: Origin, - 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 Origin") - } - } - } - - 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}" - } - } - 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/accounts/origins/OriginUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt index 06009d04..d6005a3e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt @@ -19,15 +19,14 @@ 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.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 = OriginUpdateResponse.Deserializer::class) @JsonSerialize(using = OriginUpdateResponse.Serializer::class) class OriginUpdateResponse @@ -37,8 +36,8 @@ private constructor( 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 googleCloudStorageGcs: GoogleCloudStorageGcs? = null, + private val azureBlobStorage: AzureBlobStorage? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -53,9 +52,10 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun gcs(): Optional = Optional.ofNullable(gcs) + fun googleCloudStorageGcs(): Optional = + Optional.ofNullable(googleCloudStorageGcs) - fun azureBlob(): Optional = Optional.ofNullable(azureBlob) + fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -69,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGcs(): Boolean = gcs != null + fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null - fun isAzureBlob(): Boolean = azureBlob != null + fun isAzureBlobStorage(): Boolean = azureBlobStorage != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -85,9 +85,10 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGcs(): Gcs = gcs.getOrThrow("gcs") + fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = + googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") - fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") + fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -100,8 +101,9 @@ private constructor( 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) + googleCloudStorageGcs != null -> + visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) + azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -135,12 +137,14 @@ private constructor( webProxy.validate() } - override fun visitGcs(gcs: Gcs) { - gcs.validate() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) { + googleCloudStorageGcs.validate() } - override fun visitAzureBlob(azureBlob: AzureBlob) { - azureBlob.validate() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { + azureBlobStorage.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -179,9 +183,12 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGcs(gcs: Gcs) = gcs.validity() + override fun visitGoogleCloudStorageGcs( + googleCloudStorageGcs: GoogleCloudStorageGcs + ) = googleCloudStorageGcs.validity() - override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() + override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + azureBlobStorage.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -200,8 +207,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - gcs == other.gcs && - azureBlob == other.azureBlob && + googleCloudStorageGcs == other.googleCloudStorageGcs && + azureBlobStorage == other.azureBlobStorage && akeneoPim == other.akeneoPim } @@ -212,8 +219,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - gcs, - azureBlob, + googleCloudStorageGcs, + azureBlobStorage, akeneoPim, ) @@ -224,8 +231,9 @@ private constructor( cloudinaryBackup != null -> "OriginUpdateResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginUpdateResponse{webFolder=$webFolder}" webProxy != null -> "OriginUpdateResponse{webProxy=$webProxy}" - gcs != null -> "OriginUpdateResponse{gcs=$gcs}" - azureBlob != null -> "OriginUpdateResponse{azureBlob=$azureBlob}" + googleCloudStorageGcs != null -> + "OriginUpdateResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" + azureBlobStorage != null -> "OriginUpdateResponse{azureBlobStorage=$azureBlobStorage}" akeneoPim != null -> "OriginUpdateResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginUpdateResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginUpdateResponse") @@ -248,10 +256,13 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginUpdateResponse(webProxy = webProxy) - @JvmStatic fun ofGcs(gcs: Gcs) = OriginUpdateResponse(gcs = gcs) + @JvmStatic + fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = + OriginUpdateResponse(googleCloudStorageGcs = googleCloudStorageGcs) @JvmStatic - fun ofAzureBlob(azureBlob: AzureBlob) = OriginUpdateResponse(azureBlob = azureBlob) + fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = + OriginUpdateResponse(azureBlobStorage = azureBlobStorage) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginUpdateResponse(akeneoPim = akeneoPim) @@ -273,9 +284,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGcs(gcs: Gcs): T + fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T - fun visitAzureBlob(azureBlob: AzureBlob): T + fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -299,52 +310,46 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginUpdateResponse { val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(s3 = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(s3Compatible = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(cloudinaryBackup = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(webFolder = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(webProxy = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(gcs = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(azureBlob = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(akeneoPim = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(s3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(s3Compatible = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(cloudinaryBackup = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(webFolder = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(webProxy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(googleCloudStorageGcs = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(azureBlobStorage = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(akeneoPim = 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 -> OriginUpdateResponse(_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() } - - return OriginUpdateResponse(_json = json) } } @@ -361,8 +366,9 @@ private constructor( 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.googleCloudStorageGcs != null -> + generator.writeObject(value.googleCloudStorageGcs) + value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) value.akeneoPim != null -> generator.writeObject(value.akeneoPim) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid OriginUpdateResponse") @@ -372,48 +378,57 @@ private constructor( class S3 private constructor( - private val id: JsonField, + private val accessKey: JsonField, private val bucket: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonField, + private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("accessKey") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -423,15 +438,6 @@ private constructor( */ 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. * @@ -441,12 +447,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Path prefix inside the bucket. + * 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 prefix(): String = prefix.getRequired("prefix") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -459,6 +465,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -469,28 +481,35 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [accessKey]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @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]. @@ -500,11 +519,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [secretKey]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * 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 [baseUrlForCanonicalHeader]. @@ -516,6 +542,23 @@ private constructor( @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) @@ -535,11 +578,10 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -548,41 +590,42 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: JsonField? = null private var bucket: JsonField? = null - private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonField? = null + private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3") + private var id: JsonField = JsonMissing.of() 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 { - id = s3.id + accessKey = s3.accessKey bucket = s3.bucket - includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - prefix = s3.prefix + secretKey = s3.secretKey type = s3.type + id = s3.id baseUrlForCanonicalHeader = s3.baseUrlForCanonicalHeader + includeCanonicalHeader = s3.includeCanonicalHeader + prefix = s3.prefix 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -596,21 +639,6 @@ private constructor( */ 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)) @@ -623,17 +651,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -649,6 +677,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -664,6 +703,33 @@ private constructor( 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) @@ -690,24 +756,25 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } @@ -719,17 +786,19 @@ private constructor( return@apply } - id() + accessKey() bucket() - includeCanonicalHeader() name() - prefix() + secretKey() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -749,13 +818,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -763,25 +834,29 @@ private constructor( } return other is S3 && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -789,63 +864,72 @@ private constructor( 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}" + "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val id: JsonField, + private val accessKey: 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 secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val s3ForcePathStyle: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: 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, + accessKey, bucket, endpoint, - includeCanonicalHeader, name, - prefix, - s3ForcePathStyle, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -863,15 +947,6 @@ private constructor( */ 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. * @@ -881,20 +956,12 @@ private constructor( 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? + * 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 s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -907,6 +974,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -917,18 +990,43 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + 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]. @@ -938,21 +1036,45 @@ private constructor( @JsonProperty("endpoint") @ExcludeMissing fun _endpoint(): JsonField = endpoint /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * 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 [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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [prefix]. @@ -971,16 +1093,6 @@ private constructor( @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) @@ -1000,13 +1112,11 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() * .endpoint() - * .includeCanonicalHeader() * .name() - * .prefix() - * .s3ForcePathStyle() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -1015,45 +1125,46 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: 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 secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") + private var id: JsonField = JsonMissing.of() 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 { - id = s3Compatible.id + accessKey = s3Compatible.accessKey bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - includeCanonicalHeader = s3Compatible.includeCanonicalHeader name = s3Compatible.name - prefix = s3Compatible.prefix - s3ForcePathStyle = s3Compatible.s3ForcePathStyle + secretKey = s3Compatible.secretKey type = s3Compatible.type + id = s3Compatible.id baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader + includeCanonicalHeader = s3Compatible.includeCanonicalHeader + prefix = s3Compatible.prefix + s3ForcePathStyle = s3Compatible.s3ForcePathStyle 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1079,21 +1190,6 @@ private constructor( */ 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)) @@ -1106,32 +1202,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -1147,6 +1228,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1162,6 +1254,48 @@ private constructor( 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) @@ -1188,28 +1322,28 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() * .endpoint() - * .includeCanonicalHeader() * .name() - * .prefix() - * .s3ForcePathStyle() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), - checkRequired("s3ForcePathStyle", s3ForcePathStyle), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1221,19 +1355,21 @@ private constructor( return@apply } - id() + accessKey() bucket() endpoint() - includeCanonicalHeader() name() - prefix() - s3ForcePathStyle() + secretKey() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + s3ForcePathStyle() validated = true } @@ -1253,15 +1389,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -1269,29 +1407,33 @@ private constructor( } return other is S3Compatible && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && endpoint == other.endpoint && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && - s3ForcePathStyle == other.s3ForcePathStyle && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + s3ForcePathStyle == other.s3ForcePathStyle && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, endpoint, - includeCanonicalHeader, name, - prefix, - s3ForcePathStyle, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, additionalProperties, ) } @@ -1299,53 +1441,62 @@ private constructor( 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}" + "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" } class CloudinaryBackup private constructor( - private val id: JsonField, + private val accessKey: JsonField, private val bucket: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val prefix: JsonField, + private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("accessKey") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun accessKey(): String = accessKey.getRequired("accessKey") /** * S3 bucket name. @@ -1355,15 +1506,6 @@ private constructor( */ 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. * @@ -1373,12 +1515,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Path prefix inside the bucket. + * 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 prefix(): String = prefix.getRequired("prefix") + fun secretKey(): String = secretKey.getRequired("secretKey") /** * Expected to always return the following: @@ -1391,6 +1533,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -1401,28 +1549,35 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [bucket]. + * Path prefix inside the bucket. * - * Unlike [bucket], 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("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + fun prefix(): Optional = prefix.getOptional("prefix") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [accessKey]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @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]. @@ -1432,11 +1587,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [secretKey]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * 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 [baseUrlForCanonicalHeader]. @@ -1448,6 +1610,23 @@ private constructor( @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) @@ -1467,11 +1646,10 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -1480,41 +1658,42 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var id: JsonField? = null + private var accessKey: JsonField? = null private var bucket: JsonField? = null - private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var prefix: JsonField? = null + private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") + private var id: JsonField = JsonMissing.of() 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 { - id = cloudinaryBackup.id + accessKey = cloudinaryBackup.accessKey bucket = cloudinaryBackup.bucket - includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - prefix = cloudinaryBackup.prefix + secretKey = cloudinaryBackup.secretKey type = cloudinaryBackup.type + id = cloudinaryBackup.id baseUrlForCanonicalHeader = cloudinaryBackup.baseUrlForCanonicalHeader + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader + prefix = cloudinaryBackup.prefix 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)) + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.accessKey] 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. + * 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 id(id: JsonField) = apply { this.id = id } + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1528,21 +1707,6 @@ private constructor( */ 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)) @@ -1555,17 +1719,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Path prefix inside the bucket. */ - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.secretKey] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } /** * Sets the field to an arbitrary JSON value. @@ -1581,6 +1745,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1596,6 +1771,33 @@ private constructor( 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) @@ -1622,24 +1824,25 @@ private constructor( * * The following fields are required: * ```java - * .id() + * .accessKey() * .bucket() - * .includeCanonicalHeader() * .name() - * .prefix() + * .secretKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("id", id), + checkRequired("accessKey", accessKey), checkRequired("bucket", bucket), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } @@ -1651,17 +1854,19 @@ private constructor( return@apply } - id() + accessKey() bucket() - includeCanonicalHeader() name() - prefix() + secretKey() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -1681,13 +1886,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + + (if (accessKey.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) + + (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 (id.asKnown().isPresent) 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) { @@ -1695,25 +1902,29 @@ private constructor( } return other is CloudinaryBackup && - id == other.id && + accessKey == other.accessKey && bucket == other.bucket && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, + accessKey, bucket, - includeCanonicalHeader, name, - prefix, + secretKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -1721,56 +1932,47 @@ private constructor( 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}" + "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, 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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: 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, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, 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. * @@ -1779,24 +1981,6 @@ private constructor( */ 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. * @@ -1816,6 +2000,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -1826,11 +2016,22 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Forward the Host header to origin? * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -1840,41 +2041,48 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** - * Returns the raw JSON value of [forwardHostHeaderToOrigin]. + * Returns the raw JSON value of [name]. * - * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("forwardHostHeaderToOrigin") - @ExcludeMissing - fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [id]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [forwardHostHeaderToOrigin]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1895,10 +2103,7 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .forwardHostHeaderToOrigin() - * .includeCanonicalHeader() * .name() * ``` */ @@ -1908,42 +2113,27 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { - 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 } - + @JvmSynthetic + internal fun from(webFolder: WebFolder) = apply { + baseUrl = webFolder.baseUrl + name = webFolder.name + type = webFolder.type + id = webFolder.id + 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)) @@ -1956,36 +2146,6 @@ private constructor( */ 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)) @@ -2012,6 +2172,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2027,6 +2198,36 @@ private constructor( 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) @@ -2053,10 +2254,7 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .forwardHostHeaderToOrigin() - * .includeCanonicalHeader() * .name() * ``` * @@ -2064,13 +2262,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( - checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2082,17 +2280,17 @@ private constructor( return@apply } - id() baseUrl() - forwardHostHeaderToOrigin() - includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + forwardHostHeaderToOrigin() + includeCanonicalHeader() validated = true } @@ -2112,13 +2310,13 @@ private constructor( */ @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 (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 (id.asKnown().isPresent) 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) { @@ -2126,25 +2324,25 @@ private constructor( } return other is WebFolder && - id == other.id && baseUrl == other.baseUrl && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, baseUrl, - forwardHostHeaderToOrigin, - includeCanonicalHeader, name, type, + id, baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, additionalProperties, ) } @@ -2152,49 +2350,31 @@ private constructor( 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}" + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } class WebProxy private constructor( - private val id: JsonField, - private val includeCanonicalHeader: JsonField, private val name: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = 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") + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) /** * Display name of the origin. @@ -2215,6 +2395,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -2225,28 +2411,27 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [id]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2258,6 +2443,16 @@ private constructor( @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) @@ -2277,8 +2472,6 @@ private constructor( * * The following fields are required: * ```java - * .id() - * .includeCanonicalHeader() * .name() * ``` */ @@ -2288,53 +2481,23 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: 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 + id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader + includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2361,6 +2524,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2376,6 +2550,21 @@ private constructor( 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) @@ -2402,8 +2591,6 @@ private constructor( * * The following fields are required: * ```java - * .id() - * .includeCanonicalHeader() * .name() * ``` * @@ -2411,11 +2598,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( - checkRequired("id", id), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2427,15 +2614,15 @@ private constructor( return@apply } - id() - includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() validated = true } @@ -2455,11 +2642,11 @@ private constructor( */ @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) + + (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 (id.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) { @@ -2467,21 +2654,21 @@ private constructor( } return other is WebProxy && - id == other.id && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, - includeCanonicalHeader, name, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties, ) } @@ -2489,59 +2676,55 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } - class Gcs + class GoogleCloudStorageGcs 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 privateKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: 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("privateKey") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, bucket, clientEmail, - includeCanonicalHeader, name, - prefix, + privateKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, 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). @@ -2554,15 +2737,6 @@ private constructor( */ 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. * @@ -2575,7 +2749,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 prefix(): String = prefix.getRequired("prefix") + fun privateKey(): String = privateKey.getRequired("privateKey") /** * Expected to always return the following: @@ -2588,6 +2762,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -2598,11 +2778,19 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -2621,28 +2809,27 @@ private constructor( fun _clientEmail(): JsonField = clientEmail /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [privateKey]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("privateKey") + @ExcludeMissing + fun _privateKey(): JsonField = privateKey /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [id]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2654,6 +2841,23 @@ private constructor( @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) @@ -2669,62 +2873,47 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Gcs]. + * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. * * The following fields are required: * ```java - * .id() * .bucket() * .clientEmail() - * .includeCanonicalHeader() * .name() - * .prefix() + * .privateKey() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Gcs]. */ + /** A builder for [GoogleCloudStorageGcs]. */ 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 privateKey: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") + private var id: JsonField = JsonMissing.of() 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 { - 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() + internal fun from(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { + bucket = googleCloudStorageGcs.bucket + clientEmail = googleCloudStorageGcs.clientEmail + name = googleCloudStorageGcs.name + privateKey = googleCloudStorageGcs.privateKey + type = googleCloudStorageGcs.type + id = googleCloudStorageGcs.id + baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader + includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader + prefix = googleCloudStorageGcs.prefix + additionalProperties = googleCloudStorageGcs.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)) /** @@ -2749,21 +2938,6 @@ private constructor( 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)) @@ -2776,16 +2950,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.privateKey] 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 + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } /** * Sets the field to an arbitrary JSON value. @@ -2801,6 +2975,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2816,6 +3001,32 @@ private constructor( 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) @@ -2836,55 +3047,55 @@ private constructor( } /** - * Returns an immutable instance of [Gcs]. + * Returns an immutable instance of [GoogleCloudStorageGcs]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() * .bucket() * .clientEmail() - * .includeCanonicalHeader() * .name() - * .prefix() + * .privateKey() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Gcs = - Gcs( - checkRequired("id", id), + fun build(): GoogleCloudStorageGcs = + GoogleCloudStorageGcs( checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("privateKey", privateKey), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Gcs = apply { + fun validate(): GoogleCloudStorageGcs = apply { if (validated) { return@apply } - id() bucket() clientEmail() - includeCanonicalHeader() name() - prefix() + privateKey() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -2904,42 +3115,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (bucket.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) + + (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 (id.asKnown().isPresent) 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 && - id == other.id && + return other is GoogleCloudStorageGcs && bucket == other.bucket && clientEmail == other.clientEmail && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + privateKey == other.privateKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, bucket, clientEmail, - includeCanonicalHeader, name, - prefix, + privateKey, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -2947,61 +3161,57 @@ private constructor( 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}" + "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } - class AzureBlob + class AzureBlobStorage 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 sasToken: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: 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("sasToken") + @ExcludeMissing + sasToken: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( - id, accountName, container, - includeCanonicalHeader, name, - prefix, + sasToken, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, 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). @@ -3014,15 +3224,6 @@ private constructor( */ 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. * @@ -3035,7 +3236,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 prefix(): String = prefix.getRequired("prefix") + fun sasToken(): String = sasToken.getRequired("sasToken") /** * Expected to always return the following: @@ -3048,6 +3249,12 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -3058,11 +3265,19 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + 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]. @@ -3081,28 +3296,25 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [name]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [sasToken]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken /** - * Returns the raw JSON value of [prefix]. + * Returns the raw JSON value of [id]. * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3114,6 +3326,23 @@ private constructor( @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) @@ -3129,61 +3358,46 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlob]. + * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. * * The following fields are required: * ```java - * .id() * .accountName() * .container() - * .includeCanonicalHeader() * .name() - * .prefix() + * .sasToken() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlob]. */ + /** A builder for [AzureBlobStorage]. */ 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 sasToken: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") + private var id: JsonField = JsonMissing.of() 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 { - 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 } + @JvmSynthetic + internal fun from(azureBlobStorage: AzureBlobStorage) = apply { + accountName = azureBlobStorage.accountName + container = azureBlobStorage.container + name = azureBlobStorage.name + sasToken = azureBlobStorage.sasToken + type = azureBlobStorage.type + id = azureBlobStorage.id + baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader + prefix = azureBlobStorage.prefix + additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() + } fun accountName(accountName: String) = accountName(JsonField.of(accountName)) @@ -3209,21 +3423,6 @@ private constructor( */ 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)) @@ -3236,16 +3435,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) /** - * Sets [Builder.prefix] to an arbitrary JSON value. + * Sets [Builder.sasToken] to an arbitrary JSON value. * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * 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 prefix(prefix: JsonField) = apply { this.prefix = prefix } + fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } /** * Sets the field to an arbitrary JSON value. @@ -3261,6 +3460,17 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3276,6 +3486,32 @@ private constructor( 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) @@ -3296,55 +3532,55 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlob]. + * Returns an immutable instance of [AzureBlobStorage]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .id() * .accountName() * .container() - * .includeCanonicalHeader() * .name() - * .prefix() + * .sasToken() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlob = - AzureBlob( - checkRequired("id", id), + fun build(): AzureBlobStorage = + AzureBlobStorage( checkRequired("accountName", accountName), checkRequired("container", container), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("prefix", prefix), + checkRequired("sasToken", sasToken), type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AzureBlob = apply { + fun validate(): AzureBlobStorage = apply { if (validated) { return@apply } - id() accountName() container() - includeCanonicalHeader() name() - prefix() + sasToken() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() validated = true } @@ -3364,42 +3600,45 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (accountName.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) + + (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 (id.asKnown().isPresent) 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 && - id == other.id && + return other is AzureBlobStorage && accountName == other.accountName && container == other.container && - includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - prefix == other.prefix && + sasToken == other.sasToken && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, accountName, container, - includeCanonicalHeader, name, - prefix, + sasToken, type, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, additionalProperties, ) } @@ -3407,67 +3646,85 @@ private constructor( 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}" + "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim private constructor( - private val id: JsonField, private val baseUrl: JsonField, - private val includeCanonicalHeader: 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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") + @JsonProperty("clientId") @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( - id, baseUrl, - includeCanonicalHeader, + clientId, + clientSecret, name, + password, type, + username, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, mutableMapOf(), ) /** - * Unique identifier for the origin. This is generated by ImageKit when you create a new - * origin. + * 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 id(): String = id.getRequired("id") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun clientId(): String = clientId.getRequired("clientId") /** - * Whether to send a Canonical header. + * 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 includeCanonicalHeader(): Boolean = - includeCanonicalHeader.getRequired("includeCanonicalHeader") + fun clientSecret(): String = clientSecret.getRequired("clientSecret") /** * Display name of the origin. @@ -3477,6 +3734,14 @@ private constructor( */ 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 @@ -3488,6 +3753,20 @@ private constructor( */ @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") + + /** + * @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") + /** * URL used in the Canonical header (if enabled). * @@ -3498,11 +3777,13 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Returns the raw JSON value of [id]. + * Whether to send a Canonical header. * - * Unlike [id], 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("id") @ExcludeMissing fun _id(): JsonField = id + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") /** * Returns the raw JSON value of [baseUrl]. @@ -3512,14 +3793,21 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** - * Returns the raw JSON value of [includeCanonicalHeader]. + * Returns the raw JSON value of [clientId]. * - * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("includeCanonicalHeader") + @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 _includeCanonicalHeader(): JsonField = includeCanonicalHeader + fun _clientSecret(): JsonField = clientSecret /** * Returns the raw JSON value of [name]. @@ -3528,6 +3816,27 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3538,6 +3847,16 @@ private constructor( @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) @@ -3557,10 +3876,12 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .includeCanonicalHeader() + * .clientId() + * .clientSecret() * .name() + * .password() + * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3569,40 +3890,33 @@ private constructor( /** 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 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { - id = akeneoPim.id baseUrl = akeneoPim.baseUrl - includeCanonicalHeader = akeneoPim.includeCanonicalHeader + clientId = akeneoPim.clientId + clientSecret = akeneoPim.clientSecret name = akeneoPim.name + password = akeneoPim.password type = akeneoPim.type + username = akeneoPim.username + id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader + includeCanonicalHeader = akeneoPim.includeCanonicalHeader 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)) @@ -3615,19 +3929,30 @@ private constructor( */ fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Whether to send a Canonical header. */ - fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = - includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + /** Akeneo API client ID. */ + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) /** - * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * Sets [Builder.clientId] 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. + * 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 includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { - this.includeCanonicalHeader = includeCanonicalHeader + 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. */ @@ -3642,6 +3967,18 @@ private constructor( */ 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. * @@ -3656,6 +3993,29 @@ private constructor( */ 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 } + + 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3671,6 +4031,21 @@ private constructor( 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) @@ -3697,22 +4072,28 @@ private constructor( * * The following fields are required: * ```java - * .id() * .baseUrl() - * .includeCanonicalHeader() + * .clientId() + * .clientSecret() * .name() + * .password() + * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( - checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("clientId", clientId), + checkRequired("clientSecret", clientSecret), checkRequired("name", name), + checkRequired("password", password), type, + checkRequired("username", username), + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -3724,16 +4105,20 @@ private constructor( return@apply } - id() baseUrl() - includeCanonicalHeader() + clientId() + clientSecret() name() + password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + username() + id() baseUrlForCanonicalHeader() + includeCanonicalHeader() validated = true } @@ -3753,12 +4138,16 @@ private constructor( */ @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 (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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (username.asKnown().isPresent) 1 else 0) + + (if (id.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) { @@ -3766,23 +4155,31 @@ private constructor( } return other is AkeneoPim && - id == other.id && baseUrl == other.baseUrl && - includeCanonicalHeader == other.includeCanonicalHeader && + clientId == other.clientId && + clientSecret == other.clientSecret && name == other.name && + password == other.password && type == other.type && + username == other.username && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - id, baseUrl, - includeCanonicalHeader, + clientId, + clientSecret, name, + password, type, + username, + id, baseUrlForCanonicalHeader, + includeCanonicalHeader, additionalProperties, ) } @@ -3790,6 +4187,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{id=$id, baseUrl=$baseUrl, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } } 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 e8defa1a..6a10effe 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 @@ -11,7 +11,7 @@ internal class OriginCreateParamsTest { fun create() { OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -29,7 +29,7 @@ internal class OriginCreateParamsTest { val params = OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -45,8 +45,8 @@ internal class OriginCreateParamsTest { assertThat(body) .isEqualTo( - OriginCreateParams.Origin.ofS3( - OriginCreateParams.Origin.S3.builder() + Origin.ofS3( + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -64,7 +64,7 @@ internal class OriginCreateParamsTest { val params = OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -77,8 +77,8 @@ internal class OriginCreateParamsTest { assertThat(body) .isEqualTo( - OriginCreateParams.Origin.ofS3( - OriginCreateParams.Origin.S3.builder() + Origin.ofS3( + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt index be5a3722..e05bced9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt @@ -18,12 +18,14 @@ internal class OriginCreateResponseTest { fun ofS3() { val s3 = OriginCreateResponse.S3.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() val originCreateResponse = OriginCreateResponse.ofS3(s3) @@ -33,8 +35,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -44,12 +46,14 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofS3( OriginCreateResponse.S3.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() ) @@ -66,14 +70,16 @@ internal class OriginCreateResponseTest { fun ofS3Compatible() { val s3Compatible = OriginCreateResponse.S3Compatible.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .includeCanonicalHeader(false) .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .prefix("raw-assets") .s3ForcePathStyle(true) - .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originCreateResponse = OriginCreateResponse.ofS3Compatible(s3Compatible) @@ -83,8 +89,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -94,14 +100,16 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofS3Compatible( OriginCreateResponse.S3Compatible.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .includeCanonicalHeader(false) .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .prefix("raw-assets") .s3ForcePathStyle(true) - .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -118,12 +126,14 @@ internal class OriginCreateResponseTest { fun ofCloudinaryBackup() { val cloudinaryBackup = OriginCreateResponse.CloudinaryBackup.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() val originCreateResponse = OriginCreateResponse.ofCloudinaryBackup(cloudinaryBackup) @@ -133,8 +143,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -144,12 +154,14 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofCloudinaryBackup( OriginCreateResponse.CloudinaryBackup.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() ) @@ -166,12 +178,12 @@ internal class OriginCreateResponseTest { fun ofWebFolder() { val webFolder = OriginCreateResponse.WebFolder.builder() - .id("id") .baseUrl("https://images.example.com/assets") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) .build() val originCreateResponse = OriginCreateResponse.ofWebFolder(webFolder) @@ -181,8 +193,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).contains(webFolder) assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -192,12 +204,12 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofWebFolder( OriginCreateResponse.WebFolder.builder() - .id("id") .baseUrl("https://images.example.com/assets") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) .build() ) @@ -214,10 +226,10 @@ internal class OriginCreateResponseTest { fun ofWebProxy() { val webProxy = OriginCreateResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() val originCreateResponse = OriginCreateResponse.ofWebProxy(webProxy) @@ -227,8 +239,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).contains(webProxy) - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -238,10 +250,10 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofWebProxy( OriginCreateResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() ) @@ -255,43 +267,46 @@ internal class OriginCreateResponseTest { } @Test - fun ofGcs() { - val gcs = - OriginCreateResponse.Gcs.builder() - .id("id") + fun ofGoogleCloudStorageGcs() { + val googleCloudStorageGcs = + OriginCreateResponse.GoogleCloudStorageGcs.builder() .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("products") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") .build() - val originCreateResponse = OriginCreateResponse.ofGcs(gcs) + val originCreateResponse = + OriginCreateResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) assertThat(originCreateResponse.s3()).isEmpty assertThat(originCreateResponse.s3Compatible()).isEmpty assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).contains(gcs) - assertThat(originCreateResponse.azureBlob()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) + assertThat(originCreateResponse.azureBlobStorage()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @Test - fun ofGcsRoundtrip() { + fun ofGoogleCloudStorageGcsRoundtrip() { val jsonMapper = jsonMapper() val originCreateResponse = - OriginCreateResponse.ofGcs( - OriginCreateResponse.Gcs.builder() - .id("id") + OriginCreateResponse.ofGoogleCloudStorageGcs( + OriginCreateResponse.GoogleCloudStorageGcs.builder() .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("products") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") .build() ) @@ -305,43 +320,45 @@ internal class OriginCreateResponseTest { } @Test - fun ofAzureBlob() { - val azureBlob = - OriginCreateResponse.AzureBlob.builder() - .id("id") + fun ofAzureBlobStorage() { + val azureBlobStorage = + OriginCreateResponse.AzureBlobStorage.builder() .accountName("account123") .container("images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("uploads") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") .build() - val originCreateResponse = OriginCreateResponse.ofAzureBlob(azureBlob) + val originCreateResponse = OriginCreateResponse.ofAzureBlobStorage(azureBlobStorage) assertThat(originCreateResponse.s3()).isEmpty assertThat(originCreateResponse.s3Compatible()).isEmpty assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).contains(azureBlob) + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).contains(azureBlobStorage) assertThat(originCreateResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobRoundtrip() { + fun ofAzureBlobStorageRoundtrip() { val jsonMapper = jsonMapper() val originCreateResponse = - OriginCreateResponse.ofAzureBlob( - OriginCreateResponse.AzureBlob.builder() - .id("id") + OriginCreateResponse.ofAzureBlobStorage( + OriginCreateResponse.AzureBlobStorage.builder() .accountName("account123") .container("images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("uploads") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") .build() ) @@ -358,11 +375,15 @@ internal class OriginCreateResponseTest { fun ofAkeneoPim() { val akeneoPim = OriginCreateResponse.AkeneoPim.builder() - .id("id") .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() val originCreateResponse = OriginCreateResponse.ofAkeneoPim(akeneoPim) @@ -372,8 +393,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty + assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originCreateResponse.azureBlobStorage()).isEmpty assertThat(originCreateResponse.akeneoPim()).contains(akeneoPim) } @@ -383,11 +404,15 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofAkeneoPim( OriginCreateResponse.AkeneoPim.builder() - .id("id") .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt index 81a0e62f..54e7e5cd 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt @@ -18,12 +18,14 @@ internal class OriginGetResponseTest { fun ofS3() { val s3 = OriginGetResponse.S3.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() val originGetResponse = OriginGetResponse.ofS3(s3) @@ -33,8 +35,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -44,12 +46,14 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofS3( OriginGetResponse.S3.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() ) @@ -66,14 +70,16 @@ internal class OriginGetResponseTest { fun ofS3Compatible() { val s3Compatible = OriginGetResponse.S3Compatible.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .includeCanonicalHeader(false) .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .prefix("raw-assets") .s3ForcePathStyle(true) - .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originGetResponse = OriginGetResponse.ofS3Compatible(s3Compatible) @@ -83,8 +89,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -94,14 +100,16 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofS3Compatible( OriginGetResponse.S3Compatible.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .includeCanonicalHeader(false) .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .prefix("raw-assets") .s3ForcePathStyle(true) - .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -118,12 +126,14 @@ internal class OriginGetResponseTest { fun ofCloudinaryBackup() { val cloudinaryBackup = OriginGetResponse.CloudinaryBackup.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() val originGetResponse = OriginGetResponse.ofCloudinaryBackup(cloudinaryBackup) @@ -133,8 +143,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -144,12 +154,14 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofCloudinaryBackup( OriginGetResponse.CloudinaryBackup.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() ) @@ -166,12 +178,12 @@ internal class OriginGetResponseTest { fun ofWebFolder() { val webFolder = OriginGetResponse.WebFolder.builder() - .id("id") .baseUrl("https://images.example.com/assets") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) .build() val originGetResponse = OriginGetResponse.ofWebFolder(webFolder) @@ -181,8 +193,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).contains(webFolder) assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -192,12 +204,12 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofWebFolder( OriginGetResponse.WebFolder.builder() - .id("id") .baseUrl("https://images.example.com/assets") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) .build() ) @@ -214,10 +226,10 @@ internal class OriginGetResponseTest { fun ofWebProxy() { val webProxy = OriginGetResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() val originGetResponse = OriginGetResponse.ofWebProxy(webProxy) @@ -227,8 +239,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).contains(webProxy) - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -238,10 +250,10 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofWebProxy( OriginGetResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() ) @@ -255,43 +267,45 @@ internal class OriginGetResponseTest { } @Test - fun ofGcs() { - val gcs = - OriginGetResponse.Gcs.builder() - .id("id") + fun ofGoogleCloudStorageGcs() { + val googleCloudStorageGcs = + OriginGetResponse.GoogleCloudStorageGcs.builder() .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("products") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") .build() - val originGetResponse = OriginGetResponse.ofGcs(gcs) + val originGetResponse = OriginGetResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) assertThat(originGetResponse.s3()).isEmpty assertThat(originGetResponse.s3Compatible()).isEmpty assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).contains(gcs) - assertThat(originGetResponse.azureBlob()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) + assertThat(originGetResponse.azureBlobStorage()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @Test - fun ofGcsRoundtrip() { + fun ofGoogleCloudStorageGcsRoundtrip() { val jsonMapper = jsonMapper() val originGetResponse = - OriginGetResponse.ofGcs( - OriginGetResponse.Gcs.builder() - .id("id") + OriginGetResponse.ofGoogleCloudStorageGcs( + OriginGetResponse.GoogleCloudStorageGcs.builder() .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("products") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") .build() ) @@ -305,43 +319,45 @@ internal class OriginGetResponseTest { } @Test - fun ofAzureBlob() { - val azureBlob = - OriginGetResponse.AzureBlob.builder() - .id("id") + fun ofAzureBlobStorage() { + val azureBlobStorage = + OriginGetResponse.AzureBlobStorage.builder() .accountName("account123") .container("images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("uploads") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") .build() - val originGetResponse = OriginGetResponse.ofAzureBlob(azureBlob) + val originGetResponse = OriginGetResponse.ofAzureBlobStorage(azureBlobStorage) assertThat(originGetResponse.s3()).isEmpty assertThat(originGetResponse.s3Compatible()).isEmpty assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).contains(azureBlob) + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).contains(azureBlobStorage) assertThat(originGetResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobRoundtrip() { + fun ofAzureBlobStorageRoundtrip() { val jsonMapper = jsonMapper() val originGetResponse = - OriginGetResponse.ofAzureBlob( - OriginGetResponse.AzureBlob.builder() - .id("id") + OriginGetResponse.ofAzureBlobStorage( + OriginGetResponse.AzureBlobStorage.builder() .accountName("account123") .container("images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("uploads") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") .build() ) @@ -358,11 +374,15 @@ internal class OriginGetResponseTest { fun ofAkeneoPim() { val akeneoPim = OriginGetResponse.AkeneoPim.builder() - .id("id") .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() val originGetResponse = OriginGetResponse.ofAkeneoPim(akeneoPim) @@ -372,8 +392,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty + assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty + assertThat(originGetResponse.azureBlobStorage()).isEmpty assertThat(originGetResponse.akeneoPim()).contains(akeneoPim) } @@ -383,11 +403,15 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofAkeneoPim( OriginGetResponse.AkeneoPim.builder() - .id("id") .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt index 5a5b4506..89a663bf 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt @@ -18,12 +18,14 @@ internal class OriginListResponseTest { fun ofS3() { val s3 = OriginListResponse.S3.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() val originListResponse = OriginListResponse.ofS3(s3) @@ -33,8 +35,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -44,12 +46,14 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofS3( OriginListResponse.S3.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() ) @@ -66,14 +70,16 @@ internal class OriginListResponseTest { fun ofS3Compatible() { val s3Compatible = OriginListResponse.S3Compatible.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .includeCanonicalHeader(false) .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .prefix("raw-assets") .s3ForcePathStyle(true) - .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originListResponse = OriginListResponse.ofS3Compatible(s3Compatible) @@ -83,8 +89,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -94,14 +100,16 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofS3Compatible( OriginListResponse.S3Compatible.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .includeCanonicalHeader(false) .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .prefix("raw-assets") .s3ForcePathStyle(true) - .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -118,12 +126,14 @@ internal class OriginListResponseTest { fun ofCloudinaryBackup() { val cloudinaryBackup = OriginListResponse.CloudinaryBackup.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() val originListResponse = OriginListResponse.ofCloudinaryBackup(cloudinaryBackup) @@ -133,8 +143,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -144,12 +154,14 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofCloudinaryBackup( OriginListResponse.CloudinaryBackup.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() ) @@ -166,12 +178,12 @@ internal class OriginListResponseTest { fun ofWebFolder() { val webFolder = OriginListResponse.WebFolder.builder() - .id("id") .baseUrl("https://images.example.com/assets") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) .build() val originListResponse = OriginListResponse.ofWebFolder(webFolder) @@ -181,8 +193,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).contains(webFolder) assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -192,12 +204,12 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofWebFolder( OriginListResponse.WebFolder.builder() - .id("id") .baseUrl("https://images.example.com/assets") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) .build() ) @@ -214,10 +226,10 @@ internal class OriginListResponseTest { fun ofWebProxy() { val webProxy = OriginListResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() val originListResponse = OriginListResponse.ofWebProxy(webProxy) @@ -227,8 +239,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).contains(webProxy) - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -238,10 +250,10 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofWebProxy( OriginListResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() ) @@ -255,43 +267,45 @@ internal class OriginListResponseTest { } @Test - fun ofGcs() { - val gcs = - OriginListResponse.Gcs.builder() - .id("id") + fun ofGoogleCloudStorageGcs() { + val googleCloudStorageGcs = + OriginListResponse.GoogleCloudStorageGcs.builder() .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("products") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") .build() - val originListResponse = OriginListResponse.ofGcs(gcs) + val originListResponse = OriginListResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) assertThat(originListResponse.s3()).isEmpty assertThat(originListResponse.s3Compatible()).isEmpty assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).contains(gcs) - assertThat(originListResponse.azureBlob()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) + assertThat(originListResponse.azureBlobStorage()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @Test - fun ofGcsRoundtrip() { + fun ofGoogleCloudStorageGcsRoundtrip() { val jsonMapper = jsonMapper() val originListResponse = - OriginListResponse.ofGcs( - OriginListResponse.Gcs.builder() - .id("id") + OriginListResponse.ofGoogleCloudStorageGcs( + OriginListResponse.GoogleCloudStorageGcs.builder() .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("products") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") .build() ) @@ -305,43 +319,45 @@ internal class OriginListResponseTest { } @Test - fun ofAzureBlob() { - val azureBlob = - OriginListResponse.AzureBlob.builder() - .id("id") + fun ofAzureBlobStorage() { + val azureBlobStorage = + OriginListResponse.AzureBlobStorage.builder() .accountName("account123") .container("images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("uploads") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") .build() - val originListResponse = OriginListResponse.ofAzureBlob(azureBlob) + val originListResponse = OriginListResponse.ofAzureBlobStorage(azureBlobStorage) assertThat(originListResponse.s3()).isEmpty assertThat(originListResponse.s3Compatible()).isEmpty assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).contains(azureBlob) + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).contains(azureBlobStorage) assertThat(originListResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobRoundtrip() { + fun ofAzureBlobStorageRoundtrip() { val jsonMapper = jsonMapper() val originListResponse = - OriginListResponse.ofAzureBlob( - OriginListResponse.AzureBlob.builder() - .id("id") + OriginListResponse.ofAzureBlobStorage( + OriginListResponse.AzureBlobStorage.builder() .accountName("account123") .container("images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("uploads") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") .build() ) @@ -358,11 +374,15 @@ internal class OriginListResponseTest { fun ofAkeneoPim() { val akeneoPim = OriginListResponse.AkeneoPim.builder() - .id("id") .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() val originListResponse = OriginListResponse.ofAkeneoPim(akeneoPim) @@ -372,8 +392,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty + assertThat(originListResponse.googleCloudStorageGcs()).isEmpty + assertThat(originListResponse.azureBlobStorage()).isEmpty assertThat(originListResponse.akeneoPim()).contains(akeneoPim) } @@ -383,11 +403,15 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofAkeneoPim( OriginListResponse.AkeneoPim.builder() - .id("id") .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt new file mode 100644 index 00000000..3e702b59 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt @@ -0,0 +1,403 @@ +// 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 OriginTest { + + @Test + fun ofS3() { + val s3 = + Origin.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 origin = Origin.ofS3(s3) + + assertThat(origin.s3()).contains(s3) + assertThat(origin.s3Compatible()).isEmpty + assertThat(origin.cloudinaryBackup()).isEmpty + assertThat(origin.webFolder()).isEmpty + assertThat(origin.webProxy()).isEmpty + assertThat(origin.gcs()).isEmpty + assertThat(origin.azureBlob()).isEmpty + assertThat(origin.akeneoPim()).isEmpty + } + + @Test + fun ofS3Roundtrip() { + val jsonMapper = jsonMapper() + val origin = + Origin.ofS3( + Origin.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 roundtrippedOrigin = + jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) + + assertThat(roundtrippedOrigin).isEqualTo(origin) + } + + @Test + fun ofS3Compatible() { + val s3Compatible = + Origin.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 origin = Origin.ofS3Compatible(s3Compatible) + + assertThat(origin.s3()).isEmpty + assertThat(origin.s3Compatible()).contains(s3Compatible) + assertThat(origin.cloudinaryBackup()).isEmpty + assertThat(origin.webFolder()).isEmpty + assertThat(origin.webProxy()).isEmpty + assertThat(origin.gcs()).isEmpty + assertThat(origin.azureBlob()).isEmpty + assertThat(origin.akeneoPim()).isEmpty + } + + @Test + fun ofS3CompatibleRoundtrip() { + val jsonMapper = jsonMapper() + val origin = + Origin.ofS3Compatible( + Origin.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 roundtrippedOrigin = + jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) + + assertThat(roundtrippedOrigin).isEqualTo(origin) + } + + @Test + fun ofCloudinaryBackup() { + val cloudinaryBackup = + Origin.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 origin = Origin.ofCloudinaryBackup(cloudinaryBackup) + + assertThat(origin.s3()).isEmpty + assertThat(origin.s3Compatible()).isEmpty + assertThat(origin.cloudinaryBackup()).contains(cloudinaryBackup) + assertThat(origin.webFolder()).isEmpty + assertThat(origin.webProxy()).isEmpty + assertThat(origin.gcs()).isEmpty + assertThat(origin.azureBlob()).isEmpty + assertThat(origin.akeneoPim()).isEmpty + } + + @Test + fun ofCloudinaryBackupRoundtrip() { + val jsonMapper = jsonMapper() + val origin = + Origin.ofCloudinaryBackup( + Origin.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 roundtrippedOrigin = + jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) + + assertThat(roundtrippedOrigin).isEqualTo(origin) + } + + @Test + fun ofWebFolder() { + val webFolder = + Origin.WebFolder.builder() + .baseUrl("https://images.example.com/assets") + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .build() + + val origin = Origin.ofWebFolder(webFolder) + + assertThat(origin.s3()).isEmpty + assertThat(origin.s3Compatible()).isEmpty + assertThat(origin.cloudinaryBackup()).isEmpty + assertThat(origin.webFolder()).contains(webFolder) + assertThat(origin.webProxy()).isEmpty + assertThat(origin.gcs()).isEmpty + assertThat(origin.azureBlob()).isEmpty + assertThat(origin.akeneoPim()).isEmpty + } + + @Test + fun ofWebFolderRoundtrip() { + val jsonMapper = jsonMapper() + val origin = + Origin.ofWebFolder( + Origin.WebFolder.builder() + .baseUrl("https://images.example.com/assets") + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .build() + ) + + val roundtrippedOrigin = + jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) + + assertThat(roundtrippedOrigin).isEqualTo(origin) + } + + @Test + fun ofWebProxy() { + val webProxy = + Origin.WebProxy.builder() + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .build() + + val origin = Origin.ofWebProxy(webProxy) + + assertThat(origin.s3()).isEmpty + assertThat(origin.s3Compatible()).isEmpty + assertThat(origin.cloudinaryBackup()).isEmpty + assertThat(origin.webFolder()).isEmpty + assertThat(origin.webProxy()).contains(webProxy) + assertThat(origin.gcs()).isEmpty + assertThat(origin.azureBlob()).isEmpty + assertThat(origin.akeneoPim()).isEmpty + } + + @Test + fun ofWebProxyRoundtrip() { + val jsonMapper = jsonMapper() + val origin = + Origin.ofWebProxy( + Origin.WebProxy.builder() + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .build() + ) + + val roundtrippedOrigin = + jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) + + assertThat(roundtrippedOrigin).isEqualTo(origin) + } + + @Test + fun ofGcs() { + val gcs = + Origin.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 origin = Origin.ofGcs(gcs) + + assertThat(origin.s3()).isEmpty + assertThat(origin.s3Compatible()).isEmpty + assertThat(origin.cloudinaryBackup()).isEmpty + assertThat(origin.webFolder()).isEmpty + assertThat(origin.webProxy()).isEmpty + assertThat(origin.gcs()).contains(gcs) + assertThat(origin.azureBlob()).isEmpty + assertThat(origin.akeneoPim()).isEmpty + } + + @Test + fun ofGcsRoundtrip() { + val jsonMapper = jsonMapper() + val origin = + Origin.ofGcs( + Origin.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 roundtrippedOrigin = + jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) + + assertThat(roundtrippedOrigin).isEqualTo(origin) + } + + @Test + fun ofAzureBlob() { + val azureBlob = + Origin.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 origin = Origin.ofAzureBlob(azureBlob) + + assertThat(origin.s3()).isEmpty + assertThat(origin.s3Compatible()).isEmpty + assertThat(origin.cloudinaryBackup()).isEmpty + assertThat(origin.webFolder()).isEmpty + assertThat(origin.webProxy()).isEmpty + assertThat(origin.gcs()).isEmpty + assertThat(origin.azureBlob()).contains(azureBlob) + assertThat(origin.akeneoPim()).isEmpty + } + + @Test + fun ofAzureBlobRoundtrip() { + val jsonMapper = jsonMapper() + val origin = + Origin.ofAzureBlob( + Origin.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 roundtrippedOrigin = + jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) + + assertThat(roundtrippedOrigin).isEqualTo(origin) + } + + @Test + fun ofAkeneoPim() { + val akeneoPim = + Origin.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 origin = Origin.ofAkeneoPim(akeneoPim) + + assertThat(origin.s3()).isEmpty + assertThat(origin.s3Compatible()).isEmpty + assertThat(origin.cloudinaryBackup()).isEmpty + assertThat(origin.webFolder()).isEmpty + assertThat(origin.webProxy()).isEmpty + assertThat(origin.gcs()).isEmpty + assertThat(origin.azureBlob()).isEmpty + assertThat(origin.akeneoPim()).contains(akeneoPim) + } + + @Test + fun ofAkeneoPimRoundtrip() { + val jsonMapper = jsonMapper() + val origin = + Origin.ofAkeneoPim( + Origin.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 roundtrippedOrigin = + jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) + + assertThat(roundtrippedOrigin).isEqualTo(origin) + } + + 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 origin = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { origin.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 index e9be0a35..f7bc6d19 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 @@ -12,7 +12,7 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -31,7 +31,7 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -51,7 +51,7 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -67,8 +67,8 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - OriginUpdateParams.Origin.ofS3( - OriginUpdateParams.Origin.S3.builder() + Origin.ofS3( + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -87,7 +87,7 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -100,8 +100,8 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - OriginUpdateParams.Origin.ofS3( - OriginUpdateParams.Origin.S3.builder() + Origin.ofS3( + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt index c569a06f..e2ad014f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt @@ -18,12 +18,14 @@ internal class OriginUpdateResponseTest { fun ofS3() { val s3 = OriginUpdateResponse.S3.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() val originUpdateResponse = OriginUpdateResponse.ofS3(s3) @@ -33,8 +35,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -44,12 +46,14 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofS3( OriginUpdateResponse.S3.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() ) @@ -66,14 +70,16 @@ internal class OriginUpdateResponseTest { fun ofS3Compatible() { val s3Compatible = OriginUpdateResponse.S3Compatible.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .includeCanonicalHeader(false) .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .prefix("raw-assets") .s3ForcePathStyle(true) - .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originUpdateResponse = OriginUpdateResponse.ofS3Compatible(s3Compatible) @@ -83,8 +89,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -94,14 +100,16 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofS3Compatible( OriginUpdateResponse.S3Compatible.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .includeCanonicalHeader(false) .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .prefix("raw-assets") .s3ForcePathStyle(true) - .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -118,12 +126,14 @@ internal class OriginUpdateResponseTest { fun ofCloudinaryBackup() { val cloudinaryBackup = OriginUpdateResponse.CloudinaryBackup.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() val originUpdateResponse = OriginUpdateResponse.ofCloudinaryBackup(cloudinaryBackup) @@ -133,8 +143,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -144,12 +154,14 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofCloudinaryBackup( OriginUpdateResponse.CloudinaryBackup.builder() - .id("id") + .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("raw-assets") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") .build() ) @@ -166,12 +178,12 @@ internal class OriginUpdateResponseTest { fun ofWebFolder() { val webFolder = OriginUpdateResponse.WebFolder.builder() - .id("id") .baseUrl("https://images.example.com/assets") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) .build() val originUpdateResponse = OriginUpdateResponse.ofWebFolder(webFolder) @@ -181,8 +193,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).contains(webFolder) assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -192,12 +204,12 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofWebFolder( OriginUpdateResponse.WebFolder.builder() - .id("id") .baseUrl("https://images.example.com/assets") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) .build() ) @@ -214,10 +226,10 @@ internal class OriginUpdateResponseTest { fun ofWebProxy() { val webProxy = OriginUpdateResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() val originUpdateResponse = OriginUpdateResponse.ofWebProxy(webProxy) @@ -227,8 +239,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).contains(webProxy) - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -238,10 +250,10 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofWebProxy( OriginUpdateResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() ) @@ -255,43 +267,46 @@ internal class OriginUpdateResponseTest { } @Test - fun ofGcs() { - val gcs = - OriginUpdateResponse.Gcs.builder() - .id("id") + fun ofGoogleCloudStorageGcs() { + val googleCloudStorageGcs = + OriginUpdateResponse.GoogleCloudStorageGcs.builder() .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("products") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") .build() - val originUpdateResponse = OriginUpdateResponse.ofGcs(gcs) + val originUpdateResponse = + OriginUpdateResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) assertThat(originUpdateResponse.s3()).isEmpty assertThat(originUpdateResponse.s3Compatible()).isEmpty assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).contains(gcs) - assertThat(originUpdateResponse.azureBlob()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @Test - fun ofGcsRoundtrip() { + fun ofGoogleCloudStorageGcsRoundtrip() { val jsonMapper = jsonMapper() val originUpdateResponse = - OriginUpdateResponse.ofGcs( - OriginUpdateResponse.Gcs.builder() - .id("id") + OriginUpdateResponse.ofGoogleCloudStorageGcs( + OriginUpdateResponse.GoogleCloudStorageGcs.builder() .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("products") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") .build() ) @@ -305,43 +320,45 @@ internal class OriginUpdateResponseTest { } @Test - fun ofAzureBlob() { - val azureBlob = - OriginUpdateResponse.AzureBlob.builder() - .id("id") + fun ofAzureBlobStorage() { + val azureBlobStorage = + OriginUpdateResponse.AzureBlobStorage.builder() .accountName("account123") .container("images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("uploads") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") .build() - val originUpdateResponse = OriginUpdateResponse.ofAzureBlob(azureBlob) + val originUpdateResponse = OriginUpdateResponse.ofAzureBlobStorage(azureBlobStorage) assertThat(originUpdateResponse.s3()).isEmpty assertThat(originUpdateResponse.s3Compatible()).isEmpty assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).contains(azureBlob) + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).contains(azureBlobStorage) assertThat(originUpdateResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobRoundtrip() { + fun ofAzureBlobStorageRoundtrip() { val jsonMapper = jsonMapper() val originUpdateResponse = - OriginUpdateResponse.ofAzureBlob( - OriginUpdateResponse.AzureBlob.builder() - .id("id") + OriginUpdateResponse.ofAzureBlobStorage( + OriginUpdateResponse.AzureBlobStorage.builder() .accountName("account123") .container("images") - .includeCanonicalHeader(false) .name("US S3 Storage") - .prefix("uploads") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") .build() ) @@ -358,11 +375,15 @@ internal class OriginUpdateResponseTest { fun ofAkeneoPim() { val akeneoPim = OriginUpdateResponse.AkeneoPim.builder() - .id("id") .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .build() val originUpdateResponse = OriginUpdateResponse.ofAkeneoPim(akeneoPim) @@ -372,8 +393,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty + assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty + assertThat(originUpdateResponse.azureBlobStorage()).isEmpty assertThat(originUpdateResponse.akeneoPim()).contains(akeneoPim) } @@ -383,11 +404,15 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofAkeneoPim( OriginUpdateResponse.AkeneoPim.builder() - .id("id") .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) .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 89426faf..0f7f1261 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,6 +4,7 @@ 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.Origin import com.imagekit.api.models.accounts.origins.OriginCreateParams import com.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled @@ -28,7 +29,7 @@ internal class OriginServiceAsyncTest { originServiceAsync.create( OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -61,7 +62,7 @@ internal class OriginServiceAsyncTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") 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 13880caa..8fe9c310 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,6 +4,7 @@ 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.Origin import com.imagekit.api.models.accounts.origins.OriginCreateParams import com.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled @@ -28,7 +29,7 @@ internal class OriginServiceTest { originService.create( OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -60,7 +61,7 @@ internal class OriginServiceTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + Origin.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") From a4a09e4192e19b80be888ca01456105f161dfa3f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 03:32:35 +0000 Subject: [PATCH 047/125] feat(api): manual updates --- .stats.yml | 6 +- .../accounts/origins/OriginCreateResponse.kt | 2307 +++++++---------- .../accounts/origins/OriginGetResponse.kt | 2306 +++++++--------- .../accounts/origins/OriginListResponse.kt | 2306 +++++++--------- .../accounts/origins/OriginUpdateResponse.kt | 2307 +++++++---------- .../origins/OriginCreateResponseTest.kt | 173 +- .../accounts/origins/OriginGetResponseTest.kt | 172 +- .../origins/OriginListResponseTest.kt | 172 +- .../origins/OriginUpdateResponseTest.kt | 173 +- 9 files changed, 4117 insertions(+), 5805 deletions(-) diff --git a/.stats.yml b/.stats.yml index 53bd25d3..5afb8fd9 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-d65a790786704dc315c1fded8ee24d61a55d96054fbbf1e6da429ec96b3e0c88.yml -openapi_spec_hash: 0fa9ee90455e183ec3b5d4e36f1351a9 -config_hash: 89ffae9ef2878c981a64f42cadb85186 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml +openapi_spec_hash: 98642308bee81ac776b7b1843089b888 +config_hash: ddd6954a6e35eb1a97e5d0cda8209e62 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt index af82b8e9..4eb17b1b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt @@ -19,14 +19,15 @@ 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.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 = OriginCreateResponse.Deserializer::class) @JsonSerialize(using = OriginCreateResponse.Serializer::class) class OriginCreateResponse @@ -36,8 +37,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -52,10 +53,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -69,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -85,10 +85,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -101,9 +100,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -137,14 +135,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -183,12 +179,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -207,8 +200,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -219,8 +212,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -231,9 +224,8 @@ private constructor( cloudinaryBackup != null -> "OriginCreateResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginCreateResponse{webFolder=$webFolder}" webProxy != null -> "OriginCreateResponse{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "OriginCreateResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "OriginCreateResponse{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "OriginCreateResponse{gcs=$gcs}" + azureBlob != null -> "OriginCreateResponse{azureBlob=$azureBlob}" akeneoPim != null -> "OriginCreateResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginCreateResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginCreateResponse") @@ -256,13 +248,10 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginCreateResponse(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - OriginCreateResponse(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginCreateResponse(gcs = gcs) @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - OriginCreateResponse(azureBlobStorage = azureBlobStorage) + fun ofAzureBlob(azureBlob: AzureBlob) = OriginCreateResponse(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginCreateResponse(akeneoPim = akeneoPim) @@ -284,9 +273,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -310,46 +299,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginCreateResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(akeneoPim = 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 -> OriginCreateResponse(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(s3 = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(s3Compatible = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(cloudinaryBackup = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(webFolder = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(webProxy = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(gcs = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(azureBlob = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginCreateResponse(akeneoPim = it, _json = json) + } ?: OriginCreateResponse(_json = json) + } } + + return OriginCreateResponse(_json = json) } } @@ -366,9 +361,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 OriginCreateResponse") @@ -378,57 +372,48 @@ private constructor( class S3 private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -438,6 +423,15 @@ private constructor( */ 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. * @@ -447,12 +441,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -465,12 +459,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -481,28 +469,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -512,25 +483,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -542,23 +516,6 @@ private constructor( @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) @@ -578,10 +535,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -590,42 +548,41 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("S3") - private var id: JsonField = JsonMissing.of() 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 + id = s3.id bucket = s3.bucket + includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - secretKey = s3.secretKey + prefix = s3.prefix type = s3.type - id = s3.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -639,6 +596,21 @@ private constructor( */ 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)) @@ -651,17 +623,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -677,17 +649,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -703,33 +664,6 @@ private constructor( 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) @@ -756,25 +690,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -786,19 +719,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -818,15 +749,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -834,29 +763,25 @@ private constructor( } return other is S3 && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -864,72 +789,63 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "S3{id=$id, bucket=$bucket, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, private val endpoint: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonValue, - private val id: JsonField, - private val baseUrlForCanonicalHeader: 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("accessKey") - @ExcludeMissing - accessKey: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -947,6 +863,15 @@ private constructor( */ 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. * @@ -956,12 +881,20 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** * Expected to always return the following: @@ -974,12 +907,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -990,43 +917,18 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Path prefix inside the bucket. + * Returns the raw JSON value of [bucket]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. */ - 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 + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** * Returns the raw JSON value of [endpoint]. @@ -1035,37 +937,6 @@ private constructor( */ @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 [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 [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]. * @@ -1076,6 +947,13 @@ private constructor( @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]. * @@ -1093,6 +971,16 @@ private constructor( @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) @@ -1112,11 +1000,13 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` */ @JvmStatic fun builder() = Builder() @@ -1125,46 +1015,45 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + 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 secretKey: JsonField? = null + private var prefix: JsonField? = null + private var s3ForcePathStyle: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") - private var id: JsonField = JsonMissing.of() 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 + id = s3Compatible.id bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - name = s3Compatible.name - secretKey = s3Compatible.secretKey - type = s3Compatible.type - id = s3Compatible.id - baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader includeCanonicalHeader = s3Compatible.includeCanonicalHeader + name = s3Compatible.name prefix = s3Compatible.prefix s3ForcePathStyle = s3Compatible.s3ForcePathStyle + type = s3Compatible.type + baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader additionalProperties = s3Compatible.additionalProperties.toMutableMap() } - /** Access key for the bucket. */ - fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1190,6 +1079,21 @@ private constructor( */ 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)) @@ -1202,17 +1106,32 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + 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. @@ -1228,17 +1147,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1254,48 +1162,6 @@ private constructor( 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) @@ -1322,28 +1188,28 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), + checkRequired("s3ForcePathStyle", s3ForcePathStyle), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1355,21 +1221,19 @@ private constructor( return@apply } - accessKey() + id() bucket() endpoint() + includeCanonicalHeader() name() - secretKey() + prefix() + s3ForcePathStyle() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - s3ForcePathStyle() validated = true } @@ -1389,17 +1253,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (if (id.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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.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) + (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) { @@ -1407,33 +1269,29 @@ private constructor( } return other is S3Compatible && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && endpoint == other.endpoint && - name == other.name && - secretKey == other.secretKey && - type == other.type && - id == other.id && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, additionalProperties, ) } @@ -1441,62 +1299,53 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" + "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 accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -1506,6 +1355,15 @@ private constructor( */ 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. * @@ -1515,12 +1373,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -1533,12 +1391,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -1549,28 +1401,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -1580,25 +1415,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -1610,23 +1448,6 @@ private constructor( @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) @@ -1646,10 +1467,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -1658,42 +1480,41 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") - private var id: JsonField = JsonMissing.of() 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 + id = cloudinaryBackup.id bucket = cloudinaryBackup.bucket + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - secretKey = cloudinaryBackup.secretKey + prefix = cloudinaryBackup.prefix type = cloudinaryBackup.type - id = cloudinaryBackup.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1707,6 +1528,21 @@ private constructor( */ 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)) @@ -1719,17 +1555,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -1745,17 +1581,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1771,33 +1596,6 @@ private constructor( 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) @@ -1824,25 +1622,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -1854,19 +1651,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -1886,15 +1681,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1902,29 +1695,25 @@ private constructor( } return other is CloudinaryBackup && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -1932,47 +1721,56 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, 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. * @@ -1981,6 +1779,24 @@ private constructor( */ 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. * @@ -2000,12 +1816,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2015,38 +1825,6 @@ private constructor( 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 [id]. * @@ -2055,14 +1833,11 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [baseUrl]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** * Returns the raw JSON value of [forwardHostHeaderToOrigin]. @@ -2084,6 +1859,23 @@ private constructor( @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) @@ -2103,7 +1895,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2113,27 +1908,42 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { + id = webFolder.id baseUrl = webFolder.baseUrl + forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolder.includeCanonicalHeader name = webFolder.name type = webFolder.type - id = webFolder.id baseUrlForCanonicalHeader = webFolder.baseUrlForCanonicalHeader - forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin - includeCanonicalHeader = webFolder.includeCanonicalHeader 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)) @@ -2146,6 +1956,36 @@ private constructor( */ 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)) @@ -2172,17 +2012,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2198,36 +2027,6 @@ private constructor( 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) @@ -2254,7 +2053,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` * @@ -2262,13 +2064,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), + checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2280,17 +2082,17 @@ private constructor( return@apply } + id() baseUrl() + forwardHostHeaderToOrigin() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - forwardHostHeaderToOrigin() - includeCanonicalHeader() validated = true } @@ -2310,13 +2112,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (baseUrl.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2324,25 +2126,25 @@ private constructor( } return other is WebFolder && + id == other.id && baseUrl == other.baseUrl && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties, ) } @@ -2350,31 +2152,49 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) + ) : 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. @@ -2395,12 +2215,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2411,27 +2225,28 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [name]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2443,16 +2258,6 @@ private constructor( @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) @@ -2472,6 +2277,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2481,23 +2288,53 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: 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 - id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader - includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2524,17 +2361,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2550,21 +2376,6 @@ private constructor( 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) @@ -2591,6 +2402,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` * @@ -2598,11 +2411,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2614,15 +2427,15 @@ private constructor( return@apply } + id() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -2642,11 +2455,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2654,21 +2467,21 @@ private constructor( } return other is WebProxy && + id == other.id && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -2676,55 +2489,59 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + 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 privateKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("privateKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -2737,6 +2554,15 @@ private constructor( */ 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. * @@ -2749,7 +2575,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 privateKey(): String = privateKey.getRequired("privateKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -2762,12 +2588,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2778,19 +2598,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -2809,27 +2621,28 @@ private constructor( fun _clientEmail(): JsonField = clientEmail /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [privateKey]. + * Returns the raw JSON value of [name]. * - * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("privateKey") - @ExcludeMissing - fun _privateKey(): JsonField = privateKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2841,23 +2654,6 @@ private constructor( @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) @@ -2873,47 +2669,62 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java + * .id() * .bucket() * .clientEmail() + * .includeCanonicalHeader() * .name() - * .privateKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** 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 privateKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") - private var id: JsonField = JsonMissing.of() 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - id = googleCloudStorageGcs.id - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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)) /** @@ -2938,6 +2749,21 @@ private constructor( 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)) @@ -2950,16 +2776,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.privateKey] to an arbitrary JSON value. + * Sets [Builder.prefix] 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 + * 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 privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -2975,17 +2801,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3001,32 +2816,6 @@ private constructor( 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) @@ -3047,55 +2836,55 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * 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() - * .privateKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("privateKey", privateKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } + id() bucket() clientEmail() + includeCanonicalHeader() name() - privateKey() + prefix() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3115,45 +2904,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (bucket.asKnown().isPresent) 1 else 0) + + (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 (privateKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("GCS")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && + id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - privateKey == other.privateKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3161,57 +2947,61 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + 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 sasToken: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("sasToken") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - sasToken: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -3224,6 +3014,15 @@ private constructor( */ 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. * @@ -3236,7 +3035,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 sasToken(): String = sasToken.getRequired("sasToken") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -3249,12 +3048,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -3265,19 +3058,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [accountName]. @@ -3296,25 +3081,28 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [sasToken]. + * Returns the raw JSON value of [name]. * - * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3326,23 +3114,6 @@ private constructor( @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) @@ -3358,46 +3129,61 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java + * .id() * .accountName() * .container() + * .includeCanonicalHeader() * .name() - * .sasToken() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** 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 sasToken: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") - private var id: JsonField = JsonMissing.of() 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(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - id = azureBlobStorage.id - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() - } + @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)) @@ -3423,6 +3209,21 @@ private constructor( */ 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)) @@ -3435,16 +3236,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.sasToken] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.sasToken] with a well-typed [String] value instead. + * 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 sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -3460,17 +3261,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3486,32 +3276,6 @@ private constructor( 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) @@ -3532,55 +3296,55 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * 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() - * .sasToken() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( + checkRequired("id", id), checkRequired("accountName", accountName), checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("sasToken", sasToken), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } + id() accountName() container() + includeCanonicalHeader() name() - sasToken() + prefix() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3600,45 +3364,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accountName.asKnown().isPresent) 1 else 0) + + (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 (sasToken.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("AZURE_BLOB")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AzureBlobStorage && + return other is AzureBlob && + id == other.id && accountName == other.accountName && container == other.container && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - sasToken == other.sasToken && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3646,85 +3407,67 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 clientId: JsonField, - private val clientSecret: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val password: JsonField, private val type: JsonValue, - private val username: JsonField, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("clientId") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - clientSecret: JsonField = JsonMissing.of(), + includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, mutableMapOf(), ) /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun id(): String = id.getRequired("id") /** - * Akeneo API client 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 clientId(): String = clientId.getRequired("clientId") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo API client secret. + * 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 clientSecret(): String = clientSecret.getRequired("clientSecret") + fun includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") /** * Display name of the origin. @@ -3734,14 +3477,6 @@ private constructor( */ 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 @@ -3753,20 +3488,6 @@ private constructor( */ @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") - - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -3777,13 +3498,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrl]. @@ -3793,21 +3512,14 @@ private constructor( @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]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _clientSecret(): JsonField = clientSecret + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [name]. @@ -3816,27 +3528,6 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3847,16 +3538,6 @@ private constructor( @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) @@ -3876,12 +3557,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3890,69 +3569,65 @@ private constructor( /** A builder for [AkeneoPim]. */ class Builder internal constructor() { + private var id: JsonField? = null private var baseUrl: JsonField? = null - private var clientId: JsonField? = null - private var clientSecret: JsonField? = null + private var includeCanonicalHeader: 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { + id = akeneoPim.id baseUrl = akeneoPim.baseUrl - clientId = akeneoPim.clientId - clientSecret = akeneoPim.clientSecret + includeCanonicalHeader = akeneoPim.includeCanonicalHeader name = akeneoPim.name - password = akeneoPim.password type = akeneoPim.type - username = akeneoPim.username - id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader - includeCanonicalHeader = akeneoPim.includeCanonicalHeader additionalProperties = akeneoPim.additionalProperties.toMutableMap() } - /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + /** + * 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.baseUrl] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + fun id(id: JsonField) = apply { this.id = id } - /** Akeneo API client ID. */ - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + /** Akeneo instance base URL. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) /** - * Sets [Builder.clientId] to an arbitrary JSON value. + * Sets [Builder.baseUrl] to an arbitrary JSON value. * - * You should usually call [Builder.clientId] with a well-typed [String] value instead. + * 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 clientId(clientId: JsonField) = apply { this.clientId = clientId } + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Akeneo API client secret. */ - fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) /** - * Sets [Builder.clientSecret] to an arbitrary JSON value. + * Sets [Builder.includeCanonicalHeader] 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. + * 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 clientSecret(clientSecret: JsonField) = apply { - this.clientSecret = clientSecret + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader } /** Display name of the origin. */ @@ -3967,18 +3642,6 @@ private constructor( */ 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. * @@ -3993,29 +3656,6 @@ private constructor( */ 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 } - - 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -4031,21 +3671,6 @@ private constructor( 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) @@ -4072,28 +3697,22 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("clientId", clientId), - checkRequired("clientSecret", clientSecret), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("password", password), type, - checkRequired("username", username), - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -4105,20 +3724,16 @@ private constructor( return@apply } + id() baseUrl() - clientId() - clientSecret() + includeCanonicalHeader() name() - password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - username() - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -4138,16 +3753,12 @@ private constructor( */ @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 (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) + - (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -4155,31 +3766,23 @@ private constructor( } return other is AkeneoPim && + id == other.id && baseUrl == other.baseUrl && - clientId == other.clientId && - clientSecret == other.clientSecret && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - password == other.password && type == other.type && - username == other.username && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -4187,6 +3790,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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/OriginGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt index 6fd68932..81dffd47 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt @@ -19,14 +19,15 @@ 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.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 = OriginGetResponse.Deserializer::class) @JsonSerialize(using = OriginGetResponse.Serializer::class) class OriginGetResponse @@ -36,8 +37,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -52,10 +53,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -69,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -85,10 +85,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -101,9 +100,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -137,14 +135,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -183,12 +179,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -207,8 +200,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -219,8 +212,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -231,9 +224,8 @@ private constructor( cloudinaryBackup != null -> "OriginGetResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginGetResponse{webFolder=$webFolder}" webProxy != null -> "OriginGetResponse{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "OriginGetResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "OriginGetResponse{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "OriginGetResponse{gcs=$gcs}" + azureBlob != null -> "OriginGetResponse{azureBlob=$azureBlob}" akeneoPim != null -> "OriginGetResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginGetResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginGetResponse") @@ -255,13 +247,9 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginGetResponse(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - OriginGetResponse(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginGetResponse(gcs = gcs) - @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - OriginGetResponse(azureBlobStorage = azureBlobStorage) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginGetResponse(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginGetResponse(akeneoPim = akeneoPim) } @@ -282,9 +270,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -307,46 +295,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginGetResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(akeneoPim = 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 -> OriginGetResponse(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(s3 = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(s3Compatible = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(cloudinaryBackup = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(webFolder = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(webProxy = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(gcs = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(azureBlob = it, _json = json) + } ?: OriginGetResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginGetResponse(akeneoPim = it, _json = json) + } ?: OriginGetResponse(_json = json) + } } + + return OriginGetResponse(_json = json) } } @@ -363,9 +357,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 OriginGetResponse") @@ -375,57 +368,48 @@ private constructor( class S3 private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -435,6 +419,15 @@ private constructor( */ 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. * @@ -444,12 +437,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -462,12 +455,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -478,28 +465,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -509,25 +479,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -539,23 +512,6 @@ private constructor( @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) @@ -575,10 +531,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -587,42 +544,41 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("S3") - private var id: JsonField = JsonMissing.of() 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 + id = s3.id bucket = s3.bucket + includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - secretKey = s3.secretKey + prefix = s3.prefix type = s3.type - id = s3.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -636,6 +592,21 @@ private constructor( */ 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)) @@ -648,17 +619,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -674,17 +645,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -700,33 +660,6 @@ private constructor( 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) @@ -753,25 +686,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -783,19 +715,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -815,15 +745,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -831,29 +759,25 @@ private constructor( } return other is S3 && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -861,72 +785,63 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "S3{id=$id, bucket=$bucket, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, private val endpoint: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonValue, - private val id: JsonField, - private val baseUrlForCanonicalHeader: 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("accessKey") - @ExcludeMissing - accessKey: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -944,6 +859,15 @@ private constructor( */ 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. * @@ -953,12 +877,20 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** * Expected to always return the following: @@ -971,12 +903,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -987,41 +913,16 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Path prefix inside the bucket. + * Returns the raw JSON value of [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. + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket @@ -1032,37 +933,6 @@ private constructor( */ @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 [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 [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]. * @@ -1073,6 +943,13 @@ private constructor( @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]. * @@ -1090,6 +967,16 @@ private constructor( @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) @@ -1109,11 +996,13 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` */ @JvmStatic fun builder() = Builder() @@ -1122,46 +1011,45 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + 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 secretKey: JsonField? = null + private var prefix: JsonField? = null + private var s3ForcePathStyle: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") - private var id: JsonField = JsonMissing.of() 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 + id = s3Compatible.id bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - name = s3Compatible.name - secretKey = s3Compatible.secretKey - type = s3Compatible.type - id = s3Compatible.id - baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader includeCanonicalHeader = s3Compatible.includeCanonicalHeader + name = s3Compatible.name prefix = s3Compatible.prefix s3ForcePathStyle = s3Compatible.s3ForcePathStyle + type = s3Compatible.type + baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader additionalProperties = s3Compatible.additionalProperties.toMutableMap() } - /** Access key for the bucket. */ - fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1187,6 +1075,21 @@ private constructor( */ 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)) @@ -1199,17 +1102,32 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + 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. @@ -1225,17 +1143,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1251,48 +1158,6 @@ private constructor( 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) @@ -1319,28 +1184,28 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), + checkRequired("s3ForcePathStyle", s3ForcePathStyle), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1352,21 +1217,19 @@ private constructor( return@apply } - accessKey() + id() bucket() endpoint() + includeCanonicalHeader() name() - secretKey() + prefix() + s3ForcePathStyle() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - s3ForcePathStyle() validated = true } @@ -1386,17 +1249,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (if (id.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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.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) + (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) { @@ -1404,33 +1265,29 @@ private constructor( } return other is S3Compatible && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && endpoint == other.endpoint && - name == other.name && - secretKey == other.secretKey && - type == other.type && - id == other.id && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, additionalProperties, ) } @@ -1438,62 +1295,53 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" + "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 accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -1503,6 +1351,15 @@ private constructor( */ 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. * @@ -1512,12 +1369,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -1530,12 +1387,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -1546,28 +1397,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -1577,25 +1411,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -1607,23 +1444,6 @@ private constructor( @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) @@ -1643,10 +1463,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -1655,42 +1476,41 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") - private var id: JsonField = JsonMissing.of() 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 + id = cloudinaryBackup.id bucket = cloudinaryBackup.bucket + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - secretKey = cloudinaryBackup.secretKey + prefix = cloudinaryBackup.prefix type = cloudinaryBackup.type - id = cloudinaryBackup.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1704,6 +1524,21 @@ private constructor( */ 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)) @@ -1716,17 +1551,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -1742,17 +1577,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1768,33 +1592,6 @@ private constructor( 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) @@ -1821,25 +1618,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -1851,19 +1647,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -1883,15 +1677,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1899,29 +1691,25 @@ private constructor( } return other is CloudinaryBackup && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -1929,47 +1717,56 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, 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. * @@ -1978,6 +1775,24 @@ private constructor( */ 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. * @@ -1997,12 +1812,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2012,38 +1821,6 @@ private constructor( 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 [id]. * @@ -2052,14 +1829,11 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [baseUrl]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** * Returns the raw JSON value of [forwardHostHeaderToOrigin]. @@ -2081,6 +1855,23 @@ private constructor( @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) @@ -2100,7 +1891,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2110,27 +1904,42 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { + id = webFolder.id baseUrl = webFolder.baseUrl + forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolder.includeCanonicalHeader name = webFolder.name type = webFolder.type - id = webFolder.id baseUrlForCanonicalHeader = webFolder.baseUrlForCanonicalHeader - forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin - includeCanonicalHeader = webFolder.includeCanonicalHeader 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)) @@ -2143,6 +1952,36 @@ private constructor( */ 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)) @@ -2169,17 +2008,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2195,36 +2023,6 @@ private constructor( 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) @@ -2251,7 +2049,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` * @@ -2259,13 +2060,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), + checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2277,17 +2078,17 @@ private constructor( return@apply } + id() baseUrl() + forwardHostHeaderToOrigin() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - forwardHostHeaderToOrigin() - includeCanonicalHeader() validated = true } @@ -2307,13 +2108,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (baseUrl.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2321,25 +2122,25 @@ private constructor( } return other is WebFolder && + id == other.id && baseUrl == other.baseUrl && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties, ) } @@ -2347,31 +2148,49 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) + ) : 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. @@ -2392,12 +2211,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2408,27 +2221,28 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [name]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2440,16 +2254,6 @@ private constructor( @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) @@ -2469,6 +2273,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2478,23 +2284,53 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: 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 - id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader - includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2521,17 +2357,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2547,21 +2372,6 @@ private constructor( 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) @@ -2588,6 +2398,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` * @@ -2595,11 +2407,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2611,15 +2423,15 @@ private constructor( return@apply } + id() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -2639,11 +2451,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2651,21 +2463,21 @@ private constructor( } return other is WebProxy && + id == other.id && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -2673,55 +2485,59 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + 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 privateKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("privateKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -2734,6 +2550,15 @@ private constructor( */ 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. * @@ -2746,7 +2571,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 privateKey(): String = privateKey.getRequired("privateKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -2759,12 +2584,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2775,19 +2594,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -2806,27 +2617,28 @@ private constructor( fun _clientEmail(): JsonField = clientEmail /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [privateKey]. + * Returns the raw JSON value of [name]. * - * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("privateKey") - @ExcludeMissing - fun _privateKey(): JsonField = privateKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2838,23 +2650,6 @@ private constructor( @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) @@ -2870,47 +2665,62 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java + * .id() * .bucket() * .clientEmail() + * .includeCanonicalHeader() * .name() - * .privateKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** 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 privateKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") - private var id: JsonField = JsonMissing.of() 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - id = googleCloudStorageGcs.id - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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)) /** @@ -2935,6 +2745,21 @@ private constructor( 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)) @@ -2947,16 +2772,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.privateKey] to an arbitrary JSON value. + * Sets [Builder.prefix] 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 + * 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 privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -2972,17 +2797,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2998,32 +2812,6 @@ private constructor( 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) @@ -3044,55 +2832,55 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * 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() - * .privateKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("privateKey", privateKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } + id() bucket() clientEmail() + includeCanonicalHeader() name() - privateKey() + prefix() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3112,45 +2900,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (bucket.asKnown().isPresent) 1 else 0) + + (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 (privateKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("GCS")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && + id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - privateKey == other.privateKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3158,57 +2943,61 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + 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 sasToken: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("sasToken") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - sasToken: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -3221,6 +3010,15 @@ private constructor( */ 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. * @@ -3233,7 +3031,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 sasToken(): String = sasToken.getRequired("sasToken") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -3246,12 +3044,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -3262,19 +3054,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [accountName]. @@ -3293,25 +3077,28 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [sasToken]. + * Returns the raw JSON value of [name]. * - * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3323,23 +3110,6 @@ private constructor( @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) @@ -3355,46 +3125,61 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java + * .id() * .accountName() * .container() + * .includeCanonicalHeader() * .name() - * .sasToken() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** 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 sasToken: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") - private var id: JsonField = JsonMissing.of() 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(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - id = azureBlobStorage.id - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() - } + @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)) @@ -3420,6 +3205,21 @@ private constructor( */ 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)) @@ -3432,16 +3232,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.sasToken] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.sasToken] with a well-typed [String] value instead. + * 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 sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -3457,17 +3257,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3483,32 +3272,6 @@ private constructor( 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) @@ -3529,55 +3292,55 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * 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() - * .sasToken() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( + checkRequired("id", id), checkRequired("accountName", accountName), checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("sasToken", sasToken), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } + id() accountName() container() + includeCanonicalHeader() name() - sasToken() + prefix() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3597,45 +3360,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accountName.asKnown().isPresent) 1 else 0) + + (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 (sasToken.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("AZURE_BLOB")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AzureBlobStorage && + return other is AzureBlob && + id == other.id && accountName == other.accountName && container == other.container && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - sasToken == other.sasToken && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3643,85 +3403,67 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 clientId: JsonField, - private val clientSecret: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val password: JsonField, private val type: JsonValue, - private val username: JsonField, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("clientId") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - clientSecret: JsonField = JsonMissing.of(), + includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, mutableMapOf(), ) /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun id(): String = id.getRequired("id") /** - * Akeneo API client 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 clientId(): String = clientId.getRequired("clientId") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo API client secret. + * 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 clientSecret(): String = clientSecret.getRequired("clientSecret") + fun includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") /** * Display name of the origin. @@ -3731,14 +3473,6 @@ private constructor( */ 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 @@ -3750,20 +3484,6 @@ private constructor( */ @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") - - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -3774,13 +3494,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrl]. @@ -3790,21 +3508,14 @@ private constructor( @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]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _clientSecret(): JsonField = clientSecret + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [name]. @@ -3813,27 +3524,6 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3844,16 +3534,6 @@ private constructor( @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) @@ -3873,12 +3553,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3887,69 +3565,65 @@ private constructor( /** A builder for [AkeneoPim]. */ class Builder internal constructor() { + private var id: JsonField? = null private var baseUrl: JsonField? = null - private var clientId: JsonField? = null - private var clientSecret: JsonField? = null + private var includeCanonicalHeader: 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { + id = akeneoPim.id baseUrl = akeneoPim.baseUrl - clientId = akeneoPim.clientId - clientSecret = akeneoPim.clientSecret + includeCanonicalHeader = akeneoPim.includeCanonicalHeader name = akeneoPim.name - password = akeneoPim.password type = akeneoPim.type - username = akeneoPim.username - id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader - includeCanonicalHeader = akeneoPim.includeCanonicalHeader additionalProperties = akeneoPim.additionalProperties.toMutableMap() } - /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + /** + * 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.baseUrl] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + fun id(id: JsonField) = apply { this.id = id } - /** Akeneo API client ID. */ - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + /** Akeneo instance base URL. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) /** - * Sets [Builder.clientId] to an arbitrary JSON value. + * Sets [Builder.baseUrl] to an arbitrary JSON value. * - * You should usually call [Builder.clientId] with a well-typed [String] value instead. + * 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 clientId(clientId: JsonField) = apply { this.clientId = clientId } + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Akeneo API client secret. */ - fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) /** - * Sets [Builder.clientSecret] to an arbitrary JSON value. + * Sets [Builder.includeCanonicalHeader] 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. + * 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 clientSecret(clientSecret: JsonField) = apply { - this.clientSecret = clientSecret + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader } /** Display name of the origin. */ @@ -3964,18 +3638,6 @@ private constructor( */ 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. * @@ -3990,29 +3652,6 @@ private constructor( */ 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 } - - 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -4028,21 +3667,6 @@ private constructor( 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) @@ -4069,28 +3693,22 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("clientId", clientId), - checkRequired("clientSecret", clientSecret), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("password", password), type, - checkRequired("username", username), - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -4102,20 +3720,16 @@ private constructor( return@apply } + id() baseUrl() - clientId() - clientSecret() + includeCanonicalHeader() name() - password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - username() - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -4135,16 +3749,12 @@ private constructor( */ @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 (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) + - (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -4152,31 +3762,23 @@ private constructor( } return other is AkeneoPim && + id == other.id && baseUrl == other.baseUrl && - clientId == other.clientId && - clientSecret == other.clientSecret && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - password == other.password && type == other.type && - username == other.username && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -4184,6 +3786,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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/OriginListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt index 7ac98a64..8ec0a69e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt @@ -19,14 +19,15 @@ 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.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 = OriginListResponse.Deserializer::class) @JsonSerialize(using = OriginListResponse.Serializer::class) class OriginListResponse @@ -36,8 +37,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -52,10 +53,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -69,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -85,10 +85,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -101,9 +100,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -137,14 +135,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -183,12 +179,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -207,8 +200,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -219,8 +212,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -231,9 +224,8 @@ private constructor( cloudinaryBackup != null -> "OriginListResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginListResponse{webFolder=$webFolder}" webProxy != null -> "OriginListResponse{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "OriginListResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "OriginListResponse{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "OriginListResponse{gcs=$gcs}" + azureBlob != null -> "OriginListResponse{azureBlob=$azureBlob}" akeneoPim != null -> "OriginListResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginListResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginListResponse") @@ -255,13 +247,9 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginListResponse(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - OriginListResponse(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginListResponse(gcs = gcs) - @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - OriginListResponse(azureBlobStorage = azureBlobStorage) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginListResponse(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginListResponse(akeneoPim = akeneoPim) } @@ -282,9 +270,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -307,46 +295,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginListResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(akeneoPim = 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 -> OriginListResponse(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(s3 = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(s3Compatible = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(cloudinaryBackup = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(webFolder = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(webProxy = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(gcs = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(azureBlob = it, _json = json) + } ?: OriginListResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginListResponse(akeneoPim = it, _json = json) + } ?: OriginListResponse(_json = json) + } } + + return OriginListResponse(_json = json) } } @@ -363,9 +357,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 OriginListResponse") @@ -375,57 +368,48 @@ private constructor( class S3 private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -435,6 +419,15 @@ private constructor( */ 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. * @@ -444,12 +437,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -462,12 +455,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -478,28 +465,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -509,25 +479,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -539,23 +512,6 @@ private constructor( @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) @@ -575,10 +531,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -587,42 +544,41 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("S3") - private var id: JsonField = JsonMissing.of() 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 + id = s3.id bucket = s3.bucket + includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - secretKey = s3.secretKey + prefix = s3.prefix type = s3.type - id = s3.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -636,6 +592,21 @@ private constructor( */ 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)) @@ -648,17 +619,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -674,17 +645,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -700,33 +660,6 @@ private constructor( 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) @@ -753,25 +686,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -783,19 +715,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -815,15 +745,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -831,29 +759,25 @@ private constructor( } return other is S3 && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -861,72 +785,63 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "S3{id=$id, bucket=$bucket, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, private val endpoint: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonValue, - private val id: JsonField, - private val baseUrlForCanonicalHeader: 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("accessKey") - @ExcludeMissing - accessKey: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -944,6 +859,15 @@ private constructor( */ 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. * @@ -953,12 +877,20 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** * Expected to always return the following: @@ -971,12 +903,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -987,41 +913,16 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Path prefix inside the bucket. + * Returns the raw JSON value of [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. + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket @@ -1032,37 +933,6 @@ private constructor( */ @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 [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 [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]. * @@ -1073,6 +943,13 @@ private constructor( @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]. * @@ -1090,6 +967,16 @@ private constructor( @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) @@ -1109,11 +996,13 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` */ @JvmStatic fun builder() = Builder() @@ -1122,46 +1011,45 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + 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 secretKey: JsonField? = null + private var prefix: JsonField? = null + private var s3ForcePathStyle: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") - private var id: JsonField = JsonMissing.of() 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 + id = s3Compatible.id bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - name = s3Compatible.name - secretKey = s3Compatible.secretKey - type = s3Compatible.type - id = s3Compatible.id - baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader includeCanonicalHeader = s3Compatible.includeCanonicalHeader + name = s3Compatible.name prefix = s3Compatible.prefix s3ForcePathStyle = s3Compatible.s3ForcePathStyle + type = s3Compatible.type + baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader additionalProperties = s3Compatible.additionalProperties.toMutableMap() } - /** Access key for the bucket. */ - fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1187,6 +1075,21 @@ private constructor( */ 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)) @@ -1199,17 +1102,32 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + 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. @@ -1225,17 +1143,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1251,48 +1158,6 @@ private constructor( 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) @@ -1319,28 +1184,28 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), + checkRequired("s3ForcePathStyle", s3ForcePathStyle), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1352,21 +1217,19 @@ private constructor( return@apply } - accessKey() + id() bucket() endpoint() + includeCanonicalHeader() name() - secretKey() + prefix() + s3ForcePathStyle() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - s3ForcePathStyle() validated = true } @@ -1386,17 +1249,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (if (id.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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.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) + (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) { @@ -1404,33 +1265,29 @@ private constructor( } return other is S3Compatible && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && endpoint == other.endpoint && - name == other.name && - secretKey == other.secretKey && - type == other.type && - id == other.id && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, additionalProperties, ) } @@ -1438,62 +1295,53 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" + "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 accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -1503,6 +1351,15 @@ private constructor( */ 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. * @@ -1512,12 +1369,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -1530,12 +1387,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -1546,28 +1397,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -1577,25 +1411,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -1607,23 +1444,6 @@ private constructor( @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) @@ -1643,10 +1463,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -1655,42 +1476,41 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") - private var id: JsonField = JsonMissing.of() 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 + id = cloudinaryBackup.id bucket = cloudinaryBackup.bucket + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - secretKey = cloudinaryBackup.secretKey + prefix = cloudinaryBackup.prefix type = cloudinaryBackup.type - id = cloudinaryBackup.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1704,6 +1524,21 @@ private constructor( */ 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)) @@ -1716,17 +1551,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -1742,17 +1577,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1768,33 +1592,6 @@ private constructor( 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) @@ -1821,25 +1618,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -1851,19 +1647,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -1883,15 +1677,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1899,29 +1691,25 @@ private constructor( } return other is CloudinaryBackup && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -1929,47 +1717,56 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, 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. * @@ -1978,6 +1775,24 @@ private constructor( */ 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. * @@ -1997,12 +1812,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2012,38 +1821,6 @@ private constructor( 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 [id]. * @@ -2052,14 +1829,11 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [baseUrl]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** * Returns the raw JSON value of [forwardHostHeaderToOrigin]. @@ -2081,6 +1855,23 @@ private constructor( @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) @@ -2100,7 +1891,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2110,27 +1904,42 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { + id = webFolder.id baseUrl = webFolder.baseUrl + forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolder.includeCanonicalHeader name = webFolder.name type = webFolder.type - id = webFolder.id baseUrlForCanonicalHeader = webFolder.baseUrlForCanonicalHeader - forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin - includeCanonicalHeader = webFolder.includeCanonicalHeader 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)) @@ -2143,6 +1952,36 @@ private constructor( */ 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)) @@ -2169,17 +2008,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2195,36 +2023,6 @@ private constructor( 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) @@ -2251,7 +2049,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` * @@ -2259,13 +2060,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), + checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2277,17 +2078,17 @@ private constructor( return@apply } + id() baseUrl() + forwardHostHeaderToOrigin() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - forwardHostHeaderToOrigin() - includeCanonicalHeader() validated = true } @@ -2307,13 +2108,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (baseUrl.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2321,25 +2122,25 @@ private constructor( } return other is WebFolder && + id == other.id && baseUrl == other.baseUrl && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties, ) } @@ -2347,31 +2148,49 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) + ) : 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. @@ -2392,12 +2211,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2408,27 +2221,28 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [name]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2440,16 +2254,6 @@ private constructor( @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) @@ -2469,6 +2273,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2478,23 +2284,53 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: 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 - id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader - includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2521,17 +2357,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2547,21 +2372,6 @@ private constructor( 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) @@ -2588,6 +2398,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` * @@ -2595,11 +2407,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2611,15 +2423,15 @@ private constructor( return@apply } + id() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -2639,11 +2451,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2651,21 +2463,21 @@ private constructor( } return other is WebProxy && + id == other.id && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -2673,55 +2485,59 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + 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 privateKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("privateKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -2734,6 +2550,15 @@ private constructor( */ 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. * @@ -2746,7 +2571,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 privateKey(): String = privateKey.getRequired("privateKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -2759,12 +2584,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2775,19 +2594,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -2806,27 +2617,28 @@ private constructor( fun _clientEmail(): JsonField = clientEmail /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [privateKey]. + * Returns the raw JSON value of [name]. * - * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("privateKey") - @ExcludeMissing - fun _privateKey(): JsonField = privateKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2838,23 +2650,6 @@ private constructor( @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) @@ -2870,47 +2665,62 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java + * .id() * .bucket() * .clientEmail() + * .includeCanonicalHeader() * .name() - * .privateKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** 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 privateKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") - private var id: JsonField = JsonMissing.of() 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - id = googleCloudStorageGcs.id - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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)) /** @@ -2935,6 +2745,21 @@ private constructor( 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)) @@ -2947,16 +2772,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.privateKey] to an arbitrary JSON value. + * Sets [Builder.prefix] 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 + * 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 privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -2972,17 +2797,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2998,32 +2812,6 @@ private constructor( 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) @@ -3044,55 +2832,55 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * 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() - * .privateKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("privateKey", privateKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } + id() bucket() clientEmail() + includeCanonicalHeader() name() - privateKey() + prefix() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3112,45 +2900,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (bucket.asKnown().isPresent) 1 else 0) + + (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 (privateKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("GCS")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && + id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - privateKey == other.privateKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3158,57 +2943,61 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + 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 sasToken: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("sasToken") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - sasToken: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -3221,6 +3010,15 @@ private constructor( */ 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. * @@ -3233,7 +3031,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 sasToken(): String = sasToken.getRequired("sasToken") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -3246,12 +3044,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -3262,19 +3054,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [accountName]. @@ -3293,25 +3077,28 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [sasToken]. + * Returns the raw JSON value of [name]. * - * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3323,23 +3110,6 @@ private constructor( @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) @@ -3355,46 +3125,61 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java + * .id() * .accountName() * .container() + * .includeCanonicalHeader() * .name() - * .sasToken() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** 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 sasToken: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") - private var id: JsonField = JsonMissing.of() 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(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - id = azureBlobStorage.id - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() - } + @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)) @@ -3420,6 +3205,21 @@ private constructor( */ 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)) @@ -3432,16 +3232,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.sasToken] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.sasToken] with a well-typed [String] value instead. + * 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 sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -3457,17 +3257,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3483,32 +3272,6 @@ private constructor( 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) @@ -3529,55 +3292,55 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * 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() - * .sasToken() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( + checkRequired("id", id), checkRequired("accountName", accountName), checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("sasToken", sasToken), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } + id() accountName() container() + includeCanonicalHeader() name() - sasToken() + prefix() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3597,45 +3360,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accountName.asKnown().isPresent) 1 else 0) + + (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 (sasToken.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("AZURE_BLOB")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AzureBlobStorage && + return other is AzureBlob && + id == other.id && accountName == other.accountName && container == other.container && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - sasToken == other.sasToken && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3643,85 +3403,67 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 clientId: JsonField, - private val clientSecret: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val password: JsonField, private val type: JsonValue, - private val username: JsonField, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("clientId") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - clientSecret: JsonField = JsonMissing.of(), + includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, mutableMapOf(), ) /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun id(): String = id.getRequired("id") /** - * Akeneo API client 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 clientId(): String = clientId.getRequired("clientId") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo API client secret. + * 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 clientSecret(): String = clientSecret.getRequired("clientSecret") + fun includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") /** * Display name of the origin. @@ -3731,14 +3473,6 @@ private constructor( */ 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 @@ -3750,20 +3484,6 @@ private constructor( */ @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") - - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -3774,13 +3494,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrl]. @@ -3790,21 +3508,14 @@ private constructor( @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]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _clientSecret(): JsonField = clientSecret + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [name]. @@ -3813,27 +3524,6 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3844,16 +3534,6 @@ private constructor( @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) @@ -3873,12 +3553,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3887,69 +3565,65 @@ private constructor( /** A builder for [AkeneoPim]. */ class Builder internal constructor() { + private var id: JsonField? = null private var baseUrl: JsonField? = null - private var clientId: JsonField? = null - private var clientSecret: JsonField? = null + private var includeCanonicalHeader: 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { + id = akeneoPim.id baseUrl = akeneoPim.baseUrl - clientId = akeneoPim.clientId - clientSecret = akeneoPim.clientSecret + includeCanonicalHeader = akeneoPim.includeCanonicalHeader name = akeneoPim.name - password = akeneoPim.password type = akeneoPim.type - username = akeneoPim.username - id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader - includeCanonicalHeader = akeneoPim.includeCanonicalHeader additionalProperties = akeneoPim.additionalProperties.toMutableMap() } - /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + /** + * 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.baseUrl] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + fun id(id: JsonField) = apply { this.id = id } - /** Akeneo API client ID. */ - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + /** Akeneo instance base URL. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) /** - * Sets [Builder.clientId] to an arbitrary JSON value. + * Sets [Builder.baseUrl] to an arbitrary JSON value. * - * You should usually call [Builder.clientId] with a well-typed [String] value instead. + * 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 clientId(clientId: JsonField) = apply { this.clientId = clientId } + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Akeneo API client secret. */ - fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) /** - * Sets [Builder.clientSecret] to an arbitrary JSON value. + * Sets [Builder.includeCanonicalHeader] 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. + * 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 clientSecret(clientSecret: JsonField) = apply { - this.clientSecret = clientSecret + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader } /** Display name of the origin. */ @@ -3964,18 +3638,6 @@ private constructor( */ 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. * @@ -3990,29 +3652,6 @@ private constructor( */ 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 } - - 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -4028,21 +3667,6 @@ private constructor( 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) @@ -4069,28 +3693,22 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("clientId", clientId), - checkRequired("clientSecret", clientSecret), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("password", password), type, - checkRequired("username", username), - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -4102,20 +3720,16 @@ private constructor( return@apply } + id() baseUrl() - clientId() - clientSecret() + includeCanonicalHeader() name() - password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - username() - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -4135,16 +3749,12 @@ private constructor( */ @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 (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) + - (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -4152,31 +3762,23 @@ private constructor( } return other is AkeneoPim && + id == other.id && baseUrl == other.baseUrl && - clientId == other.clientId && - clientSecret == other.clientSecret && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - password == other.password && type == other.type && - username == other.username && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -4184,6 +3786,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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/OriginUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt index d6005a3e..06009d04 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt @@ -19,14 +19,15 @@ 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.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 = OriginUpdateResponse.Deserializer::class) @JsonSerialize(using = OriginUpdateResponse.Serializer::class) class OriginUpdateResponse @@ -36,8 +37,8 @@ private constructor( private val cloudinaryBackup: CloudinaryBackup? = null, private val webFolder: WebFolder? = null, private val webProxy: WebProxy? = null, - private val googleCloudStorageGcs: GoogleCloudStorageGcs? = null, - private val azureBlobStorage: AzureBlobStorage? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, private val akeneoPim: AkeneoPim? = null, private val _json: JsonValue? = null, ) { @@ -52,10 +53,9 @@ private constructor( fun webProxy(): Optional = Optional.ofNullable(webProxy) - fun googleCloudStorageGcs(): Optional = - Optional.ofNullable(googleCloudStorageGcs) + fun gcs(): Optional = Optional.ofNullable(gcs) - fun azureBlobStorage(): Optional = Optional.ofNullable(azureBlobStorage) + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) @@ -69,9 +69,9 @@ private constructor( fun isWebProxy(): Boolean = webProxy != null - fun isGoogleCloudStorageGcs(): Boolean = googleCloudStorageGcs != null + fun isGcs(): Boolean = gcs != null - fun isAzureBlobStorage(): Boolean = azureBlobStorage != null + fun isAzureBlob(): Boolean = azureBlob != null fun isAkeneoPim(): Boolean = akeneoPim != null @@ -85,10 +85,9 @@ private constructor( fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") - fun asGoogleCloudStorageGcs(): GoogleCloudStorageGcs = - googleCloudStorageGcs.getOrThrow("googleCloudStorageGcs") + fun asGcs(): Gcs = gcs.getOrThrow("gcs") - fun asAzureBlobStorage(): AzureBlobStorage = azureBlobStorage.getOrThrow("azureBlobStorage") + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") @@ -101,9 +100,8 @@ private constructor( cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) webFolder != null -> visitor.visitWebFolder(webFolder) webProxy != null -> visitor.visitWebProxy(webProxy) - googleCloudStorageGcs != null -> - visitor.visitGoogleCloudStorageGcs(googleCloudStorageGcs) - azureBlobStorage != null -> visitor.visitAzureBlobStorage(azureBlobStorage) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) else -> visitor.unknown(_json) } @@ -137,14 +135,12 @@ private constructor( webProxy.validate() } - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) { - googleCloudStorageGcs.validate() + override fun visitGcs(gcs: Gcs) { + gcs.validate() } - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) { - azureBlobStorage.validate() + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() } override fun visitAkeneoPim(akeneoPim: AkeneoPim) { @@ -183,12 +179,9 @@ private constructor( override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() - override fun visitGoogleCloudStorageGcs( - googleCloudStorageGcs: GoogleCloudStorageGcs - ) = googleCloudStorageGcs.validity() + override fun visitGcs(gcs: Gcs) = gcs.validity() - override fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - azureBlobStorage.validity() + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() @@ -207,8 +200,8 @@ private constructor( cloudinaryBackup == other.cloudinaryBackup && webFolder == other.webFolder && webProxy == other.webProxy && - googleCloudStorageGcs == other.googleCloudStorageGcs && - azureBlobStorage == other.azureBlobStorage && + gcs == other.gcs && + azureBlob == other.azureBlob && akeneoPim == other.akeneoPim } @@ -219,8 +212,8 @@ private constructor( cloudinaryBackup, webFolder, webProxy, - googleCloudStorageGcs, - azureBlobStorage, + gcs, + azureBlob, akeneoPim, ) @@ -231,9 +224,8 @@ private constructor( cloudinaryBackup != null -> "OriginUpdateResponse{cloudinaryBackup=$cloudinaryBackup}" webFolder != null -> "OriginUpdateResponse{webFolder=$webFolder}" webProxy != null -> "OriginUpdateResponse{webProxy=$webProxy}" - googleCloudStorageGcs != null -> - "OriginUpdateResponse{googleCloudStorageGcs=$googleCloudStorageGcs}" - azureBlobStorage != null -> "OriginUpdateResponse{azureBlobStorage=$azureBlobStorage}" + gcs != null -> "OriginUpdateResponse{gcs=$gcs}" + azureBlob != null -> "OriginUpdateResponse{azureBlob=$azureBlob}" akeneoPim != null -> "OriginUpdateResponse{akeneoPim=$akeneoPim}" _json != null -> "OriginUpdateResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid OriginUpdateResponse") @@ -256,13 +248,10 @@ private constructor( @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginUpdateResponse(webProxy = webProxy) - @JvmStatic - fun ofGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs) = - OriginUpdateResponse(googleCloudStorageGcs = googleCloudStorageGcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginUpdateResponse(gcs = gcs) @JvmStatic - fun ofAzureBlobStorage(azureBlobStorage: AzureBlobStorage) = - OriginUpdateResponse(azureBlobStorage = azureBlobStorage) + fun ofAzureBlob(azureBlob: AzureBlob) = OriginUpdateResponse(azureBlob = azureBlob) @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginUpdateResponse(akeneoPim = akeneoPim) @@ -284,9 +273,9 @@ private constructor( fun visitWebProxy(webProxy: WebProxy): T - fun visitGoogleCloudStorageGcs(googleCloudStorageGcs: GoogleCloudStorageGcs): T + fun visitGcs(gcs: Gcs): T - fun visitAzureBlobStorage(azureBlobStorage: AzureBlobStorage): T + fun visitAzureBlob(azureBlob: AzureBlob): T fun visitAkeneoPim(akeneoPim: AkeneoPim): T @@ -310,46 +299,52 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): OriginUpdateResponse { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(s3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(s3Compatible = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(cloudinaryBackup = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(webFolder = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(webProxy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(googleCloudStorageGcs = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(azureBlobStorage = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(akeneoPim = 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 -> OriginUpdateResponse(_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) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(s3 = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(s3Compatible = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(cloudinaryBackup = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(webFolder = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(webProxy = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(gcs = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(azureBlob = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginUpdateResponse(akeneoPim = it, _json = json) + } ?: OriginUpdateResponse(_json = json) + } } + + return OriginUpdateResponse(_json = json) } } @@ -366,9 +361,8 @@ private constructor( value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) value.webFolder != null -> generator.writeObject(value.webFolder) value.webProxy != null -> generator.writeObject(value.webProxy) - value.googleCloudStorageGcs != null -> - generator.writeObject(value.googleCloudStorageGcs) - value.azureBlobStorage != null -> generator.writeObject(value.azureBlobStorage) + 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 OriginUpdateResponse") @@ -378,57 +372,48 @@ private constructor( class S3 private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -438,6 +423,15 @@ private constructor( */ 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. * @@ -447,12 +441,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -465,12 +459,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -481,28 +469,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -512,25 +483,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -542,23 +516,6 @@ private constructor( @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) @@ -578,10 +535,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -590,42 +548,41 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("S3") - private var id: JsonField = JsonMissing.of() 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 + id = s3.id bucket = s3.bucket + includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - secretKey = s3.secretKey + prefix = s3.prefix type = s3.type - id = s3.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -639,6 +596,21 @@ private constructor( */ 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)) @@ -651,17 +623,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -677,17 +649,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -703,33 +664,6 @@ private constructor( 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) @@ -756,25 +690,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -786,19 +719,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -818,15 +749,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -834,29 +763,25 @@ private constructor( } return other is S3 && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -864,72 +789,63 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "S3{id=$id, bucket=$bucket, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, private val endpoint: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonValue, - private val id: JsonField, - private val baseUrlForCanonicalHeader: 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("accessKey") - @ExcludeMissing - accessKey: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -947,6 +863,15 @@ private constructor( */ 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. * @@ -956,12 +881,20 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** * Expected to always return the following: @@ -974,12 +907,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -990,43 +917,18 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Path prefix inside the bucket. + * Returns the raw JSON value of [bucket]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. */ - 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 + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** * Returns the raw JSON value of [endpoint]. @@ -1035,37 +937,6 @@ private constructor( */ @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 [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 [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]. * @@ -1076,6 +947,13 @@ private constructor( @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]. * @@ -1093,6 +971,16 @@ private constructor( @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) @@ -1112,11 +1000,13 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` */ @JvmStatic fun builder() = Builder() @@ -1125,46 +1015,45 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + 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 secretKey: JsonField? = null + private var prefix: JsonField? = null + private var s3ForcePathStyle: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") - private var id: JsonField = JsonMissing.of() 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 + id = s3Compatible.id bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - name = s3Compatible.name - secretKey = s3Compatible.secretKey - type = s3Compatible.type - id = s3Compatible.id - baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader includeCanonicalHeader = s3Compatible.includeCanonicalHeader + name = s3Compatible.name prefix = s3Compatible.prefix s3ForcePathStyle = s3Compatible.s3ForcePathStyle + type = s3Compatible.type + baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader additionalProperties = s3Compatible.additionalProperties.toMutableMap() } - /** Access key for the bucket. */ - fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1190,6 +1079,21 @@ private constructor( */ 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)) @@ -1202,17 +1106,32 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + 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. @@ -1228,17 +1147,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1254,48 +1162,6 @@ private constructor( 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) @@ -1322,28 +1188,28 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), + checkRequired("s3ForcePathStyle", s3ForcePathStyle), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1355,21 +1221,19 @@ private constructor( return@apply } - accessKey() + id() bucket() endpoint() + includeCanonicalHeader() name() - secretKey() + prefix() + s3ForcePathStyle() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - s3ForcePathStyle() validated = true } @@ -1389,17 +1253,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (if (id.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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.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) + (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) { @@ -1407,33 +1269,29 @@ private constructor( } return other is S3Compatible && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && endpoint == other.endpoint && - name == other.name && - secretKey == other.secretKey && - type == other.type && - id == other.id && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, additionalProperties, ) } @@ -1441,62 +1299,53 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" + "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 accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -1506,6 +1355,15 @@ private constructor( */ 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. * @@ -1515,12 +1373,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -1533,12 +1391,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -1549,28 +1401,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -1580,25 +1415,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -1610,23 +1448,6 @@ private constructor( @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) @@ -1646,10 +1467,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -1658,42 +1480,41 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") - private var id: JsonField = JsonMissing.of() 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 + id = cloudinaryBackup.id bucket = cloudinaryBackup.bucket + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - secretKey = cloudinaryBackup.secretKey + prefix = cloudinaryBackup.prefix type = cloudinaryBackup.type - id = cloudinaryBackup.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1707,6 +1528,21 @@ private constructor( */ 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)) @@ -1719,17 +1555,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -1745,17 +1581,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1771,33 +1596,6 @@ private constructor( 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) @@ -1824,25 +1622,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -1854,19 +1651,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -1886,15 +1681,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1902,29 +1695,25 @@ private constructor( } return other is CloudinaryBackup && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -1932,47 +1721,56 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, 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. * @@ -1981,6 +1779,24 @@ private constructor( */ 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. * @@ -2000,12 +1816,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2015,38 +1825,6 @@ private constructor( 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 [id]. * @@ -2055,14 +1833,11 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [baseUrl]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** * Returns the raw JSON value of [forwardHostHeaderToOrigin]. @@ -2084,6 +1859,23 @@ private constructor( @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) @@ -2103,7 +1895,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2113,27 +1908,42 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { + id = webFolder.id baseUrl = webFolder.baseUrl + forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolder.includeCanonicalHeader name = webFolder.name type = webFolder.type - id = webFolder.id baseUrlForCanonicalHeader = webFolder.baseUrlForCanonicalHeader - forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin - includeCanonicalHeader = webFolder.includeCanonicalHeader 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)) @@ -2146,6 +1956,36 @@ private constructor( */ 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)) @@ -2172,17 +2012,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2198,36 +2027,6 @@ private constructor( 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) @@ -2254,7 +2053,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` * @@ -2262,13 +2064,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), + checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2280,17 +2082,17 @@ private constructor( return@apply } + id() baseUrl() + forwardHostHeaderToOrigin() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - forwardHostHeaderToOrigin() - includeCanonicalHeader() validated = true } @@ -2310,13 +2112,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (baseUrl.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2324,25 +2126,25 @@ private constructor( } return other is WebFolder && + id == other.id && baseUrl == other.baseUrl && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties, ) } @@ -2350,31 +2152,49 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) + ) : 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. @@ -2395,12 +2215,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2411,27 +2225,28 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [name]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2443,16 +2258,6 @@ private constructor( @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) @@ -2472,6 +2277,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2481,23 +2288,53 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: 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 - id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader - includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2524,17 +2361,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2550,21 +2376,6 @@ private constructor( 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) @@ -2591,6 +2402,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` * @@ -2598,11 +2411,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2614,15 +2427,15 @@ private constructor( return@apply } + id() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -2642,11 +2455,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2654,21 +2467,21 @@ private constructor( } return other is WebProxy && + id == other.id && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -2676,55 +2489,59 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class GoogleCloudStorageGcs + 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 privateKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("privateKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -2737,6 +2554,15 @@ private constructor( */ 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. * @@ -2749,7 +2575,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 privateKey(): String = privateKey.getRequired("privateKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -2762,12 +2588,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -2778,19 +2598,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -2809,27 +2621,28 @@ private constructor( fun _clientEmail(): JsonField = clientEmail /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [privateKey]. + * Returns the raw JSON value of [name]. * - * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("privateKey") - @ExcludeMissing - fun _privateKey(): JsonField = privateKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2841,23 +2654,6 @@ private constructor( @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) @@ -2873,47 +2669,62 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GoogleCloudStorageGcs]. + * Returns a mutable builder for constructing an instance of [Gcs]. * * The following fields are required: * ```java + * .id() * .bucket() * .clientEmail() + * .includeCanonicalHeader() * .name() - * .privateKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [GoogleCloudStorageGcs]. */ + /** 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 privateKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") - private var id: JsonField = JsonMissing.of() 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(googleCloudStorageGcs: GoogleCloudStorageGcs) = apply { - bucket = googleCloudStorageGcs.bucket - clientEmail = googleCloudStorageGcs.clientEmail - name = googleCloudStorageGcs.name - privateKey = googleCloudStorageGcs.privateKey - type = googleCloudStorageGcs.type - id = googleCloudStorageGcs.id - baseUrlForCanonicalHeader = googleCloudStorageGcs.baseUrlForCanonicalHeader - includeCanonicalHeader = googleCloudStorageGcs.includeCanonicalHeader - prefix = googleCloudStorageGcs.prefix - additionalProperties = googleCloudStorageGcs.additionalProperties.toMutableMap() + 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)) /** @@ -2938,6 +2749,21 @@ private constructor( 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)) @@ -2950,16 +2776,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.privateKey] to an arbitrary JSON value. + * Sets [Builder.prefix] 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 + * 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 privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -2975,17 +2801,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3001,32 +2816,6 @@ private constructor( 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) @@ -3047,55 +2836,55 @@ private constructor( } /** - * Returns an immutable instance of [GoogleCloudStorageGcs]. + * 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() - * .privateKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): GoogleCloudStorageGcs = - GoogleCloudStorageGcs( + fun build(): Gcs = + Gcs( + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("privateKey", privateKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): GoogleCloudStorageGcs = apply { + fun validate(): Gcs = apply { if (validated) { return@apply } + id() bucket() clientEmail() + includeCanonicalHeader() name() - privateKey() + prefix() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3115,45 +2904,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (bucket.asKnown().isPresent) 1 else 0) + + (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 (privateKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("GCS")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is GoogleCloudStorageGcs && + return other is Gcs && + id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - privateKey == other.privateKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3161,57 +2947,61 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GoogleCloudStorageGcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } - class AzureBlobStorage + 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 sasToken: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("sasToken") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - sasToken: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -3224,6 +3014,15 @@ private constructor( */ 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. * @@ -3236,7 +3035,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 sasToken(): String = sasToken.getRequired("sasToken") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -3249,12 +3048,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -3265,19 +3058,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [accountName]. @@ -3296,25 +3081,28 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [sasToken]. + * Returns the raw JSON value of [name]. * - * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3326,23 +3114,6 @@ private constructor( @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) @@ -3358,46 +3129,61 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AzureBlobStorage]. + * Returns a mutable builder for constructing an instance of [AzureBlob]. * * The following fields are required: * ```java + * .id() * .accountName() * .container() + * .includeCanonicalHeader() * .name() - * .sasToken() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AzureBlobStorage]. */ + /** 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 sasToken: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") - private var id: JsonField = JsonMissing.of() 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(azureBlobStorage: AzureBlobStorage) = apply { - accountName = azureBlobStorage.accountName - container = azureBlobStorage.container - name = azureBlobStorage.name - sasToken = azureBlobStorage.sasToken - type = azureBlobStorage.type - id = azureBlobStorage.id - baseUrlForCanonicalHeader = azureBlobStorage.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlobStorage.includeCanonicalHeader - prefix = azureBlobStorage.prefix - additionalProperties = azureBlobStorage.additionalProperties.toMutableMap() - } + @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)) @@ -3423,6 +3209,21 @@ private constructor( */ 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)) @@ -3435,16 +3236,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.sasToken] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.sasToken] with a well-typed [String] value instead. + * 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 sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -3460,17 +3261,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3486,32 +3276,6 @@ private constructor( 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) @@ -3532,55 +3296,55 @@ private constructor( } /** - * Returns an immutable instance of [AzureBlobStorage]. + * 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() - * .sasToken() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AzureBlobStorage = - AzureBlobStorage( + fun build(): AzureBlob = + AzureBlob( + checkRequired("id", id), checkRequired("accountName", accountName), checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("sasToken", sasToken), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AzureBlobStorage = apply { + fun validate(): AzureBlob = apply { if (validated) { return@apply } + id() accountName() container() + includeCanonicalHeader() name() - sasToken() + prefix() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3600,45 +3364,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accountName.asKnown().isPresent) 1 else 0) + + (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 (sasToken.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("AZURE_BLOB")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AzureBlobStorage && + return other is AzureBlob && + id == other.id && accountName == other.accountName && container == other.container && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - sasToken == other.sasToken && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3646,85 +3407,67 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlobStorage{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 clientId: JsonField, - private val clientSecret: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val password: JsonField, private val type: JsonValue, - private val username: JsonField, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("clientId") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - clientSecret: JsonField = JsonMissing.of(), + includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, mutableMapOf(), ) /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun id(): String = id.getRequired("id") /** - * Akeneo API client 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 clientId(): String = clientId.getRequired("clientId") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo API client secret. + * 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 clientSecret(): String = clientSecret.getRequired("clientSecret") + fun includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") /** * Display name of the origin. @@ -3734,14 +3477,6 @@ private constructor( */ 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 @@ -3753,20 +3488,6 @@ private constructor( */ @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") - - /** - * @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") - /** * URL used in the Canonical header (if enabled). * @@ -3777,13 +3498,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrl]. @@ -3793,21 +3512,14 @@ private constructor( @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]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _clientSecret(): JsonField = clientSecret + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [name]. @@ -3816,27 +3528,6 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3847,16 +3538,6 @@ private constructor( @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) @@ -3876,12 +3557,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3890,69 +3569,65 @@ private constructor( /** A builder for [AkeneoPim]. */ class Builder internal constructor() { + private var id: JsonField? = null private var baseUrl: JsonField? = null - private var clientId: JsonField? = null - private var clientSecret: JsonField? = null + private var includeCanonicalHeader: 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { + id = akeneoPim.id baseUrl = akeneoPim.baseUrl - clientId = akeneoPim.clientId - clientSecret = akeneoPim.clientSecret + includeCanonicalHeader = akeneoPim.includeCanonicalHeader name = akeneoPim.name - password = akeneoPim.password type = akeneoPim.type - username = akeneoPim.username - id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader - includeCanonicalHeader = akeneoPim.includeCanonicalHeader additionalProperties = akeneoPim.additionalProperties.toMutableMap() } - /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + /** + * 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.baseUrl] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + fun id(id: JsonField) = apply { this.id = id } - /** Akeneo API client ID. */ - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + /** Akeneo instance base URL. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) /** - * Sets [Builder.clientId] to an arbitrary JSON value. + * Sets [Builder.baseUrl] to an arbitrary JSON value. * - * You should usually call [Builder.clientId] with a well-typed [String] value instead. + * 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 clientId(clientId: JsonField) = apply { this.clientId = clientId } + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Akeneo API client secret. */ - fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) /** - * Sets [Builder.clientSecret] to an arbitrary JSON value. + * Sets [Builder.includeCanonicalHeader] 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. + * 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 clientSecret(clientSecret: JsonField) = apply { - this.clientSecret = clientSecret + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader } /** Display name of the origin. */ @@ -3967,18 +3642,6 @@ private constructor( */ 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. * @@ -3993,29 +3656,6 @@ private constructor( */ 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 } - - 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -4031,21 +3671,6 @@ private constructor( 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) @@ -4072,28 +3697,22 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("clientId", clientId), - checkRequired("clientSecret", clientSecret), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("password", password), type, - checkRequired("username", username), - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -4105,20 +3724,16 @@ private constructor( return@apply } + id() baseUrl() - clientId() - clientSecret() + includeCanonicalHeader() name() - password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - username() - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -4138,16 +3753,12 @@ private constructor( */ @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 (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) + - (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -4155,31 +3766,23 @@ private constructor( } return other is AkeneoPim && + id == other.id && baseUrl == other.baseUrl && - clientId == other.clientId && - clientSecret == other.clientSecret && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - password == other.password && type == other.type && - username == other.username && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -4187,6 +3790,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "AkeneoPim{id=$id, baseUrl=$baseUrl, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt index e05bced9..be5a3722 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt @@ -18,14 +18,12 @@ internal class OriginCreateResponseTest { fun ofS3() { val s3 = OriginCreateResponse.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originCreateResponse = OriginCreateResponse.ofS3(s3) @@ -35,8 +33,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -46,14 +44,12 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofS3( OriginCreateResponse.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -70,16 +66,14 @@ internal class OriginCreateResponseTest { fun ofS3Compatible() { val s3Compatible = OriginCreateResponse.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") + .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originCreateResponse = OriginCreateResponse.ofS3Compatible(s3Compatible) @@ -89,8 +83,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -100,16 +94,14 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofS3Compatible( OriginCreateResponse.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") + .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -126,14 +118,12 @@ internal class OriginCreateResponseTest { fun ofCloudinaryBackup() { val cloudinaryBackup = OriginCreateResponse.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originCreateResponse = OriginCreateResponse.ofCloudinaryBackup(cloudinaryBackup) @@ -143,8 +133,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -154,14 +144,12 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofCloudinaryBackup( OriginCreateResponse.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -178,12 +166,12 @@ internal class OriginCreateResponseTest { fun ofWebFolder() { val webFolder = OriginCreateResponse.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originCreateResponse = OriginCreateResponse.ofWebFolder(webFolder) @@ -193,8 +181,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).contains(webFolder) assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -204,12 +192,12 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofWebFolder( OriginCreateResponse.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -226,10 +214,10 @@ internal class OriginCreateResponseTest { fun ofWebProxy() { val webProxy = OriginCreateResponse.WebProxy.builder() - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originCreateResponse = OriginCreateResponse.ofWebProxy(webProxy) @@ -239,8 +227,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).contains(webProxy) - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @@ -250,10 +238,10 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofWebProxy( OriginCreateResponse.WebProxy.builder() - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -267,46 +255,43 @@ internal class OriginCreateResponseTest { } @Test - fun ofGoogleCloudStorageGcs() { - val googleCloudStorageGcs = - OriginCreateResponse.GoogleCloudStorageGcs.builder() + fun ofGcs() { + val gcs = + OriginCreateResponse.Gcs.builder() + .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originCreateResponse = - OriginCreateResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + val originCreateResponse = OriginCreateResponse.ofGcs(gcs) assertThat(originCreateResponse.s3()).isEmpty assertThat(originCreateResponse.s3Compatible()).isEmpty assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).contains(gcs) + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).isEmpty } @Test - fun ofGoogleCloudStorageGcsRoundtrip() { + fun ofGcsRoundtrip() { val jsonMapper = jsonMapper() val originCreateResponse = - OriginCreateResponse.ofGoogleCloudStorageGcs( - OriginCreateResponse.GoogleCloudStorageGcs.builder() + OriginCreateResponse.ofGcs( + OriginCreateResponse.Gcs.builder() + .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -320,45 +305,43 @@ internal class OriginCreateResponseTest { } @Test - fun ofAzureBlobStorage() { - val azureBlobStorage = - OriginCreateResponse.AzureBlobStorage.builder() + fun ofAzureBlob() { + val azureBlob = + OriginCreateResponse.AzureBlob.builder() + .id("id") .accountName("account123") .container("images") - .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originCreateResponse = OriginCreateResponse.ofAzureBlobStorage(azureBlobStorage) + val originCreateResponse = OriginCreateResponse.ofAzureBlob(azureBlob) assertThat(originCreateResponse.s3()).isEmpty assertThat(originCreateResponse.s3Compatible()).isEmpty assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).contains(azureBlob) assertThat(originCreateResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobStorageRoundtrip() { + fun ofAzureBlobRoundtrip() { val jsonMapper = jsonMapper() val originCreateResponse = - OriginCreateResponse.ofAzureBlobStorage( - OriginCreateResponse.AzureBlobStorage.builder() + OriginCreateResponse.ofAzureBlob( + OriginCreateResponse.AzureBlob.builder() + .id("id") .accountName("account123") .container("images") - .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -375,15 +358,11 @@ internal class OriginCreateResponseTest { fun ofAkeneoPim() { val akeneoPim = OriginCreateResponse.AkeneoPim.builder() + .id("id") .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") + .includeCanonicalHeader(false) .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") - .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) .build() val originCreateResponse = OriginCreateResponse.ofAkeneoPim(akeneoPim) @@ -393,8 +372,8 @@ internal class OriginCreateResponseTest { assertThat(originCreateResponse.cloudinaryBackup()).isEmpty assertThat(originCreateResponse.webFolder()).isEmpty assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originCreateResponse.azureBlobStorage()).isEmpty + assertThat(originCreateResponse.gcs()).isEmpty + assertThat(originCreateResponse.azureBlob()).isEmpty assertThat(originCreateResponse.akeneoPim()).contains(akeneoPim) } @@ -404,15 +383,11 @@ internal class OriginCreateResponseTest { val originCreateResponse = OriginCreateResponse.ofAkeneoPim( OriginCreateResponse.AkeneoPim.builder() + .id("id") .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") + .includeCanonicalHeader(false) .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") - .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt index 54e7e5cd..81a0e62f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt @@ -18,14 +18,12 @@ internal class OriginGetResponseTest { fun ofS3() { val s3 = OriginGetResponse.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originGetResponse = OriginGetResponse.ofS3(s3) @@ -35,8 +33,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -46,14 +44,12 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofS3( OriginGetResponse.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -70,16 +66,14 @@ internal class OriginGetResponseTest { fun ofS3Compatible() { val s3Compatible = OriginGetResponse.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") + .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originGetResponse = OriginGetResponse.ofS3Compatible(s3Compatible) @@ -89,8 +83,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -100,16 +94,14 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofS3Compatible( OriginGetResponse.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") + .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -126,14 +118,12 @@ internal class OriginGetResponseTest { fun ofCloudinaryBackup() { val cloudinaryBackup = OriginGetResponse.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originGetResponse = OriginGetResponse.ofCloudinaryBackup(cloudinaryBackup) @@ -143,8 +133,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -154,14 +144,12 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofCloudinaryBackup( OriginGetResponse.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -178,12 +166,12 @@ internal class OriginGetResponseTest { fun ofWebFolder() { val webFolder = OriginGetResponse.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originGetResponse = OriginGetResponse.ofWebFolder(webFolder) @@ -193,8 +181,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).contains(webFolder) assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -204,12 +192,12 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofWebFolder( OriginGetResponse.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -226,10 +214,10 @@ internal class OriginGetResponseTest { fun ofWebProxy() { val webProxy = OriginGetResponse.WebProxy.builder() - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originGetResponse = OriginGetResponse.ofWebProxy(webProxy) @@ -239,8 +227,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).contains(webProxy) - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @@ -250,10 +238,10 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofWebProxy( OriginGetResponse.WebProxy.builder() - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -267,45 +255,43 @@ internal class OriginGetResponseTest { } @Test - fun ofGoogleCloudStorageGcs() { - val googleCloudStorageGcs = - OriginGetResponse.GoogleCloudStorageGcs.builder() + fun ofGcs() { + val gcs = + OriginGetResponse.Gcs.builder() + .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + val originGetResponse = OriginGetResponse.ofGcs(gcs) assertThat(originGetResponse.s3()).isEmpty assertThat(originGetResponse.s3Compatible()).isEmpty assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).contains(gcs) + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).isEmpty } @Test - fun ofGoogleCloudStorageGcsRoundtrip() { + fun ofGcsRoundtrip() { val jsonMapper = jsonMapper() val originGetResponse = - OriginGetResponse.ofGoogleCloudStorageGcs( - OriginGetResponse.GoogleCloudStorageGcs.builder() + OriginGetResponse.ofGcs( + OriginGetResponse.Gcs.builder() + .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -319,45 +305,43 @@ internal class OriginGetResponseTest { } @Test - fun ofAzureBlobStorage() { - val azureBlobStorage = - OriginGetResponse.AzureBlobStorage.builder() + fun ofAzureBlob() { + val azureBlob = + OriginGetResponse.AzureBlob.builder() + .id("id") .accountName("account123") .container("images") - .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofAzureBlobStorage(azureBlobStorage) + val originGetResponse = OriginGetResponse.ofAzureBlob(azureBlob) assertThat(originGetResponse.s3()).isEmpty assertThat(originGetResponse.s3Compatible()).isEmpty assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).contains(azureBlob) assertThat(originGetResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobStorageRoundtrip() { + fun ofAzureBlobRoundtrip() { val jsonMapper = jsonMapper() val originGetResponse = - OriginGetResponse.ofAzureBlobStorage( - OriginGetResponse.AzureBlobStorage.builder() + OriginGetResponse.ofAzureBlob( + OriginGetResponse.AzureBlob.builder() + .id("id") .accountName("account123") .container("images") - .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -374,15 +358,11 @@ internal class OriginGetResponseTest { fun ofAkeneoPim() { val akeneoPim = OriginGetResponse.AkeneoPim.builder() + .id("id") .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") + .includeCanonicalHeader(false) .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") - .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) .build() val originGetResponse = OriginGetResponse.ofAkeneoPim(akeneoPim) @@ -392,8 +372,8 @@ internal class OriginGetResponseTest { assertThat(originGetResponse.cloudinaryBackup()).isEmpty assertThat(originGetResponse.webFolder()).isEmpty assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.googleCloudStorageGcs()).isEmpty - assertThat(originGetResponse.azureBlobStorage()).isEmpty + assertThat(originGetResponse.gcs()).isEmpty + assertThat(originGetResponse.azureBlob()).isEmpty assertThat(originGetResponse.akeneoPim()).contains(akeneoPim) } @@ -403,15 +383,11 @@ internal class OriginGetResponseTest { val originGetResponse = OriginGetResponse.ofAkeneoPim( OriginGetResponse.AkeneoPim.builder() + .id("id") .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") + .includeCanonicalHeader(false) .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") - .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt index 89a663bf..5a5b4506 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt @@ -18,14 +18,12 @@ internal class OriginListResponseTest { fun ofS3() { val s3 = OriginListResponse.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originListResponse = OriginListResponse.ofS3(s3) @@ -35,8 +33,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -46,14 +44,12 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofS3( OriginListResponse.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -70,16 +66,14 @@ internal class OriginListResponseTest { fun ofS3Compatible() { val s3Compatible = OriginListResponse.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") + .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originListResponse = OriginListResponse.ofS3Compatible(s3Compatible) @@ -89,8 +83,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -100,16 +94,14 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofS3Compatible( OriginListResponse.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") + .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -126,14 +118,12 @@ internal class OriginListResponseTest { fun ofCloudinaryBackup() { val cloudinaryBackup = OriginListResponse.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originListResponse = OriginListResponse.ofCloudinaryBackup(cloudinaryBackup) @@ -143,8 +133,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -154,14 +144,12 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofCloudinaryBackup( OriginListResponse.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -178,12 +166,12 @@ internal class OriginListResponseTest { fun ofWebFolder() { val webFolder = OriginListResponse.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originListResponse = OriginListResponse.ofWebFolder(webFolder) @@ -193,8 +181,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).contains(webFolder) assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -204,12 +192,12 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofWebFolder( OriginListResponse.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -226,10 +214,10 @@ internal class OriginListResponseTest { fun ofWebProxy() { val webProxy = OriginListResponse.WebProxy.builder() - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originListResponse = OriginListResponse.ofWebProxy(webProxy) @@ -239,8 +227,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).contains(webProxy) - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @@ -250,10 +238,10 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofWebProxy( OriginListResponse.WebProxy.builder() - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -267,45 +255,43 @@ internal class OriginListResponseTest { } @Test - fun ofGoogleCloudStorageGcs() { - val googleCloudStorageGcs = - OriginListResponse.GoogleCloudStorageGcs.builder() + fun ofGcs() { + val gcs = + OriginListResponse.Gcs.builder() + .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originListResponse = OriginListResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + val originListResponse = OriginListResponse.ofGcs(gcs) assertThat(originListResponse.s3()).isEmpty assertThat(originListResponse.s3Compatible()).isEmpty assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).contains(gcs) + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).isEmpty } @Test - fun ofGoogleCloudStorageGcsRoundtrip() { + fun ofGcsRoundtrip() { val jsonMapper = jsonMapper() val originListResponse = - OriginListResponse.ofGoogleCloudStorageGcs( - OriginListResponse.GoogleCloudStorageGcs.builder() + OriginListResponse.ofGcs( + OriginListResponse.Gcs.builder() + .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -319,45 +305,43 @@ internal class OriginListResponseTest { } @Test - fun ofAzureBlobStorage() { - val azureBlobStorage = - OriginListResponse.AzureBlobStorage.builder() + fun ofAzureBlob() { + val azureBlob = + OriginListResponse.AzureBlob.builder() + .id("id") .accountName("account123") .container("images") - .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originListResponse = OriginListResponse.ofAzureBlobStorage(azureBlobStorage) + val originListResponse = OriginListResponse.ofAzureBlob(azureBlob) assertThat(originListResponse.s3()).isEmpty assertThat(originListResponse.s3Compatible()).isEmpty assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).contains(azureBlob) assertThat(originListResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobStorageRoundtrip() { + fun ofAzureBlobRoundtrip() { val jsonMapper = jsonMapper() val originListResponse = - OriginListResponse.ofAzureBlobStorage( - OriginListResponse.AzureBlobStorage.builder() + OriginListResponse.ofAzureBlob( + OriginListResponse.AzureBlob.builder() + .id("id") .accountName("account123") .container("images") - .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -374,15 +358,11 @@ internal class OriginListResponseTest { fun ofAkeneoPim() { val akeneoPim = OriginListResponse.AkeneoPim.builder() + .id("id") .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") + .includeCanonicalHeader(false) .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") - .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) .build() val originListResponse = OriginListResponse.ofAkeneoPim(akeneoPim) @@ -392,8 +372,8 @@ internal class OriginListResponseTest { assertThat(originListResponse.cloudinaryBackup()).isEmpty assertThat(originListResponse.webFolder()).isEmpty assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.googleCloudStorageGcs()).isEmpty - assertThat(originListResponse.azureBlobStorage()).isEmpty + assertThat(originListResponse.gcs()).isEmpty + assertThat(originListResponse.azureBlob()).isEmpty assertThat(originListResponse.akeneoPim()).contains(akeneoPim) } @@ -403,15 +383,11 @@ internal class OriginListResponseTest { val originListResponse = OriginListResponse.ofAkeneoPim( OriginListResponse.AkeneoPim.builder() + .id("id") .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") + .includeCanonicalHeader(false) .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") - .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt index e2ad014f..c569a06f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt @@ -18,14 +18,12 @@ internal class OriginUpdateResponseTest { fun ofS3() { val s3 = OriginUpdateResponse.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originUpdateResponse = OriginUpdateResponse.ofS3(s3) @@ -35,8 +33,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -46,14 +44,12 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofS3( OriginUpdateResponse.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -70,16 +66,14 @@ internal class OriginUpdateResponseTest { fun ofS3Compatible() { val s3Compatible = OriginUpdateResponse.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") + .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originUpdateResponse = OriginUpdateResponse.ofS3Compatible(s3Compatible) @@ -89,8 +83,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -100,16 +94,14 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofS3Compatible( OriginUpdateResponse.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") + .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -126,14 +118,12 @@ internal class OriginUpdateResponseTest { fun ofCloudinaryBackup() { val cloudinaryBackup = OriginUpdateResponse.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originUpdateResponse = OriginUpdateResponse.ofCloudinaryBackup(cloudinaryBackup) @@ -143,8 +133,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).contains(cloudinaryBackup) assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -154,14 +144,12 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofCloudinaryBackup( OriginUpdateResponse.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") - .bucket("product-images") - .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .bucket("product-images") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -178,12 +166,12 @@ internal class OriginUpdateResponseTest { fun ofWebFolder() { val webFolder = OriginUpdateResponse.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originUpdateResponse = OriginUpdateResponse.ofWebFolder(webFolder) @@ -193,8 +181,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).contains(webFolder) assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -204,12 +192,12 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofWebFolder( OriginUpdateResponse.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") + .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -226,10 +214,10 @@ internal class OriginUpdateResponseTest { fun ofWebProxy() { val webProxy = OriginUpdateResponse.WebProxy.builder() - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() val originUpdateResponse = OriginUpdateResponse.ofWebProxy(webProxy) @@ -239,8 +227,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).contains(webProxy) - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @@ -250,10 +238,10 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofWebProxy( OriginUpdateResponse.WebProxy.builder() - .name("US S3 Storage") .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -267,46 +255,43 @@ internal class OriginUpdateResponseTest { } @Test - fun ofGoogleCloudStorageGcs() { - val googleCloudStorageGcs = - OriginUpdateResponse.GoogleCloudStorageGcs.builder() + fun ofGcs() { + val gcs = + OriginUpdateResponse.Gcs.builder() + .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originUpdateResponse = - OriginUpdateResponse.ofGoogleCloudStorageGcs(googleCloudStorageGcs) + val originUpdateResponse = OriginUpdateResponse.ofGcs(gcs) assertThat(originUpdateResponse.s3()).isEmpty assertThat(originUpdateResponse.s3Compatible()).isEmpty assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).contains(googleCloudStorageGcs) - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).contains(gcs) + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).isEmpty } @Test - fun ofGoogleCloudStorageGcsRoundtrip() { + fun ofGcsRoundtrip() { val jsonMapper = jsonMapper() val originUpdateResponse = - OriginUpdateResponse.ofGoogleCloudStorageGcs( - OriginUpdateResponse.GoogleCloudStorageGcs.builder() + OriginUpdateResponse.ofGcs( + OriginUpdateResponse.Gcs.builder() + .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -320,45 +305,43 @@ internal class OriginUpdateResponseTest { } @Test - fun ofAzureBlobStorage() { - val azureBlobStorage = - OriginUpdateResponse.AzureBlobStorage.builder() + fun ofAzureBlob() { + val azureBlob = + OriginUpdateResponse.AzureBlob.builder() + .id("id") .accountName("account123") .container("images") - .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originUpdateResponse = OriginUpdateResponse.ofAzureBlobStorage(azureBlobStorage) + val originUpdateResponse = OriginUpdateResponse.ofAzureBlob(azureBlob) assertThat(originUpdateResponse.s3()).isEmpty assertThat(originUpdateResponse.s3Compatible()).isEmpty assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).contains(azureBlobStorage) + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).contains(azureBlob) assertThat(originUpdateResponse.akeneoPim()).isEmpty } @Test - fun ofAzureBlobStorageRoundtrip() { + fun ofAzureBlobRoundtrip() { val jsonMapper = jsonMapper() val originUpdateResponse = - OriginUpdateResponse.ofAzureBlobStorage( - OriginUpdateResponse.AzureBlobStorage.builder() + OriginUpdateResponse.ofAzureBlob( + OriginUpdateResponse.AzureBlob.builder() + .id("id") .accountName("account123") .container("images") - .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) + .name("US S3 Storage") .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") .build() ) @@ -375,15 +358,11 @@ internal class OriginUpdateResponseTest { fun ofAkeneoPim() { val akeneoPim = OriginUpdateResponse.AkeneoPim.builder() + .id("id") .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") + .includeCanonicalHeader(false) .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") - .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) .build() val originUpdateResponse = OriginUpdateResponse.ofAkeneoPim(akeneoPim) @@ -393,8 +372,8 @@ internal class OriginUpdateResponseTest { assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty assertThat(originUpdateResponse.webFolder()).isEmpty assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.googleCloudStorageGcs()).isEmpty - assertThat(originUpdateResponse.azureBlobStorage()).isEmpty + assertThat(originUpdateResponse.gcs()).isEmpty + assertThat(originUpdateResponse.azureBlob()).isEmpty assertThat(originUpdateResponse.akeneoPim()).contains(akeneoPim) } @@ -404,15 +383,11 @@ internal class OriginUpdateResponseTest { val originUpdateResponse = OriginUpdateResponse.ofAkeneoPim( OriginUpdateResponse.AkeneoPim.builder() + .id("id") .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") + .includeCanonicalHeader(false) .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") - .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) .build() ) From 0285c6e60e86d0c1d2af00bf5be6a984fbf6bed3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 05:50:55 +0000 Subject: [PATCH 048/125] feat(api): manual updates --- .stats.yml | 2 +- .../accounts/urlendpoints/UrlEndpoint.kt | 751 ++++++++++++++ .../urlendpoints/UrlEndpointCreateParams.kt | 943 +----------------- .../urlendpoints/UrlEndpointUpdateParams.kt | 941 +---------------- .../UrlEndpointCreateParamsTest.kt | 63 +- .../accounts/urlendpoints/UrlEndpointTest.kt | 63 ++ .../UrlEndpointUpdateParamsTest.kt | 68 +- .../accounts/UrlEndpointServiceAsyncTest.kt | 33 +- .../accounts/UrlEndpointServiceTest.kt | 33 +- 9 files changed, 969 insertions(+), 1928 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpoint.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointTest.kt diff --git a/.stats.yml b/.stats.yml index 5afb8fd9..49325e6c 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-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml openapi_spec_hash: 98642308bee81ac776b7b1843089b888 -config_hash: ddd6954a6e35eb1a97e5d0cda8209e62 +config_hash: 49e367d7f33aeaf63ed738c1c0392d0a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpoint.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpoint.kt new file mode 100644 index 00000000..b1c839cf --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpoint.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 UrlEndpoint +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 [UrlEndpoint]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpoint]. */ + 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(urlEndpoint: UrlEndpoint) = apply { + description = urlEndpoint.description + origins = urlEndpoint.origins.map { it.toMutableList() } + urlPrefix = urlEndpoint.urlPrefix + urlRewriter = urlEndpoint.urlRewriter + additionalProperties = urlEndpoint.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 [UrlEndpoint]. + * + * 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(): UrlEndpoint = + UrlEndpoint( + checkRequired("description", description), + (origins ?: JsonMissing.of()).map { it.toImmutable() }, + urlPrefix, + urlRewriter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UrlEndpoint = 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 UrlEndpoint && + 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() = + "UrlEndpoint{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/UrlEndpointCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt index 790da3d6..c7c87a41 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt @@ -2,35 +2,12 @@ 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.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.util.Collections import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns the resulting @@ -38,75 +15,15 @@ import kotlin.jvm.optionals.getOrNull */ class UrlEndpointCreateParams private constructor( - private val body: Body, + private val urlEndpoint: UrlEndpoint, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - /** - * 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 = body.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> = body.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 = body.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 = body.urlRewriter() - - /** - * 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 [origins]. - * - * Unlike [origins], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _origins(): JsonField> = body._origins() - - /** - * Returns the raw JSON value of [urlPrefix]. - * - * Unlike [urlPrefix], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _urlPrefix(): JsonField = body._urlPrefix() - - /** - * Returns the raw JSON value of [urlRewriter]. - * - * Unlike [urlRewriter], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _urlRewriter(): JsonField = body._urlRewriter() + /** Schema for URL endpoint resource. */ + fun urlEndpoint(): UrlEndpoint = urlEndpoint - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = urlEndpoint._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -123,7 +40,7 @@ private constructor( * * The following fields are required: * ```java - * .description() + * .urlEndpoint() * ``` */ @JvmStatic fun builder() = Builder() @@ -132,120 +49,19 @@ private constructor( /** A builder for [UrlEndpointCreateParams]. */ class Builder internal constructor() { - private var body: Body.Builder = Body.builder() + private var urlEndpoint: UrlEndpoint? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(urlEndpointCreateParams: UrlEndpointCreateParams) = apply { - body = urlEndpointCreateParams.body.toBuilder() + urlEndpoint = urlEndpointCreateParams.urlEndpoint additionalHeaders = urlEndpointCreateParams.additionalHeaders.toBuilder() additionalQueryParams = urlEndpointCreateParams.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: - * - [description] - * - [origins] - * - [urlPrefix] - * - [urlRewriter] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Description of the URL endpoint. */ - 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) } - - /** - * 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) = apply { body.origins(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 { body.origins(origins) } - - /** - * Adds a single [String] to [origins]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addOrigin(origin: String) = apply { body.addOrigin(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) = apply { body.urlPrefix(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 { body.urlPrefix(urlPrefix) } - - /** Configuration for third-party URL rewriting. */ - fun urlRewriter(urlRewriter: UrlRewriter) = apply { body.urlRewriter(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 { - body.urlRewriter(urlRewriter) - } - - /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.Cloudinary) = apply { body.urlRewriter(cloudinary) } - - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ - fun urlRewriterImgix() = apply { body.urlRewriterImgix() } - - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ - fun urlRewriterAkamai() = apply { body.urlRewriterAkamai() } - - 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) - } + /** Schema for URL endpoint resource. */ + fun urlEndpoint(urlEndpoint: UrlEndpoint) = apply { this.urlEndpoint = urlEndpoint } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -352,766 +168,39 @@ private constructor( * * The following fields are required: * ```java - * .description() + * .urlEndpoint() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): UrlEndpointCreateParams = UrlEndpointCreateParams( - body.build(), + checkRequired("urlEndpoint", urlEndpoint), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): Body = body + fun _body(): UrlEndpoint = urlEndpoint override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** Schema for URL endpoint resource. */ - class Body - 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 [Body]. - * - * The following fields are required: - * ```java - * .description() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - 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(body: Body) = apply { - description = body.description - origins = body.origins.map { it.toMutableList() } - urlPrefix = body.urlPrefix - urlRewriter = body.urlRewriter - additionalProperties = body.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 [Body]. - * - * 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(): Body = - Body( - checkRequired("description", description), - (origins ?: JsonMissing.of()).map { it.toImmutable() }, - urlPrefix, - urlRewriter, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = 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) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - 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() = - "Body{description=$description, origins=$origins, urlPrefix=$urlPrefix, urlRewriter=$urlRewriter, additionalProperties=$additionalProperties}" - } - - /** 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 UrlEndpointCreateParams && - body == other.body && + urlEndpoint == other.urlEndpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(urlEndpoint, additionalHeaders, additionalQueryParams) override fun toString() = - "UrlEndpointCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "UrlEndpointCreateParams{urlEndpoint=$urlEndpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 index 980d8500..caf4749a 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt @@ -2,32 +2,11 @@ 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.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.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -39,7 +18,7 @@ import kotlin.jvm.optionals.getOrNull class UrlEndpointUpdateParams private constructor( private val id: String?, - private val body: Body, + private val urlEndpoint: UrlEndpoint, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -50,70 +29,10 @@ private constructor( */ fun id(): Optional = Optional.ofNullable(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 = body.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> = body.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 = body.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 = body.urlRewriter() - - /** - * 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 [origins]. - * - * Unlike [origins], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _origins(): JsonField> = body._origins() - - /** - * Returns the raw JSON value of [urlPrefix]. - * - * Unlike [urlPrefix], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _urlPrefix(): JsonField = body._urlPrefix() - - /** - * Returns the raw JSON value of [urlRewriter]. - * - * Unlike [urlRewriter], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _urlRewriter(): JsonField = body._urlRewriter() + /** Schema for URL endpoint resource. */ + fun urlEndpoint(): UrlEndpoint = urlEndpoint - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = urlEndpoint._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -130,7 +49,7 @@ private constructor( * * The following fields are required: * ```java - * .description() + * .urlEndpoint() * ``` */ @JvmStatic fun builder() = Builder() @@ -140,14 +59,14 @@ private constructor( class Builder internal constructor() { private var id: String? = null - private var body: Body.Builder = Body.builder() + private var urlEndpoint: UrlEndpoint? = 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 - body = urlEndpointUpdateParams.body.toBuilder() + urlEndpoint = urlEndpointUpdateParams.urlEndpoint additionalHeaders = urlEndpointUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = urlEndpointUpdateParams.additionalQueryParams.toBuilder() } @@ -161,109 +80,8 @@ private constructor( /** 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: - * - [description] - * - [origins] - * - [urlPrefix] - * - [urlRewriter] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Description of the URL endpoint. */ - 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) } - - /** - * 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) = apply { body.origins(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 { body.origins(origins) } - - /** - * Adds a single [String] to [origins]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addOrigin(origin: String) = apply { body.addOrigin(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) = apply { body.urlPrefix(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 { body.urlPrefix(urlPrefix) } - - /** Configuration for third-party URL rewriting. */ - fun urlRewriter(urlRewriter: UrlRewriter) = apply { body.urlRewriter(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 { - body.urlRewriter(urlRewriter) - } - - /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ - fun urlRewriter(cloudinary: UrlRewriter.Cloudinary) = apply { body.urlRewriter(cloudinary) } - - /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ - fun urlRewriterImgix() = apply { body.urlRewriterImgix() } - - /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ - fun urlRewriterAkamai() = apply { body.urlRewriterAkamai() } - - 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) - } + /** Schema for URL endpoint resource. */ + fun urlEndpoint(urlEndpoint: UrlEndpoint) = apply { this.urlEndpoint = urlEndpoint } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -370,7 +188,7 @@ private constructor( * * The following fields are required: * ```java - * .description() + * .urlEndpoint() * ``` * * @throws IllegalStateException if any required field is unset. @@ -378,13 +196,13 @@ private constructor( fun build(): UrlEndpointUpdateParams = UrlEndpointUpdateParams( id, - body.build(), + checkRequired("urlEndpoint", urlEndpoint), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): Body = body + fun _body(): UrlEndpoint = urlEndpoint fun _pathParam(index: Int): String = when (index) { @@ -396,734 +214,6 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - /** Schema for URL endpoint resource. */ - class Body - 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 [Body]. - * - * The following fields are required: - * ```java - * .description() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - 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(body: Body) = apply { - description = body.description - origins = body.origins.map { it.toMutableList() } - urlPrefix = body.urlPrefix - urlRewriter = body.urlRewriter - additionalProperties = body.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 [Body]. - * - * 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(): Body = - Body( - checkRequired("description", description), - (origins ?: JsonMissing.of()).map { it.toImmutable() }, - urlPrefix, - urlRewriter, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = 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) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - 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() = - "Body{description=$description, origins=$origins, urlPrefix=$urlPrefix, urlRewriter=$urlRewriter, additionalProperties=$additionalProperties}" - } - - /** 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 @@ -1131,13 +221,14 @@ private constructor( return other is UrlEndpointUpdateParams && id == other.id && - body == other.body && + urlEndpoint == other.urlEndpoint && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(id, urlEndpoint, additionalHeaders, additionalQueryParams) override fun toString() = - "UrlEndpointUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "UrlEndpointUpdateParams{id=$id, urlEndpoint=$urlEndpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 index 87809f44..fefb3a58 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.models.accounts.urlendpoints -import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,12 +10,16 @@ internal class UrlEndpointCreateParamsTest { @Test fun create() { UrlEndpointCreateParams.builder() - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) + .urlEndpoint( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) .build() ) .build() @@ -26,37 +29,47 @@ internal class UrlEndpointCreateParamsTest { fun body() { val params = UrlEndpointCreateParams.builder() - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) + .urlEndpoint( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) .build() ) .build() val body = params._body() - assertThat(body.description()).isEqualTo("My custom URL endpoint") - assertThat(body.origins().getOrNull()).containsExactly("origin-id-1") - assertThat(body.urlPrefix()).contains("product-images") - assertThat(body.urlRewriter()) - .contains( - UrlEndpointCreateParams.UrlRewriter.ofCloudinary( - UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + assertThat(body) + .isEqualTo( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() ) } @Test fun bodyWithoutOptionalFields() { - val params = UrlEndpointCreateParams.builder().description("My custom URL endpoint").build() + val params = + UrlEndpointCreateParams.builder() + .urlEndpoint(UrlEndpoint.builder().description("My custom URL endpoint").build()) + .build() val body = params._body() - assertThat(body.description()).isEqualTo("My custom URL endpoint") + assertThat(body) + .isEqualTo(UrlEndpoint.builder().description("My custom URL endpoint").build()) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointTest.kt new file mode 100644 index 00000000..b20b173e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointTest.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 UrlEndpointTest { + + @Test + fun create() { + val urlEndpoint = + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + + assertThat(urlEndpoint.description()).isEqualTo("My custom URL endpoint") + assertThat(urlEndpoint.origins().getOrNull()).containsExactly("origin-id-1") + assertThat(urlEndpoint.urlPrefix()).contains("product-images") + assertThat(urlEndpoint.urlRewriter()) + .contains( + UrlEndpoint.UrlRewriter.ofCloudinary( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val urlEndpoint = + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + + val roundtrippedUrlEndpoint = + jsonMapper.readValue( + jsonMapper.writeValueAsString(urlEndpoint), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUrlEndpoint).isEqualTo(urlEndpoint) + } +} 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 index bdd96b6c..a7ebb60a 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.models.accounts.urlendpoints -import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -12,12 +11,16 @@ internal class UrlEndpointUpdateParamsTest { fun create() { UrlEndpointUpdateParams.builder() .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) + .urlEndpoint( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) .build() ) .build() @@ -26,7 +29,10 @@ internal class UrlEndpointUpdateParamsTest { @Test fun pathParams() { val params = - UrlEndpointUpdateParams.builder().id("id").description("My custom URL endpoint").build() + UrlEndpointUpdateParams.builder() + .id("id") + .urlEndpoint(UrlEndpoint.builder().description("My custom URL endpoint").build()) + .build() assertThat(params._pathParam(0)).isEqualTo("id") // out-of-bound path param @@ -38,38 +44,48 @@ internal class UrlEndpointUpdateParamsTest { val params = UrlEndpointUpdateParams.builder() .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) + .urlEndpoint( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) .build() ) .build() val body = params._body() - assertThat(body.description()).isEqualTo("My custom URL endpoint") - assertThat(body.origins().getOrNull()).containsExactly("origin-id-1") - assertThat(body.urlPrefix()).contains("product-images") - assertThat(body.urlRewriter()) - .contains( - UrlEndpointUpdateParams.UrlRewriter.ofCloudinary( - UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + assertThat(body) + .isEqualTo( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() ) } @Test fun bodyWithoutOptionalFields() { val params = - UrlEndpointUpdateParams.builder().id("id").description("My custom URL endpoint").build() + UrlEndpointUpdateParams.builder() + .id("id") + .urlEndpoint(UrlEndpoint.builder().description("My custom URL endpoint").build()) + .build() val body = params._body() - assertThat(body.description()).isEqualTo("My custom URL endpoint") + assertThat(body) + .isEqualTo(UrlEndpoint.builder().description("My custom URL endpoint").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 607f0f1b..cf838cbf 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,6 +4,7 @@ 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.UrlEndpoint import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled @@ -27,12 +28,16 @@ internal class UrlEndpointServiceAsyncTest { val urlEndpointFuture = urlEndpointServiceAsync.create( UrlEndpointCreateParams.builder() - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) + .urlEndpoint( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) .build() ) .build() @@ -57,12 +62,16 @@ internal class UrlEndpointServiceAsyncTest { urlEndpointServiceAsync.update( UrlEndpointUpdateParams.builder() .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) + .urlEndpoint( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) .build() ) .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 d2070ee2..6341f99e 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,6 +4,7 @@ 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.UrlEndpoint import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled @@ -27,12 +28,16 @@ internal class UrlEndpointServiceTest { val urlEndpoint = urlEndpointService.create( UrlEndpointCreateParams.builder() - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointCreateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) + .urlEndpoint( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) .build() ) .build() @@ -56,12 +61,16 @@ internal class UrlEndpointServiceTest { urlEndpointService.update( UrlEndpointUpdateParams.builder() .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointUpdateParams.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) + .urlEndpoint( + UrlEndpoint.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpoint.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) .build() ) .build() From 6b0f25648f3c9b167d808bc64e7e71ecb0410734 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 05:57:36 +0000 Subject: [PATCH 049/125] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 49325e6c..6690c82e 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-967cd0e731df83a642ded194cacae3628050f679c600b1efd4e66cf269973531.yml -openapi_spec_hash: 98642308bee81ac776b7b1843089b888 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-67e78a2f87dab7c661093c82f338197540584fa3d9a38773d1fdd435d788282f.yml +openapi_spec_hash: 28ec969480eb18203d798e0435e76df3 config_hash: 49e367d7f33aeaf63ed738c1c0392d0a From 4baac1ebf9c21fdc7a6c086cab79a5ecfeb63178 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 05:59:34 +0000 Subject: [PATCH 050/125] feat(api): manual updates --- .stats.yml | 2 +- .../accounts/origins/OriginCreateResponse.kt | 3795 ----------------- .../accounts/origins/OriginListResponse.kt | 3791 ---------------- ...OriginGetResponse.kt => OriginResponse.kt} | 100 +- .../accounts/origins/OriginUpdateResponse.kt | 3795 ----------------- .../async/accounts/OriginServiceAsync.kt | 74 +- .../async/accounts/OriginServiceAsyncImpl.kt | 37 +- .../blocking/accounts/OriginService.kt | 72 +- .../blocking/accounts/OriginServiceImpl.kt | 37 +- .../origins/OriginCreateResponseTest.kt | 420 -- .../origins/OriginListResponseTest.kt | 420 -- ...tResponseTest.kt => OriginResponseTest.kt} | 280 +- .../origins/OriginUpdateResponseTest.kt | 420 -- .../async/accounts/OriginServiceAsyncTest.kt | 24 +- .../blocking/accounts/OriginServiceTest.kt | 16 +- 15 files changed, 310 insertions(+), 12973 deletions(-) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/{OriginGetResponse.kt => OriginResponse.kt} (97%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/{OriginGetResponseTest.kt => OriginResponseTest.kt} (50%) delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 6690c82e..21592678 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-67e78a2f87dab7c661093c82f338197540584fa3d9a38773d1fdd435d788282f.yml openapi_spec_hash: 28ec969480eb18203d798e0435e76df3 -config_hash: 49e367d7f33aeaf63ed738c1c0392d0a +config_hash: 167d38f07a70976231dcdfa53ffa234c diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt deleted file mode 100644 index 4eb17b1b..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponse.kt +++ /dev/null @@ -1,3795 +0,0 @@ -// 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 = OriginCreateResponse.Deserializer::class) -@JsonSerialize(using = OriginCreateResponse.Serializer::class) -class OriginCreateResponse -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(): OriginCreateResponse = 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 OriginCreateResponse && - 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 -> "OriginCreateResponse{s3=$s3}" - s3Compatible != null -> "OriginCreateResponse{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "OriginCreateResponse{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "OriginCreateResponse{webFolder=$webFolder}" - webProxy != null -> "OriginCreateResponse{webProxy=$webProxy}" - gcs != null -> "OriginCreateResponse{gcs=$gcs}" - azureBlob != null -> "OriginCreateResponse{azureBlob=$azureBlob}" - akeneoPim != null -> "OriginCreateResponse{akeneoPim=$akeneoPim}" - _json != null -> "OriginCreateResponse{_unknown=$_json}" - else -> throw IllegalStateException("Invalid OriginCreateResponse") - } - - companion object { - - @JvmStatic fun ofS3(s3: S3) = OriginCreateResponse(s3 = s3) - - @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = - OriginCreateResponse(s3Compatible = s3Compatible) - - @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - OriginCreateResponse(cloudinaryBackup = cloudinaryBackup) - - @JvmStatic - fun ofWebFolder(webFolder: WebFolder) = OriginCreateResponse(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginCreateResponse(webProxy = webProxy) - - @JvmStatic fun ofGcs(gcs: Gcs) = OriginCreateResponse(gcs = gcs) - - @JvmStatic - fun ofAzureBlob(azureBlob: AzureBlob) = OriginCreateResponse(azureBlob = azureBlob) - - @JvmStatic - fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginCreateResponse(akeneoPim = akeneoPim) - } - - /** - * An interface that defines how to map each variant of [OriginCreateResponse] 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 [OriginCreateResponse] to a value of type [T]. - * - * An instance of [OriginCreateResponse] 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 OriginCreateResponse: $json") - } - } - - internal class Deserializer : - BaseDeserializer(OriginCreateResponse::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): OriginCreateResponse { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(s3 = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(s3Compatible = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(cloudinaryBackup = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(webFolder = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(webProxy = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(gcs = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(azureBlob = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginCreateResponse(akeneoPim = it, _json = json) - } ?: OriginCreateResponse(_json = json) - } - } - - return OriginCreateResponse(_json = json) - } - } - - internal class Serializer : BaseSerializer(OriginCreateResponse::class) { - - override fun serialize( - value: OriginCreateResponse, - 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 OriginCreateResponse") - } - } - } - - 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/OriginListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt deleted file mode 100644 index 8ec0a69e..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponse.kt +++ /dev/null @@ -1,3791 +0,0 @@ -// 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 = OriginListResponse.Deserializer::class) -@JsonSerialize(using = OriginListResponse.Serializer::class) -class OriginListResponse -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(): OriginListResponse = 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 OriginListResponse && - 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 -> "OriginListResponse{s3=$s3}" - s3Compatible != null -> "OriginListResponse{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "OriginListResponse{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "OriginListResponse{webFolder=$webFolder}" - webProxy != null -> "OriginListResponse{webProxy=$webProxy}" - gcs != null -> "OriginListResponse{gcs=$gcs}" - azureBlob != null -> "OriginListResponse{azureBlob=$azureBlob}" - akeneoPim != null -> "OriginListResponse{akeneoPim=$akeneoPim}" - _json != null -> "OriginListResponse{_unknown=$_json}" - else -> throw IllegalStateException("Invalid OriginListResponse") - } - - companion object { - - @JvmStatic fun ofS3(s3: S3) = OriginListResponse(s3 = s3) - - @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = - OriginListResponse(s3Compatible = s3Compatible) - - @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - OriginListResponse(cloudinaryBackup = cloudinaryBackup) - - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = OriginListResponse(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginListResponse(webProxy = webProxy) - - @JvmStatic fun ofGcs(gcs: Gcs) = OriginListResponse(gcs = gcs) - - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginListResponse(azureBlob = azureBlob) - - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginListResponse(akeneoPim = akeneoPim) - } - - /** - * An interface that defines how to map each variant of [OriginListResponse] 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 [OriginListResponse] to a value of type [T]. - * - * An instance of [OriginListResponse] 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 OriginListResponse: $json") - } - } - - internal class Deserializer : BaseDeserializer(OriginListResponse::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): OriginListResponse { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(s3 = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(s3Compatible = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(cloudinaryBackup = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(webFolder = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(webProxy = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(gcs = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(azureBlob = it, _json = json) - } ?: OriginListResponse(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginListResponse(akeneoPim = it, _json = json) - } ?: OriginListResponse(_json = json) - } - } - - return OriginListResponse(_json = json) - } - } - - internal class Serializer : BaseSerializer(OriginListResponse::class) { - - override fun serialize( - value: OriginListResponse, - 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 OriginListResponse") - } - } - } - - 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/OriginGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt index 81dffd47..5f8eed29 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt @@ -28,9 +28,9 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Origin object as returned by the API (sensitive fields removed). */ -@JsonDeserialize(using = OriginGetResponse.Deserializer::class) -@JsonSerialize(using = OriginGetResponse.Serializer::class) -class OriginGetResponse +@JsonDeserialize(using = OriginResponse.Deserializer::class) +@JsonSerialize(using = OriginResponse.Serializer::class) +class OriginResponse private constructor( private val s3: S3? = null, private val s3Compatible: S3Compatible? = null, @@ -108,7 +108,7 @@ private constructor( private var validated: Boolean = false - fun validate(): OriginGetResponse = apply { + fun validate(): OriginResponse = apply { if (validated) { return@apply } @@ -194,7 +194,7 @@ private constructor( return true } - return other is OriginGetResponse && + return other is OriginResponse && s3 == other.s3 && s3Compatible == other.s3Compatible && cloudinaryBackup == other.cloudinaryBackup && @@ -219,44 +219,42 @@ private constructor( override fun toString(): String = when { - s3 != null -> "OriginGetResponse{s3=$s3}" - s3Compatible != null -> "OriginGetResponse{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "OriginGetResponse{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "OriginGetResponse{webFolder=$webFolder}" - webProxy != null -> "OriginGetResponse{webProxy=$webProxy}" - gcs != null -> "OriginGetResponse{gcs=$gcs}" - azureBlob != null -> "OriginGetResponse{azureBlob=$azureBlob}" - akeneoPim != null -> "OriginGetResponse{akeneoPim=$akeneoPim}" - _json != null -> "OriginGetResponse{_unknown=$_json}" - else -> throw IllegalStateException("Invalid OriginGetResponse") + 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) = OriginGetResponse(s3 = s3) + @JvmStatic fun ofS3(s3: S3) = OriginResponse(s3 = s3) @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = - OriginGetResponse(s3Compatible = s3Compatible) + fun ofS3Compatible(s3Compatible: S3Compatible) = OriginResponse(s3Compatible = s3Compatible) @JvmStatic fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - OriginGetResponse(cloudinaryBackup = cloudinaryBackup) + OriginResponse(cloudinaryBackup = cloudinaryBackup) - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = OriginGetResponse(webFolder = webFolder) + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = OriginResponse(webFolder = webFolder) - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginGetResponse(webProxy = webProxy) + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginResponse(webProxy = webProxy) - @JvmStatic fun ofGcs(gcs: Gcs) = OriginGetResponse(gcs = gcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginResponse(gcs = gcs) - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginGetResponse(azureBlob = azureBlob) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginResponse(azureBlob = azureBlob) - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginGetResponse(akeneoPim = akeneoPim) + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginResponse(akeneoPim = akeneoPim) } /** - * An interface that defines how to map each variant of [OriginGetResponse] to a value of type - * [T]. + * An interface that defines how to map each variant of [OriginResponse] to a value of type [T]. */ interface Visitor { @@ -277,9 +275,9 @@ private constructor( fun visitAkeneoPim(akeneoPim: AkeneoPim): T /** - * Maps an unknown variant of [OriginGetResponse] to a value of type [T]. + * Maps an unknown variant of [OriginResponse] to a value of type [T]. * - * An instance of [OriginGetResponse] can contain an unknown variant if it was deserialized + * 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. @@ -287,67 +285,67 @@ private constructor( * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown OriginGetResponse: $json") + throw ImageKitInvalidDataException("Unknown OriginResponse: $json") } } - internal class Deserializer : BaseDeserializer(OriginGetResponse::class) { + internal class Deserializer : BaseDeserializer(OriginResponse::class) { - override fun ObjectCodec.deserialize(node: JsonNode): OriginGetResponse { + 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 { - OriginGetResponse(s3 = it, _json = json) - } ?: OriginGetResponse(_json = json) + OriginResponse(s3 = it, _json = json) + } ?: OriginResponse(_json = json) } "S3_COMPATIBLE" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(s3Compatible = it, _json = json) - } ?: OriginGetResponse(_json = json) + OriginResponse(s3Compatible = it, _json = json) + } ?: OriginResponse(_json = json) } "CLOUDINARY_BACKUP" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(cloudinaryBackup = it, _json = json) - } ?: OriginGetResponse(_json = json) + OriginResponse(cloudinaryBackup = it, _json = json) + } ?: OriginResponse(_json = json) } "WEB_FOLDER" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(webFolder = it, _json = json) - } ?: OriginGetResponse(_json = json) + OriginResponse(webFolder = it, _json = json) + } ?: OriginResponse(_json = json) } "WEB_PROXY" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(webProxy = it, _json = json) - } ?: OriginGetResponse(_json = json) + OriginResponse(webProxy = it, _json = json) + } ?: OriginResponse(_json = json) } "GCS" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(gcs = it, _json = json) - } ?: OriginGetResponse(_json = json) + OriginResponse(gcs = it, _json = json) + } ?: OriginResponse(_json = json) } "AZURE_BLOB" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(azureBlob = it, _json = json) - } ?: OriginGetResponse(_json = json) + OriginResponse(azureBlob = it, _json = json) + } ?: OriginResponse(_json = json) } "AKENEO_PIM" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - OriginGetResponse(akeneoPim = it, _json = json) - } ?: OriginGetResponse(_json = json) + OriginResponse(akeneoPim = it, _json = json) + } ?: OriginResponse(_json = json) } } - return OriginGetResponse(_json = json) + return OriginResponse(_json = json) } } - internal class Serializer : BaseSerializer(OriginGetResponse::class) { + internal class Serializer : BaseSerializer(OriginResponse::class) { override fun serialize( - value: OriginGetResponse, + value: OriginResponse, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -361,7 +359,7 @@ private constructor( 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 OriginGetResponse") + else -> throw IllegalStateException("Invalid OriginResponse") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt deleted file mode 100644 index 06009d04..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponse.kt +++ /dev/null @@ -1,3795 +0,0 @@ -// 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 = OriginUpdateResponse.Deserializer::class) -@JsonSerialize(using = OriginUpdateResponse.Serializer::class) -class OriginUpdateResponse -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(): OriginUpdateResponse = 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 OriginUpdateResponse && - 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 -> "OriginUpdateResponse{s3=$s3}" - s3Compatible != null -> "OriginUpdateResponse{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "OriginUpdateResponse{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "OriginUpdateResponse{webFolder=$webFolder}" - webProxy != null -> "OriginUpdateResponse{webProxy=$webProxy}" - gcs != null -> "OriginUpdateResponse{gcs=$gcs}" - azureBlob != null -> "OriginUpdateResponse{azureBlob=$azureBlob}" - akeneoPim != null -> "OriginUpdateResponse{akeneoPim=$akeneoPim}" - _json != null -> "OriginUpdateResponse{_unknown=$_json}" - else -> throw IllegalStateException("Invalid OriginUpdateResponse") - } - - companion object { - - @JvmStatic fun ofS3(s3: S3) = OriginUpdateResponse(s3 = s3) - - @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = - OriginUpdateResponse(s3Compatible = s3Compatible) - - @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - OriginUpdateResponse(cloudinaryBackup = cloudinaryBackup) - - @JvmStatic - fun ofWebFolder(webFolder: WebFolder) = OriginUpdateResponse(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginUpdateResponse(webProxy = webProxy) - - @JvmStatic fun ofGcs(gcs: Gcs) = OriginUpdateResponse(gcs = gcs) - - @JvmStatic - fun ofAzureBlob(azureBlob: AzureBlob) = OriginUpdateResponse(azureBlob = azureBlob) - - @JvmStatic - fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginUpdateResponse(akeneoPim = akeneoPim) - } - - /** - * An interface that defines how to map each variant of [OriginUpdateResponse] 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 [OriginUpdateResponse] to a value of type [T]. - * - * An instance of [OriginUpdateResponse] 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 OriginUpdateResponse: $json") - } - } - - internal class Deserializer : - BaseDeserializer(OriginUpdateResponse::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): OriginUpdateResponse { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(s3 = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(s3Compatible = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(cloudinaryBackup = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(webFolder = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(webProxy = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(gcs = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(azureBlob = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - OriginUpdateResponse(akeneoPim = it, _json = json) - } ?: OriginUpdateResponse(_json = json) - } - } - - return OriginUpdateResponse(_json = json) - } - } - - internal class Serializer : BaseSerializer(OriginUpdateResponse::class) { - - override fun serialize( - value: OriginUpdateResponse, - 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 OriginUpdateResponse") - } - } - } - - 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/services/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt index ae63f6e9..0852af1b 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 @@ -7,14 +7,11 @@ 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.OriginCreateResponse import com.imagekit.api.models.accounts.origins.OriginDeleteParams import com.imagekit.api.models.accounts.origins.OriginGetParams -import com.imagekit.api.models.accounts.origins.OriginGetResponse import com.imagekit.api.models.accounts.origins.OriginListParams -import com.imagekit.api.models.accounts.origins.OriginListResponse +import com.imagekit.api.models.accounts.origins.OriginResponse import com.imagekit.api.models.accounts.origins.OriginUpdateParams -import com.imagekit.api.models.accounts.origins.OriginUpdateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -35,20 +32,20 @@ interface OriginServiceAsync { /** * **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ - fun create(params: OriginCreateParams): CompletableFuture = + fun create(params: OriginCreateParams): CompletableFuture = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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 = + fun update(id: String, params: OriginUpdateParams): CompletableFuture = update(id, params, RequestOptions.none()) /** @see update */ @@ -56,38 +53,37 @@ interface OriginServiceAsync { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().id(id).build(), requestOptions) + ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: OriginUpdateParams): CompletableFuture = + fun update(params: OriginUpdateParams): CompletableFuture = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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()) + fun list(): CompletableFuture> = list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see list */ fun list( params: OriginListParams = OriginListParams.none() - ): CompletableFuture> = list(params, RequestOptions.none()) + ): CompletableFuture> = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture> = + fun list(requestOptions: RequestOptions): CompletableFuture> = list(OriginListParams.none(), requestOptions) /** @@ -124,33 +120,33 @@ interface OriginServiceAsync { 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()) + 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) + ): CompletableFuture = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: OriginGetParams = OriginGetParams.none(), - ): CompletableFuture = get(id, params, RequestOptions.none()) + ): CompletableFuture = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see get */ - fun get(params: OriginGetParams): CompletableFuture = + fun get(params: OriginGetParams): CompletableFuture = get(params, RequestOptions.none()) /** @see get */ - fun get(id: String, requestOptions: RequestOptions): CompletableFuture = + fun get(id: String, requestOptions: RequestOptions): CompletableFuture = get(id, OriginGetParams.none(), requestOptions) /** @@ -171,16 +167,14 @@ interface OriginServiceAsync { * Returns a raw HTTP response for `post /v1/accounts/origins`, but is otherwise the same as * [OriginServiceAsync.create]. */ - fun create( - params: OriginCreateParams - ): CompletableFuture> = + fun create(params: OriginCreateParams): CompletableFuture> = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the @@ -189,7 +183,7 @@ interface OriginServiceAsync { fun update( id: String, params: OriginUpdateParams, - ): CompletableFuture> = + ): CompletableFuture> = update(id, params, RequestOptions.none()) /** @see update */ @@ -197,44 +191,42 @@ interface OriginServiceAsync { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update( - params: OriginUpdateParams - ): CompletableFuture> = + fun update(params: OriginUpdateParams): CompletableFuture> = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/accounts/origins`, but is otherwise the same as * [OriginServiceAsync.list]. */ - fun list(): CompletableFuture>> = + fun list(): CompletableFuture>> = list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + ): CompletableFuture>> /** @see list */ fun list( params: OriginListParams = OriginListParams.none() - ): CompletableFuture>> = + ): CompletableFuture>> = list(params, RequestOptions.none()) /** @see list */ fun list( requestOptions: RequestOptions - ): CompletableFuture>> = + ): CompletableFuture>> = list(OriginListParams.none(), requestOptions) /** @@ -276,7 +268,7 @@ interface OriginServiceAsync { * Returns a raw HTTP response for `get /v1/accounts/origins/{id}`, but is otherwise the * same as [OriginServiceAsync.get]. */ - fun get(id: String): CompletableFuture> = + fun get(id: String): CompletableFuture> = get(id, OriginGetParams.none()) /** @see get */ @@ -284,31 +276,31 @@ interface OriginServiceAsync { id: String, params: OriginGetParams = OriginGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: OriginGetParams = OriginGetParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see get */ - fun get(params: OriginGetParams): CompletableFuture> = + fun get(params: OriginGetParams): CompletableFuture> = get(params, RequestOptions.none()) /** @see get */ fun get( id: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): 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 index 7805e11a..7b9da703 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/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt @@ -18,14 +18,11 @@ 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.OriginCreateResponse import com.imagekit.api.models.accounts.origins.OriginDeleteParams import com.imagekit.api.models.accounts.origins.OriginGetParams -import com.imagekit.api.models.accounts.origins.OriginGetResponse import com.imagekit.api.models.accounts.origins.OriginListParams -import com.imagekit.api.models.accounts.origins.OriginListResponse +import com.imagekit.api.models.accounts.origins.OriginResponse import com.imagekit.api.models.accounts.origins.OriginUpdateParams -import com.imagekit.api.models.accounts.origins.OriginUpdateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -45,21 +42,21 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/accounts/origins withRawResponse().create(params, requestOptions).thenApply { it.parse() } override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // put /v1/accounts/origins/{id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = // get /v1/accounts/origins withRawResponse().list(params, requestOptions).thenApply { it.parse() } @@ -73,7 +70,7 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/accounts/origins/{id} withRawResponse().get(params, requestOptions).thenApply { it.parse() } @@ -90,13 +87,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -121,13 +118,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -155,13 +152,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture>> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -212,13 +209,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/main/kotlin/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 dd3048a9..5d735334 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 @@ -8,14 +8,11 @@ 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.OriginCreateResponse import com.imagekit.api.models.accounts.origins.OriginDeleteParams import com.imagekit.api.models.accounts.origins.OriginGetParams -import com.imagekit.api.models.accounts.origins.OriginGetResponse import com.imagekit.api.models.accounts.origins.OriginListParams -import com.imagekit.api.models.accounts.origins.OriginListResponse +import com.imagekit.api.models.accounts.origins.OriginResponse import com.imagekit.api.models.accounts.origins.OriginUpdateParams -import com.imagekit.api.models.accounts.origins.OriginUpdateResponse import java.util.function.Consumer interface OriginService { @@ -35,20 +32,19 @@ interface OriginService { /** * **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ - fun create(params: OriginCreateParams): OriginCreateResponse = - create(params, RequestOptions.none()) + fun create(params: OriginCreateParams): OriginResponse = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): OriginCreateResponse + ): 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): OriginUpdateResponse = + fun update(id: String, params: OriginUpdateParams): OriginResponse = update(id, params, RequestOptions.none()) /** @see update */ @@ -56,36 +52,35 @@ interface OriginService { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): OriginUpdateResponse = update(params.toBuilder().id(id).build(), requestOptions) + ): OriginResponse = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: OriginUpdateParams): OriginUpdateResponse = - update(params, RequestOptions.none()) + fun update(params: OriginUpdateParams): OriginResponse = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): OriginUpdateResponse + ): 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()) + fun list(): List = list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): List + ): List /** @see list */ - fun list(params: OriginListParams = OriginListParams.none()): List = + fun list(params: OriginListParams = OriginListParams.none()): List = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): List = + fun list(requestOptions: RequestOptions): List = list(OriginListParams.none(), requestOptions) /** @@ -116,30 +111,30 @@ interface OriginService { delete(id, OriginDeleteParams.none(), requestOptions) /** **Note:** This API is currently in beta. Retrieves the origin identified by `id`. */ - fun get(id: String): OriginGetResponse = get(id, OriginGetParams.none()) + fun get(id: String): OriginResponse = get(id, OriginGetParams.none()) /** @see get */ fun get( id: String, params: OriginGetParams = OriginGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): OriginGetResponse = get(params.toBuilder().id(id).build(), requestOptions) + ): OriginResponse = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ - fun get(id: String, params: OriginGetParams = OriginGetParams.none()): OriginGetResponse = + fun get(id: String, params: OriginGetParams = OriginGetParams.none()): OriginResponse = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): OriginGetResponse + ): OriginResponse /** @see get */ - fun get(params: OriginGetParams): OriginGetResponse = get(params, RequestOptions.none()) + fun get(params: OriginGetParams): OriginResponse = get(params, RequestOptions.none()) /** @see get */ - fun get(id: String, requestOptions: RequestOptions): OriginGetResponse = + 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. */ @@ -157,7 +152,7 @@ interface OriginService { * [OriginService.create]. */ @MustBeClosed - fun create(params: OriginCreateParams): HttpResponseFor = + fun create(params: OriginCreateParams): HttpResponseFor = create(params, RequestOptions.none()) /** @see create */ @@ -165,14 +160,14 @@ interface OriginService { fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun update(id: String, params: OriginUpdateParams): HttpResponseFor = update(id, params, RequestOptions.none()) /** @see update */ @@ -181,12 +176,12 @@ interface OriginService { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ @MustBeClosed - fun update(params: OriginUpdateParams): HttpResponseFor = + fun update(params: OriginUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) /** @see update */ @@ -194,31 +189,31 @@ interface OriginService { fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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()) + fun list(): HttpResponseFor> = list(OriginListParams.none()) /** @see list */ @MustBeClosed fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + ): HttpResponseFor> /** @see list */ @MustBeClosed fun list( params: OriginListParams = OriginListParams.none() - ): HttpResponseFor> = list(params, RequestOptions.none()) + ): HttpResponseFor> = list(params, RequestOptions.none()) /** @see list */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor> = + fun list(requestOptions: RequestOptions): HttpResponseFor> = list(OriginListParams.none(), requestOptions) /** @@ -263,7 +258,7 @@ interface OriginService { * same as [OriginService.get]. */ @MustBeClosed - fun get(id: String): HttpResponseFor = get(id, OriginGetParams.none()) + fun get(id: String): HttpResponseFor = get(id, OriginGetParams.none()) /** @see get */ @MustBeClosed @@ -271,31 +266,30 @@ interface OriginService { id: String, params: OriginGetParams = OriginGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - get(params.toBuilder().id(id).build(), requestOptions) + ): 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()) + ): HttpResponseFor = get(id, params, RequestOptions.none()) /** @see get */ @MustBeClosed fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see get */ @MustBeClosed - fun get(params: OriginGetParams): HttpResponseFor = + fun get(params: OriginGetParams): HttpResponseFor = get(params, RequestOptions.none()) /** @see get */ @MustBeClosed - fun get(id: String, requestOptions: RequestOptions): HttpResponseFor = + 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 index 5ddd229a..bbbd6358 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/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt @@ -18,14 +18,11 @@ 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.OriginCreateResponse import com.imagekit.api.models.accounts.origins.OriginDeleteParams import com.imagekit.api.models.accounts.origins.OriginGetParams -import com.imagekit.api.models.accounts.origins.OriginGetResponse import com.imagekit.api.models.accounts.origins.OriginListParams -import com.imagekit.api.models.accounts.origins.OriginListResponse +import com.imagekit.api.models.accounts.origins.OriginResponse import com.imagekit.api.models.accounts.origins.OriginUpdateParams -import com.imagekit.api.models.accounts.origins.OriginUpdateResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -44,21 +41,21 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): OriginCreateResponse = + ): OriginResponse = // post /v1/accounts/origins withRawResponse().create(params, requestOptions).parse() override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): OriginUpdateResponse = + ): OriginResponse = // put /v1/accounts/origins/{id} withRawResponse().update(params, requestOptions).parse() override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): List = + ): List = // get /v1/accounts/origins withRawResponse().list(params, requestOptions).parse() @@ -67,7 +64,7 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp withRawResponse().delete(params, requestOptions) } - override fun get(params: OriginGetParams, requestOptions: RequestOptions): OriginGetResponse = + override fun get(params: OriginGetParams, requestOptions: RequestOptions): OriginResponse = // get /v1/accounts/origins/{id} withRawResponse().get(params, requestOptions).parse() @@ -84,13 +81,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -112,13 +109,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -143,13 +140,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -194,13 +191,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt deleted file mode 100644 index be5a3722..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateResponseTest.kt +++ /dev/null @@ -1,420 +0,0 @@ -// 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 OriginCreateResponseTest { - - @Test - fun ofS3() { - val s3 = - OriginCreateResponse.S3.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originCreateResponse = OriginCreateResponse.ofS3(s3) - - assertThat(originCreateResponse.s3()).contains(s3) - assertThat(originCreateResponse.s3Compatible()).isEmpty - assertThat(originCreateResponse.cloudinaryBackup()).isEmpty - assertThat(originCreateResponse.webFolder()).isEmpty - assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty - assertThat(originCreateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofS3Roundtrip() { - val jsonMapper = jsonMapper() - val originCreateResponse = - OriginCreateResponse.ofS3( - OriginCreateResponse.S3.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) - } - - @Test - fun ofS3Compatible() { - val s3Compatible = - OriginCreateResponse.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 originCreateResponse = OriginCreateResponse.ofS3Compatible(s3Compatible) - - assertThat(originCreateResponse.s3()).isEmpty - assertThat(originCreateResponse.s3Compatible()).contains(s3Compatible) - assertThat(originCreateResponse.cloudinaryBackup()).isEmpty - assertThat(originCreateResponse.webFolder()).isEmpty - assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty - assertThat(originCreateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofS3CompatibleRoundtrip() { - val jsonMapper = jsonMapper() - val originCreateResponse = - OriginCreateResponse.ofS3Compatible( - OriginCreateResponse.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 roundtrippedOriginCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) - } - - @Test - fun ofCloudinaryBackup() { - val cloudinaryBackup = - OriginCreateResponse.CloudinaryBackup.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originCreateResponse = OriginCreateResponse.ofCloudinaryBackup(cloudinaryBackup) - - assertThat(originCreateResponse.s3()).isEmpty - assertThat(originCreateResponse.s3Compatible()).isEmpty - assertThat(originCreateResponse.cloudinaryBackup()).contains(cloudinaryBackup) - assertThat(originCreateResponse.webFolder()).isEmpty - assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty - assertThat(originCreateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofCloudinaryBackupRoundtrip() { - val jsonMapper = jsonMapper() - val originCreateResponse = - OriginCreateResponse.ofCloudinaryBackup( - OriginCreateResponse.CloudinaryBackup.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) - } - - @Test - fun ofWebFolder() { - val webFolder = - OriginCreateResponse.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 originCreateResponse = OriginCreateResponse.ofWebFolder(webFolder) - - assertThat(originCreateResponse.s3()).isEmpty - assertThat(originCreateResponse.s3Compatible()).isEmpty - assertThat(originCreateResponse.cloudinaryBackup()).isEmpty - assertThat(originCreateResponse.webFolder()).contains(webFolder) - assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty - assertThat(originCreateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofWebFolderRoundtrip() { - val jsonMapper = jsonMapper() - val originCreateResponse = - OriginCreateResponse.ofWebFolder( - OriginCreateResponse.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 roundtrippedOriginCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) - } - - @Test - fun ofWebProxy() { - val webProxy = - OriginCreateResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originCreateResponse = OriginCreateResponse.ofWebProxy(webProxy) - - assertThat(originCreateResponse.s3()).isEmpty - assertThat(originCreateResponse.s3Compatible()).isEmpty - assertThat(originCreateResponse.cloudinaryBackup()).isEmpty - assertThat(originCreateResponse.webFolder()).isEmpty - assertThat(originCreateResponse.webProxy()).contains(webProxy) - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty - assertThat(originCreateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofWebProxyRoundtrip() { - val jsonMapper = jsonMapper() - val originCreateResponse = - OriginCreateResponse.ofWebProxy( - OriginCreateResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) - } - - @Test - fun ofGcs() { - val gcs = - OriginCreateResponse.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 originCreateResponse = OriginCreateResponse.ofGcs(gcs) - - assertThat(originCreateResponse.s3()).isEmpty - assertThat(originCreateResponse.s3Compatible()).isEmpty - assertThat(originCreateResponse.cloudinaryBackup()).isEmpty - assertThat(originCreateResponse.webFolder()).isEmpty - assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).contains(gcs) - assertThat(originCreateResponse.azureBlob()).isEmpty - assertThat(originCreateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofGcsRoundtrip() { - val jsonMapper = jsonMapper() - val originCreateResponse = - OriginCreateResponse.ofGcs( - OriginCreateResponse.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 roundtrippedOriginCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) - } - - @Test - fun ofAzureBlob() { - val azureBlob = - OriginCreateResponse.AzureBlob.builder() - .id("id") - .accountName("account123") - .container("images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("uploads") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originCreateResponse = OriginCreateResponse.ofAzureBlob(azureBlob) - - assertThat(originCreateResponse.s3()).isEmpty - assertThat(originCreateResponse.s3Compatible()).isEmpty - assertThat(originCreateResponse.cloudinaryBackup()).isEmpty - assertThat(originCreateResponse.webFolder()).isEmpty - assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).contains(azureBlob) - assertThat(originCreateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofAzureBlobRoundtrip() { - val jsonMapper = jsonMapper() - val originCreateResponse = - OriginCreateResponse.ofAzureBlob( - OriginCreateResponse.AzureBlob.builder() - .id("id") - .accountName("account123") - .container("images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("uploads") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) - } - - @Test - fun ofAkeneoPim() { - val akeneoPim = - OriginCreateResponse.AkeneoPim.builder() - .id("id") - .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originCreateResponse = OriginCreateResponse.ofAkeneoPim(akeneoPim) - - assertThat(originCreateResponse.s3()).isEmpty - assertThat(originCreateResponse.s3Compatible()).isEmpty - assertThat(originCreateResponse.cloudinaryBackup()).isEmpty - assertThat(originCreateResponse.webFolder()).isEmpty - assertThat(originCreateResponse.webProxy()).isEmpty - assertThat(originCreateResponse.gcs()).isEmpty - assertThat(originCreateResponse.azureBlob()).isEmpty - assertThat(originCreateResponse.akeneoPim()).contains(akeneoPim) - } - - @Test - fun ofAkeneoPimRoundtrip() { - val jsonMapper = jsonMapper() - val originCreateResponse = - OriginCreateResponse.ofAkeneoPim( - OriginCreateResponse.AkeneoPim.builder() - .id("id") - .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginCreateResponse).isEqualTo(originCreateResponse) - } - - 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 originCreateResponse = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { originCreateResponse.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt deleted file mode 100644 index 5a5b4506..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListResponseTest.kt +++ /dev/null @@ -1,420 +0,0 @@ -// 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 OriginListResponseTest { - - @Test - fun ofS3() { - val s3 = - OriginListResponse.S3.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originListResponse = OriginListResponse.ofS3(s3) - - assertThat(originListResponse.s3()).contains(s3) - assertThat(originListResponse.s3Compatible()).isEmpty - assertThat(originListResponse.cloudinaryBackup()).isEmpty - assertThat(originListResponse.webFolder()).isEmpty - assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty - assertThat(originListResponse.akeneoPim()).isEmpty - } - - @Test - fun ofS3Roundtrip() { - val jsonMapper = jsonMapper() - val originListResponse = - OriginListResponse.ofS3( - OriginListResponse.S3.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) - } - - @Test - fun ofS3Compatible() { - val s3Compatible = - OriginListResponse.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 originListResponse = OriginListResponse.ofS3Compatible(s3Compatible) - - assertThat(originListResponse.s3()).isEmpty - assertThat(originListResponse.s3Compatible()).contains(s3Compatible) - assertThat(originListResponse.cloudinaryBackup()).isEmpty - assertThat(originListResponse.webFolder()).isEmpty - assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty - assertThat(originListResponse.akeneoPim()).isEmpty - } - - @Test - fun ofS3CompatibleRoundtrip() { - val jsonMapper = jsonMapper() - val originListResponse = - OriginListResponse.ofS3Compatible( - OriginListResponse.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 roundtrippedOriginListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) - } - - @Test - fun ofCloudinaryBackup() { - val cloudinaryBackup = - OriginListResponse.CloudinaryBackup.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originListResponse = OriginListResponse.ofCloudinaryBackup(cloudinaryBackup) - - assertThat(originListResponse.s3()).isEmpty - assertThat(originListResponse.s3Compatible()).isEmpty - assertThat(originListResponse.cloudinaryBackup()).contains(cloudinaryBackup) - assertThat(originListResponse.webFolder()).isEmpty - assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty - assertThat(originListResponse.akeneoPim()).isEmpty - } - - @Test - fun ofCloudinaryBackupRoundtrip() { - val jsonMapper = jsonMapper() - val originListResponse = - OriginListResponse.ofCloudinaryBackup( - OriginListResponse.CloudinaryBackup.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) - } - - @Test - fun ofWebFolder() { - val webFolder = - OriginListResponse.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 originListResponse = OriginListResponse.ofWebFolder(webFolder) - - assertThat(originListResponse.s3()).isEmpty - assertThat(originListResponse.s3Compatible()).isEmpty - assertThat(originListResponse.cloudinaryBackup()).isEmpty - assertThat(originListResponse.webFolder()).contains(webFolder) - assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty - assertThat(originListResponse.akeneoPim()).isEmpty - } - - @Test - fun ofWebFolderRoundtrip() { - val jsonMapper = jsonMapper() - val originListResponse = - OriginListResponse.ofWebFolder( - OriginListResponse.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 roundtrippedOriginListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) - } - - @Test - fun ofWebProxy() { - val webProxy = - OriginListResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originListResponse = OriginListResponse.ofWebProxy(webProxy) - - assertThat(originListResponse.s3()).isEmpty - assertThat(originListResponse.s3Compatible()).isEmpty - assertThat(originListResponse.cloudinaryBackup()).isEmpty - assertThat(originListResponse.webFolder()).isEmpty - assertThat(originListResponse.webProxy()).contains(webProxy) - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty - assertThat(originListResponse.akeneoPim()).isEmpty - } - - @Test - fun ofWebProxyRoundtrip() { - val jsonMapper = jsonMapper() - val originListResponse = - OriginListResponse.ofWebProxy( - OriginListResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) - } - - @Test - fun ofGcs() { - val gcs = - OriginListResponse.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 originListResponse = OriginListResponse.ofGcs(gcs) - - assertThat(originListResponse.s3()).isEmpty - assertThat(originListResponse.s3Compatible()).isEmpty - assertThat(originListResponse.cloudinaryBackup()).isEmpty - assertThat(originListResponse.webFolder()).isEmpty - assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).contains(gcs) - assertThat(originListResponse.azureBlob()).isEmpty - assertThat(originListResponse.akeneoPim()).isEmpty - } - - @Test - fun ofGcsRoundtrip() { - val jsonMapper = jsonMapper() - val originListResponse = - OriginListResponse.ofGcs( - OriginListResponse.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 roundtrippedOriginListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) - } - - @Test - fun ofAzureBlob() { - val azureBlob = - OriginListResponse.AzureBlob.builder() - .id("id") - .accountName("account123") - .container("images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("uploads") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originListResponse = OriginListResponse.ofAzureBlob(azureBlob) - - assertThat(originListResponse.s3()).isEmpty - assertThat(originListResponse.s3Compatible()).isEmpty - assertThat(originListResponse.cloudinaryBackup()).isEmpty - assertThat(originListResponse.webFolder()).isEmpty - assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).contains(azureBlob) - assertThat(originListResponse.akeneoPim()).isEmpty - } - - @Test - fun ofAzureBlobRoundtrip() { - val jsonMapper = jsonMapper() - val originListResponse = - OriginListResponse.ofAzureBlob( - OriginListResponse.AzureBlob.builder() - .id("id") - .accountName("account123") - .container("images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("uploads") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) - } - - @Test - fun ofAkeneoPim() { - val akeneoPim = - OriginListResponse.AkeneoPim.builder() - .id("id") - .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originListResponse = OriginListResponse.ofAkeneoPim(akeneoPim) - - assertThat(originListResponse.s3()).isEmpty - assertThat(originListResponse.s3Compatible()).isEmpty - assertThat(originListResponse.cloudinaryBackup()).isEmpty - assertThat(originListResponse.webFolder()).isEmpty - assertThat(originListResponse.webProxy()).isEmpty - assertThat(originListResponse.gcs()).isEmpty - assertThat(originListResponse.azureBlob()).isEmpty - assertThat(originListResponse.akeneoPim()).contains(akeneoPim) - } - - @Test - fun ofAkeneoPimRoundtrip() { - val jsonMapper = jsonMapper() - val originListResponse = - OriginListResponse.ofAkeneoPim( - OriginListResponse.AkeneoPim.builder() - .id("id") - .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginListResponse).isEqualTo(originListResponse) - } - - 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 originListResponse = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { originListResponse.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt similarity index 50% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt index 81a0e62f..da0a3935 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt @@ -12,12 +12,12 @@ import org.junit.jupiter.api.assertThrows import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource -internal class OriginGetResponseTest { +internal class OriginResponseTest { @Test fun ofS3() { val s3 = - OriginGetResponse.S3.builder() + OriginResponse.S3.builder() .id("id") .bucket("product-images") .includeCanonicalHeader(false) @@ -26,24 +26,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofS3(s3) + val originResponse = OriginResponse.ofS3(s3) - assertThat(originGetResponse.s3()).contains(s3) - assertThat(originGetResponse.s3Compatible()).isEmpty - assertThat(originGetResponse.cloudinaryBackup()).isEmpty - assertThat(originGetResponse.webFolder()).isEmpty - assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty - assertThat(originGetResponse.akeneoPim()).isEmpty + 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 originGetResponse = - OriginGetResponse.ofS3( - OriginGetResponse.S3.builder() + val originResponse = + OriginResponse.ofS3( + OriginResponse.S3.builder() .id("id") .bucket("product-images") .includeCanonicalHeader(false) @@ -53,19 +53,19 @@ internal class OriginGetResponseTest { .build() ) - val roundtrippedOriginGetResponse = + val roundtrippedOriginResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(originGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) } @Test fun ofS3Compatible() { val s3Compatible = - OriginGetResponse.S3Compatible.builder() + OriginResponse.S3Compatible.builder() .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") @@ -76,24 +76,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofS3Compatible(s3Compatible) + val originResponse = OriginResponse.ofS3Compatible(s3Compatible) - assertThat(originGetResponse.s3()).isEmpty - assertThat(originGetResponse.s3Compatible()).contains(s3Compatible) - assertThat(originGetResponse.cloudinaryBackup()).isEmpty - assertThat(originGetResponse.webFolder()).isEmpty - assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty - assertThat(originGetResponse.akeneoPim()).isEmpty + 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 originGetResponse = - OriginGetResponse.ofS3Compatible( - OriginGetResponse.S3Compatible.builder() + val originResponse = + OriginResponse.ofS3Compatible( + OriginResponse.S3Compatible.builder() .id("id") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") @@ -105,19 +105,19 @@ internal class OriginGetResponseTest { .build() ) - val roundtrippedOriginGetResponse = + val roundtrippedOriginResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(originGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) } @Test fun ofCloudinaryBackup() { val cloudinaryBackup = - OriginGetResponse.CloudinaryBackup.builder() + OriginResponse.CloudinaryBackup.builder() .id("id") .bucket("product-images") .includeCanonicalHeader(false) @@ -126,24 +126,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofCloudinaryBackup(cloudinaryBackup) + val originResponse = OriginResponse.ofCloudinaryBackup(cloudinaryBackup) - assertThat(originGetResponse.s3()).isEmpty - assertThat(originGetResponse.s3Compatible()).isEmpty - assertThat(originGetResponse.cloudinaryBackup()).contains(cloudinaryBackup) - assertThat(originGetResponse.webFolder()).isEmpty - assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty - assertThat(originGetResponse.akeneoPim()).isEmpty + 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 originGetResponse = - OriginGetResponse.ofCloudinaryBackup( - OriginGetResponse.CloudinaryBackup.builder() + val originResponse = + OriginResponse.ofCloudinaryBackup( + OriginResponse.CloudinaryBackup.builder() .id("id") .bucket("product-images") .includeCanonicalHeader(false) @@ -153,19 +153,19 @@ internal class OriginGetResponseTest { .build() ) - val roundtrippedOriginGetResponse = + val roundtrippedOriginResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(originGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) } @Test fun ofWebFolder() { val webFolder = - OriginGetResponse.WebFolder.builder() + OriginResponse.WebFolder.builder() .id("id") .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) @@ -174,24 +174,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofWebFolder(webFolder) + val originResponse = OriginResponse.ofWebFolder(webFolder) - assertThat(originGetResponse.s3()).isEmpty - assertThat(originGetResponse.s3Compatible()).isEmpty - assertThat(originGetResponse.cloudinaryBackup()).isEmpty - assertThat(originGetResponse.webFolder()).contains(webFolder) - assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty - assertThat(originGetResponse.akeneoPim()).isEmpty + 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 originGetResponse = - OriginGetResponse.ofWebFolder( - OriginGetResponse.WebFolder.builder() + val originResponse = + OriginResponse.ofWebFolder( + OriginResponse.WebFolder.builder() .id("id") .baseUrl("https://images.example.com/assets") .forwardHostHeaderToOrigin(false) @@ -201,43 +201,43 @@ internal class OriginGetResponseTest { .build() ) - val roundtrippedOriginGetResponse = + val roundtrippedOriginResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(originGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) } @Test fun ofWebProxy() { val webProxy = - OriginGetResponse.WebProxy.builder() + OriginResponse.WebProxy.builder() .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofWebProxy(webProxy) + val originResponse = OriginResponse.ofWebProxy(webProxy) - assertThat(originGetResponse.s3()).isEmpty - assertThat(originGetResponse.s3Compatible()).isEmpty - assertThat(originGetResponse.cloudinaryBackup()).isEmpty - assertThat(originGetResponse.webFolder()).isEmpty - assertThat(originGetResponse.webProxy()).contains(webProxy) - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty - assertThat(originGetResponse.akeneoPim()).isEmpty + 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 originGetResponse = - OriginGetResponse.ofWebProxy( - OriginGetResponse.WebProxy.builder() + val originResponse = + OriginResponse.ofWebProxy( + OriginResponse.WebProxy.builder() .id("id") .includeCanonicalHeader(false) .name("US S3 Storage") @@ -245,19 +245,19 @@ internal class OriginGetResponseTest { .build() ) - val roundtrippedOriginGetResponse = + val roundtrippedOriginResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(originGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) } @Test fun ofGcs() { val gcs = - OriginGetResponse.Gcs.builder() + OriginResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -267,24 +267,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofGcs(gcs) + val originResponse = OriginResponse.ofGcs(gcs) - assertThat(originGetResponse.s3()).isEmpty - assertThat(originGetResponse.s3Compatible()).isEmpty - assertThat(originGetResponse.cloudinaryBackup()).isEmpty - assertThat(originGetResponse.webFolder()).isEmpty - assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).contains(gcs) - assertThat(originGetResponse.azureBlob()).isEmpty - assertThat(originGetResponse.akeneoPim()).isEmpty + 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 originGetResponse = - OriginGetResponse.ofGcs( - OriginGetResponse.Gcs.builder() + val originResponse = + OriginResponse.ofGcs( + OriginResponse.Gcs.builder() .id("id") .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") @@ -295,19 +295,19 @@ internal class OriginGetResponseTest { .build() ) - val roundtrippedOriginGetResponse = + val roundtrippedOriginResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(originGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) } @Test fun ofAzureBlob() { val azureBlob = - OriginGetResponse.AzureBlob.builder() + OriginResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -317,24 +317,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofAzureBlob(azureBlob) + val originResponse = OriginResponse.ofAzureBlob(azureBlob) - assertThat(originGetResponse.s3()).isEmpty - assertThat(originGetResponse.s3Compatible()).isEmpty - assertThat(originGetResponse.cloudinaryBackup()).isEmpty - assertThat(originGetResponse.webFolder()).isEmpty - assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).contains(azureBlob) - assertThat(originGetResponse.akeneoPim()).isEmpty + 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 originGetResponse = - OriginGetResponse.ofAzureBlob( - OriginGetResponse.AzureBlob.builder() + val originResponse = + OriginResponse.ofAzureBlob( + OriginResponse.AzureBlob.builder() .id("id") .accountName("account123") .container("images") @@ -345,19 +345,19 @@ internal class OriginGetResponseTest { .build() ) - val roundtrippedOriginGetResponse = + val roundtrippedOriginResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(originGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) } @Test fun ofAkeneoPim() { val akeneoPim = - OriginGetResponse.AkeneoPim.builder() + OriginResponse.AkeneoPim.builder() .id("id") .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) @@ -365,24 +365,24 @@ internal class OriginGetResponseTest { .baseUrlForCanonicalHeader("https://cdn.example.com") .build() - val originGetResponse = OriginGetResponse.ofAkeneoPim(akeneoPim) + val originResponse = OriginResponse.ofAkeneoPim(akeneoPim) - assertThat(originGetResponse.s3()).isEmpty - assertThat(originGetResponse.s3Compatible()).isEmpty - assertThat(originGetResponse.cloudinaryBackup()).isEmpty - assertThat(originGetResponse.webFolder()).isEmpty - assertThat(originGetResponse.webProxy()).isEmpty - assertThat(originGetResponse.gcs()).isEmpty - assertThat(originGetResponse.azureBlob()).isEmpty - assertThat(originGetResponse.akeneoPim()).contains(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 originGetResponse = - OriginGetResponse.ofAkeneoPim( - OriginGetResponse.AkeneoPim.builder() + val originResponse = + OriginResponse.ofAkeneoPim( + OriginResponse.AkeneoPim.builder() .id("id") .baseUrl("https://akeneo.company.com") .includeCanonicalHeader(false) @@ -391,13 +391,13 @@ internal class OriginGetResponseTest { .build() ) - val roundtrippedOriginGetResponse = + val roundtrippedOriginResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(originGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedOriginGetResponse).isEqualTo(originGetResponse) + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) } enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { @@ -411,10 +411,10 @@ internal class OriginGetResponseTest { @ParameterizedTest @EnumSource fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val originGetResponse = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + val originResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - val e = assertThrows { originGetResponse.validate() } + 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/OriginUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt deleted file mode 100644 index c569a06f..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateResponseTest.kt +++ /dev/null @@ -1,420 +0,0 @@ -// 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 OriginUpdateResponseTest { - - @Test - fun ofS3() { - val s3 = - OriginUpdateResponse.S3.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originUpdateResponse = OriginUpdateResponse.ofS3(s3) - - assertThat(originUpdateResponse.s3()).contains(s3) - assertThat(originUpdateResponse.s3Compatible()).isEmpty - assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty - assertThat(originUpdateResponse.webFolder()).isEmpty - assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty - assertThat(originUpdateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofS3Roundtrip() { - val jsonMapper = jsonMapper() - val originUpdateResponse = - OriginUpdateResponse.ofS3( - OriginUpdateResponse.S3.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) - } - - @Test - fun ofS3Compatible() { - val s3Compatible = - OriginUpdateResponse.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 originUpdateResponse = OriginUpdateResponse.ofS3Compatible(s3Compatible) - - assertThat(originUpdateResponse.s3()).isEmpty - assertThat(originUpdateResponse.s3Compatible()).contains(s3Compatible) - assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty - assertThat(originUpdateResponse.webFolder()).isEmpty - assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty - assertThat(originUpdateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofS3CompatibleRoundtrip() { - val jsonMapper = jsonMapper() - val originUpdateResponse = - OriginUpdateResponse.ofS3Compatible( - OriginUpdateResponse.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 roundtrippedOriginUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) - } - - @Test - fun ofCloudinaryBackup() { - val cloudinaryBackup = - OriginUpdateResponse.CloudinaryBackup.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originUpdateResponse = OriginUpdateResponse.ofCloudinaryBackup(cloudinaryBackup) - - assertThat(originUpdateResponse.s3()).isEmpty - assertThat(originUpdateResponse.s3Compatible()).isEmpty - assertThat(originUpdateResponse.cloudinaryBackup()).contains(cloudinaryBackup) - assertThat(originUpdateResponse.webFolder()).isEmpty - assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty - assertThat(originUpdateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofCloudinaryBackupRoundtrip() { - val jsonMapper = jsonMapper() - val originUpdateResponse = - OriginUpdateResponse.ofCloudinaryBackup( - OriginUpdateResponse.CloudinaryBackup.builder() - .id("id") - .bucket("product-images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("raw-assets") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) - } - - @Test - fun ofWebFolder() { - val webFolder = - OriginUpdateResponse.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 originUpdateResponse = OriginUpdateResponse.ofWebFolder(webFolder) - - assertThat(originUpdateResponse.s3()).isEmpty - assertThat(originUpdateResponse.s3Compatible()).isEmpty - assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty - assertThat(originUpdateResponse.webFolder()).contains(webFolder) - assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty - assertThat(originUpdateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofWebFolderRoundtrip() { - val jsonMapper = jsonMapper() - val originUpdateResponse = - OriginUpdateResponse.ofWebFolder( - OriginUpdateResponse.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 roundtrippedOriginUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) - } - - @Test - fun ofWebProxy() { - val webProxy = - OriginUpdateResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originUpdateResponse = OriginUpdateResponse.ofWebProxy(webProxy) - - assertThat(originUpdateResponse.s3()).isEmpty - assertThat(originUpdateResponse.s3Compatible()).isEmpty - assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty - assertThat(originUpdateResponse.webFolder()).isEmpty - assertThat(originUpdateResponse.webProxy()).contains(webProxy) - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty - assertThat(originUpdateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofWebProxyRoundtrip() { - val jsonMapper = jsonMapper() - val originUpdateResponse = - OriginUpdateResponse.ofWebProxy( - OriginUpdateResponse.WebProxy.builder() - .id("id") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) - } - - @Test - fun ofGcs() { - val gcs = - OriginUpdateResponse.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 originUpdateResponse = OriginUpdateResponse.ofGcs(gcs) - - assertThat(originUpdateResponse.s3()).isEmpty - assertThat(originUpdateResponse.s3Compatible()).isEmpty - assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty - assertThat(originUpdateResponse.webFolder()).isEmpty - assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).contains(gcs) - assertThat(originUpdateResponse.azureBlob()).isEmpty - assertThat(originUpdateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofGcsRoundtrip() { - val jsonMapper = jsonMapper() - val originUpdateResponse = - OriginUpdateResponse.ofGcs( - OriginUpdateResponse.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 roundtrippedOriginUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) - } - - @Test - fun ofAzureBlob() { - val azureBlob = - OriginUpdateResponse.AzureBlob.builder() - .id("id") - .accountName("account123") - .container("images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("uploads") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originUpdateResponse = OriginUpdateResponse.ofAzureBlob(azureBlob) - - assertThat(originUpdateResponse.s3()).isEmpty - assertThat(originUpdateResponse.s3Compatible()).isEmpty - assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty - assertThat(originUpdateResponse.webFolder()).isEmpty - assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).contains(azureBlob) - assertThat(originUpdateResponse.akeneoPim()).isEmpty - } - - @Test - fun ofAzureBlobRoundtrip() { - val jsonMapper = jsonMapper() - val originUpdateResponse = - OriginUpdateResponse.ofAzureBlob( - OriginUpdateResponse.AzureBlob.builder() - .id("id") - .accountName("account123") - .container("images") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .prefix("uploads") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) - } - - @Test - fun ofAkeneoPim() { - val akeneoPim = - OriginUpdateResponse.AkeneoPim.builder() - .id("id") - .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - - val originUpdateResponse = OriginUpdateResponse.ofAkeneoPim(akeneoPim) - - assertThat(originUpdateResponse.s3()).isEmpty - assertThat(originUpdateResponse.s3Compatible()).isEmpty - assertThat(originUpdateResponse.cloudinaryBackup()).isEmpty - assertThat(originUpdateResponse.webFolder()).isEmpty - assertThat(originUpdateResponse.webProxy()).isEmpty - assertThat(originUpdateResponse.gcs()).isEmpty - assertThat(originUpdateResponse.azureBlob()).isEmpty - assertThat(originUpdateResponse.akeneoPim()).contains(akeneoPim) - } - - @Test - fun ofAkeneoPimRoundtrip() { - val jsonMapper = jsonMapper() - val originUpdateResponse = - OriginUpdateResponse.ofAkeneoPim( - OriginUpdateResponse.AkeneoPim.builder() - .id("id") - .baseUrl("https://akeneo.company.com") - .includeCanonicalHeader(false) - .name("US S3 Storage") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .build() - ) - - val roundtrippedOriginUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(originUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedOriginUpdateResponse).isEqualTo(originUpdateResponse) - } - - 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 originUpdateResponse = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { originUpdateResponse.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} 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 0f7f1261..f564bc59 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 @@ -25,7 +25,7 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originFuture = + val originResponseFuture = originServiceAsync.create( OriginCreateParams.builder() .origin( @@ -42,8 +42,8 @@ internal class OriginServiceAsyncTest { .build() ) - val origin = originFuture.get() - origin.validate() + val originResponse = originResponseFuture.get() + originResponse.validate() } @Disabled("Prism tests are disabled") @@ -57,7 +57,7 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originFuture = + val originResponseFuture = originServiceAsync.update( OriginUpdateParams.builder() .id("id") @@ -75,8 +75,8 @@ internal class OriginServiceAsyncTest { .build() ) - val origin = originFuture.get() - origin.validate() + val originResponse = originResponseFuture.get() + originResponse.validate() } @Disabled("Prism tests are disabled") @@ -90,10 +90,10 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originsFuture = originServiceAsync.list() + val originResponsesFuture = originServiceAsync.list() - val origins = originsFuture.get() - origins.forEach { it.validate() } + val originResponses = originResponsesFuture.get() + originResponses.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -123,9 +123,9 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originFuture = originServiceAsync.get("id") + val originResponseFuture = originServiceAsync.get("id") - val origin = originFuture.get() - origin.validate() + val originResponse = originResponseFuture.get() + originResponse.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 index 8fe9c310..75d18afe 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 @@ -25,7 +25,7 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val origin = + val originResponse = originService.create( OriginCreateParams.builder() .origin( @@ -42,7 +42,7 @@ internal class OriginServiceTest { .build() ) - origin.validate() + originResponse.validate() } @Disabled("Prism tests are disabled") @@ -56,7 +56,7 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val origin = + val originResponse = originService.update( OriginUpdateParams.builder() .id("id") @@ -74,7 +74,7 @@ internal class OriginServiceTest { .build() ) - origin.validate() + originResponse.validate() } @Disabled("Prism tests are disabled") @@ -88,9 +88,9 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val origins = originService.list() + val originResponses = originService.list() - origins.forEach { it.validate() } + originResponses.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -118,8 +118,8 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val origin = originService.get("id") + val originResponse = originService.get("id") - origin.validate() + originResponse.validate() } } From e65b69899ef7677e427eb799d6466ecf671e60f7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 06:09:30 +0000 Subject: [PATCH 051/125] feat(api): manual updates --- .stats.yml | 6 +- .../api/models/accounts/origins/Origin.kt | 345 +- .../models/accounts/origins/OriginResponse.kt | 3789 ----------------- .../async/accounts/OriginServiceAsync.kt | 76 +- .../async/accounts/OriginServiceAsyncImpl.kt | 31 +- .../blocking/accounts/OriginService.kt | 72 +- .../blocking/accounts/OriginServiceImpl.kt | 40 +- .../origins/OriginCreateParamsTest.kt | 27 +- .../accounts/origins/OriginResponseTest.kt | 420 -- .../api/models/accounts/origins/OriginTest.kt | 40 +- .../origins/OriginUpdateParamsTest.kt | 36 +- .../async/accounts/OriginServiceAsyncTest.kt | 30 +- .../blocking/accounts/OriginServiceTest.kt | 22 +- 13 files changed, 485 insertions(+), 4449 deletions(-) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 21592678..6ac1eba7 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-67e78a2f87dab7c661093c82f338197540584fa3d9a38773d1fdd435d788282f.yml -openapi_spec_hash: 28ec969480eb18203d798e0435e76df3 -config_hash: 167d38f07a70976231dcdfa53ffa234c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-554f897c7f0061bb1fe51cd82f5f05e66050db5e868524c374dac827bd7b8c3d.yml +openapi_spec_hash: 95b7298e7f3977ea6c98d9557d2c8d27 +config_hash: 49e367d7f33aeaf63ed738c1c0392d0a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt index e03765d9..504b58db 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt @@ -368,6 +368,7 @@ private constructor( private val name: JsonField, private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -385,6 +386,7 @@ private constructor( @ExcludeMissing secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -398,6 +400,7 @@ private constructor( name, secretKey, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -447,6 +450,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * 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 (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + /** * URL used in the Canonical header (if enabled). * @@ -501,6 +513,13 @@ private constructor( */ @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -564,6 +583,7 @@ private constructor( private var name: JsonField? = null private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3") + private var id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var prefix: JsonField = JsonMissing.of() @@ -576,6 +596,7 @@ private constructor( name = s3.name secretKey = s3.secretKey type = s3.type + id = s3.id baseUrlForCanonicalHeader = s3.baseUrlForCanonicalHeader includeCanonicalHeader = s3.includeCanonicalHeader prefix = s3.prefix @@ -644,6 +665,21 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** + * 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -727,6 +763,7 @@ private constructor( checkRequired("name", name), checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -750,6 +787,7 @@ private constructor( throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -777,6 +815,7 @@ private constructor( (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 (id.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) @@ -792,6 +831,7 @@ private constructor( name == other.name && secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && includeCanonicalHeader == other.includeCanonicalHeader && prefix == other.prefix && @@ -805,6 +845,7 @@ private constructor( name, secretKey, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -815,7 +856,7 @@ private constructor( 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}" + "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class S3Compatible @@ -826,6 +867,7 @@ private constructor( private val name: JsonField, private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -847,6 +889,7 @@ private constructor( @ExcludeMissing secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -864,6 +907,7 @@ private constructor( name, secretKey, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -922,6 +966,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * 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 (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + /** * URL used in the Canonical header (if enabled). * @@ -991,6 +1044,13 @@ private constructor( */ @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -1066,6 +1126,7 @@ private constructor( private var name: JsonField? = null private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") + private var id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var prefix: JsonField = JsonMissing.of() @@ -1080,6 +1141,7 @@ private constructor( name = s3Compatible.name secretKey = s3Compatible.secretKey type = s3Compatible.type + id = s3Compatible.id baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader includeCanonicalHeader = s3Compatible.includeCanonicalHeader prefix = s3Compatible.prefix @@ -1161,6 +1223,21 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** + * 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1261,6 +1338,7 @@ private constructor( checkRequired("name", name), checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1286,6 +1364,7 @@ private constructor( throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1315,6 +1394,7 @@ private constructor( (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 (id.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) + @@ -1332,6 +1412,7 @@ private constructor( name == other.name && secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && includeCanonicalHeader == other.includeCanonicalHeader && prefix == other.prefix && @@ -1347,6 +1428,7 @@ private constructor( name, secretKey, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1358,7 +1440,7 @@ private constructor( 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}" + "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" } class CloudinaryBackup @@ -1368,6 +1450,7 @@ private constructor( private val name: JsonField, private val secretKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -1385,6 +1468,7 @@ private constructor( @ExcludeMissing secretKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1398,6 +1482,7 @@ private constructor( name, secretKey, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1447,6 +1532,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * 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 (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + /** * URL used in the Canonical header (if enabled). * @@ -1501,6 +1595,13 @@ private constructor( */ @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -1564,6 +1665,7 @@ private constructor( private var name: JsonField? = null private var secretKey: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") + private var id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var prefix: JsonField = JsonMissing.of() @@ -1576,6 +1678,7 @@ private constructor( name = cloudinaryBackup.name secretKey = cloudinaryBackup.secretKey type = cloudinaryBackup.type + id = cloudinaryBackup.id baseUrlForCanonicalHeader = cloudinaryBackup.baseUrlForCanonicalHeader includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader prefix = cloudinaryBackup.prefix @@ -1644,6 +1747,21 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** + * 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1727,6 +1845,7 @@ private constructor( checkRequired("name", name), checkRequired("secretKey", secretKey), type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1750,6 +1869,7 @@ private constructor( throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -1777,6 +1897,7 @@ private constructor( (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 (id.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) @@ -1792,6 +1913,7 @@ private constructor( name == other.name && secretKey == other.secretKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && includeCanonicalHeader == other.includeCanonicalHeader && prefix == other.prefix && @@ -1805,6 +1927,7 @@ private constructor( name, secretKey, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -1815,7 +1938,7 @@ private constructor( 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}" + "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class WebFolder @@ -1823,6 +1946,7 @@ private constructor( private val baseUrl: JsonField, private val name: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val forwardHostHeaderToOrigin: JsonField, private val includeCanonicalHeader: JsonField, @@ -1834,6 +1958,7 @@ private constructor( @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -1847,6 +1972,7 @@ private constructor( baseUrl, name, type, + id, baseUrlForCanonicalHeader, forwardHostHeaderToOrigin, includeCanonicalHeader, @@ -1880,6 +2006,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * 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 (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + /** * URL used in the Canonical header (if enabled). * @@ -1921,6 +2056,13 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = 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 [baseUrlForCanonicalHeader]. * @@ -1983,6 +2125,7 @@ private constructor( private var baseUrl: JsonField? = null private var name: JsonField? = null private var type: JsonValue = JsonValue.from("WEB_FOLDER") + private var id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var forwardHostHeaderToOrigin: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() @@ -1993,6 +2136,7 @@ private constructor( baseUrl = webFolder.baseUrl name = webFolder.name type = webFolder.type + id = webFolder.id baseUrlForCanonicalHeader = webFolder.baseUrlForCanonicalHeader forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin includeCanonicalHeader = webFolder.includeCanonicalHeader @@ -2037,6 +2181,21 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** + * 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2119,6 +2278,7 @@ private constructor( checkRequired("baseUrl", baseUrl), checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, forwardHostHeaderToOrigin, includeCanonicalHeader, @@ -2140,6 +2300,7 @@ private constructor( throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() forwardHostHeaderToOrigin() includeCanonicalHeader() @@ -2165,6 +2326,7 @@ private constructor( (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 (id.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -2178,6 +2340,7 @@ private constructor( baseUrl == other.baseUrl && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && includeCanonicalHeader == other.includeCanonicalHeader && @@ -2189,6 +2352,7 @@ private constructor( baseUrl, name, type, + id, baseUrlForCanonicalHeader, forwardHostHeaderToOrigin, includeCanonicalHeader, @@ -2199,13 +2363,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } class WebProxy private constructor( private val name: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -2215,13 +2380,14 @@ private constructor( private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @JsonProperty("includeCanonicalHeader") @ExcludeMissing includeCanonicalHeader: JsonField = JsonMissing.of(), - ) : this(name, type, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) + ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) /** * Display name of the origin. @@ -2242,6 +2408,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * 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 (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + /** * URL used in the Canonical header (if enabled). * @@ -2267,6 +2442,13 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = 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 [baseUrlForCanonicalHeader]. * @@ -2317,6 +2499,7 @@ private constructor( private var name: JsonField? = null private var type: JsonValue = JsonValue.from("WEB_PROXY") + private var id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2325,6 +2508,7 @@ private constructor( internal fun from(webProxy: WebProxy) = apply { name = webProxy.name type = webProxy.type + id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader includeCanonicalHeader = webProxy.includeCanonicalHeader additionalProperties = webProxy.additionalProperties.toMutableMap() @@ -2356,6 +2540,21 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** + * 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2421,6 +2620,7 @@ private constructor( WebProxy( checkRequired("name", name), type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, additionalProperties.toMutableMap(), @@ -2440,6 +2640,7 @@ private constructor( throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() includeCanonicalHeader() validated = true @@ -2463,6 +2664,7 @@ private constructor( internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + + (if (id.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -2474,6 +2676,7 @@ private constructor( return other is WebProxy && name == other.name && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties @@ -2483,6 +2686,7 @@ private constructor( Objects.hash( name, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, additionalProperties, @@ -2492,7 +2696,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" } class Gcs @@ -2502,6 +2706,7 @@ private constructor( private val name: JsonField, private val privateKey: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -2519,6 +2724,7 @@ private constructor( @ExcludeMissing privateKey: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2532,6 +2738,7 @@ private constructor( name, privateKey, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -2575,6 +2782,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * 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 (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + /** * URL used in the Canonical header (if enabled). * @@ -2631,6 +2847,13 @@ private constructor( @ExcludeMissing fun _privateKey(): JsonField = privateKey + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -2694,6 +2917,7 @@ private constructor( private var name: JsonField? = null private var privateKey: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") + private var id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var prefix: JsonField = JsonMissing.of() @@ -2706,6 +2930,7 @@ private constructor( name = gcs.name privateKey = gcs.privateKey type = gcs.type + id = gcs.id baseUrlForCanonicalHeader = gcs.baseUrlForCanonicalHeader includeCanonicalHeader = gcs.includeCanonicalHeader prefix = gcs.prefix @@ -2773,6 +2998,21 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** + * 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2855,6 +3095,7 @@ private constructor( checkRequired("name", name), checkRequired("privateKey", privateKey), type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -2878,6 +3119,7 @@ private constructor( throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -2905,6 +3147,7 @@ private constructor( (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 (id.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) @@ -2920,6 +3163,7 @@ private constructor( name == other.name && privateKey == other.privateKey && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && includeCanonicalHeader == other.includeCanonicalHeader && prefix == other.prefix && @@ -2933,6 +3177,7 @@ private constructor( name, privateKey, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -2943,7 +3188,7 @@ private constructor( 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}" + "Gcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AzureBlob @@ -2953,6 +3198,7 @@ private constructor( private val name: JsonField, private val sasToken: JsonField, private val type: JsonValue, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val prefix: JsonField, @@ -2972,6 +3218,7 @@ private constructor( @ExcludeMissing sasToken: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -2985,6 +3232,7 @@ private constructor( name, sasToken, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3028,6 +3276,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * 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 (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + /** * URL used in the Canonical header (if enabled). * @@ -3082,6 +3339,13 @@ private constructor( */ @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -3145,6 +3409,7 @@ private constructor( private var name: JsonField? = null private var sasToken: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") + private var id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var prefix: JsonField = JsonMissing.of() @@ -3157,6 +3422,7 @@ private constructor( name = azureBlob.name sasToken = azureBlob.sasToken type = azureBlob.type + id = azureBlob.id baseUrlForCanonicalHeader = azureBlob.baseUrlForCanonicalHeader includeCanonicalHeader = azureBlob.includeCanonicalHeader prefix = azureBlob.prefix @@ -3224,6 +3490,21 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** + * 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3306,6 +3587,7 @@ private constructor( checkRequired("name", name), checkRequired("sasToken", sasToken), type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3329,6 +3611,7 @@ private constructor( throw ImageKitInvalidDataException("'type' is invalid, received $it") } } + id() baseUrlForCanonicalHeader() includeCanonicalHeader() prefix() @@ -3356,6 +3639,7 @@ private constructor( (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 (id.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (prefix.asKnown().isPresent) 1 else 0) @@ -3371,6 +3655,7 @@ private constructor( name == other.name && sasToken == other.sasToken && type == other.type && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && includeCanonicalHeader == other.includeCanonicalHeader && prefix == other.prefix && @@ -3384,6 +3669,7 @@ private constructor( name, sasToken, type, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, prefix, @@ -3394,7 +3680,7 @@ private constructor( 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}" + "AzureBlob{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" } class AkeneoPim @@ -3406,6 +3692,7 @@ private constructor( private val password: JsonField, private val type: JsonValue, private val username: JsonField, + private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, @@ -3428,6 +3715,7 @@ private constructor( @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), @@ -3442,6 +3730,7 @@ private constructor( password, type, username, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf(), @@ -3506,6 +3795,15 @@ private constructor( */ fun username(): String = username.getRequired("username") + /** + * 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 (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + /** * URL used in the Canonical header (if enabled). * @@ -3569,6 +3867,13 @@ private constructor( */ @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username + /** + * 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 [baseUrlForCanonicalHeader]. * @@ -3629,6 +3934,7 @@ private constructor( private var password: JsonField? = null private var type: JsonValue = JsonValue.from("AKENEO_PIM") private var username: JsonField? = null + private var id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3642,6 +3948,7 @@ private constructor( password = akeneoPim.password type = akeneoPim.type username = akeneoPim.username + id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader includeCanonicalHeader = akeneoPim.includeCanonicalHeader additionalProperties = akeneoPim.additionalProperties.toMutableMap() @@ -3735,6 +4042,21 @@ private constructor( */ fun username(username: JsonField) = apply { this.username = username } + /** + * 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 } + /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3810,6 +4132,7 @@ private constructor( checkRequired("password", password), type, checkRequired("username", username), + id, baseUrlForCanonicalHeader, includeCanonicalHeader, additionalProperties.toMutableMap(), @@ -3834,6 +4157,7 @@ private constructor( } } username() + id() baseUrlForCanonicalHeader() includeCanonicalHeader() validated = true @@ -3862,6 +4186,7 @@ private constructor( (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 (id.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) @@ -3878,6 +4203,7 @@ private constructor( password == other.password && type == other.type && username == other.username && + id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties @@ -3892,6 +4218,7 @@ private constructor( password, type, username, + id, baseUrlForCanonicalHeader, includeCanonicalHeader, additionalProperties, @@ -3901,6 +4228,6 @@ private constructor( 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}" + "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, 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 deleted file mode 100644 index 5f8eed29..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt +++ /dev/null @@ -1,3789 +0,0 @@ -// 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/services/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt index 0852af1b..181e4def 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 @@ -6,11 +6,11 @@ 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.Origin 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 @@ -32,20 +32,20 @@ interface OriginServiceAsync { /** * **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ - fun create(params: OriginCreateParams): CompletableFuture = + fun create(params: OriginCreateParams): CompletableFuture = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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 = + fun update(id: String, params: OriginUpdateParams): CompletableFuture = update(id, params, RequestOptions.none()) /** @see update */ @@ -53,37 +53,36 @@ interface OriginServiceAsync { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) + ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: OriginUpdateParams): CompletableFuture = + fun update(params: OriginUpdateParams): CompletableFuture = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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()) + fun list(): CompletableFuture> = list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see list */ - fun list( - params: OriginListParams = OriginListParams.none() - ): CompletableFuture> = list(params, RequestOptions.none()) + fun list(params: OriginListParams = OriginListParams.none()): CompletableFuture> = + list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture> = + fun list(requestOptions: RequestOptions): CompletableFuture> = list(OriginListParams.none(), requestOptions) /** @@ -120,33 +119,32 @@ interface OriginServiceAsync { 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()) + 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) + ): CompletableFuture = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: OriginGetParams = OriginGetParams.none(), - ): CompletableFuture = get(id, params, RequestOptions.none()) + ): CompletableFuture = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see get */ - fun get(params: OriginGetParams): CompletableFuture = - get(params, RequestOptions.none()) + fun get(params: OriginGetParams): CompletableFuture = get(params, RequestOptions.none()) /** @see get */ - fun get(id: String, requestOptions: RequestOptions): CompletableFuture = + fun get(id: String, requestOptions: RequestOptions): CompletableFuture = get(id, OriginGetParams.none(), requestOptions) /** @@ -167,14 +165,14 @@ interface OriginServiceAsync { * Returns a raw HTTP response for `post /v1/accounts/origins`, but is otherwise the same as * [OriginServiceAsync.create]. */ - fun create(params: OriginCreateParams): CompletableFuture> = + fun create(params: OriginCreateParams): CompletableFuture> = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the @@ -183,50 +181,45 @@ interface OriginServiceAsync { fun update( id: String, params: OriginUpdateParams, - ): CompletableFuture> = - update(id, params, RequestOptions.none()) + ): CompletableFuture> = update(id, params, RequestOptions.none()) /** @see update */ fun update( id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: OriginUpdateParams): CompletableFuture> = + fun update(params: OriginUpdateParams): CompletableFuture> = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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()) + fun list(): CompletableFuture>> = list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + ): CompletableFuture>> /** @see list */ fun list( params: OriginListParams = OriginListParams.none() - ): CompletableFuture>> = - list(params, RequestOptions.none()) + ): CompletableFuture>> = list(params, RequestOptions.none()) /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture>> = + fun list(requestOptions: RequestOptions): CompletableFuture>> = list(OriginListParams.none(), requestOptions) /** @@ -268,7 +261,7 @@ interface OriginServiceAsync { * Returns a raw HTTP response for `get /v1/accounts/origins/{id}`, but is otherwise the * same as [OriginServiceAsync.get]. */ - fun get(id: String): CompletableFuture> = + fun get(id: String): CompletableFuture> = get(id, OriginGetParams.none()) /** @see get */ @@ -276,31 +269,30 @@ interface OriginServiceAsync { id: String, params: OriginGetParams = OriginGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: OriginGetParams = OriginGetParams.none(), - ): CompletableFuture> = - get(id, params, RequestOptions.none()) + ): CompletableFuture> = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see get */ - fun get(params: OriginGetParams): CompletableFuture> = + fun get(params: OriginGetParams): CompletableFuture> = get(params, RequestOptions.none()) /** @see get */ fun get( id: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): 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 index 7b9da703..969c544d 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/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt @@ -17,11 +17,11 @@ 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.Origin 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 @@ -42,21 +42,21 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/accounts/origins withRawResponse().create(params, requestOptions).thenApply { it.parse() } override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // put /v1/accounts/origins/{id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = // get /v1/accounts/origins withRawResponse().list(params, requestOptions).thenApply { it.parse() } @@ -70,7 +70,7 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/accounts/origins/{id} withRawResponse().get(params, requestOptions).thenApply { it.parse() } @@ -87,13 +87,12 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -118,13 +117,12 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -152,13 +150,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture>> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -209,13 +207,12 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/main/kotlin/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..72ee79f2 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 @@ -7,11 +7,11 @@ 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.Origin 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 @@ -32,19 +32,19 @@ interface 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()) + fun create(params: OriginCreateParams): Origin = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): OriginResponse + ): Origin /** * **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 = + fun update(id: String, params: OriginUpdateParams): Origin = update(id, params, RequestOptions.none()) /** @see update */ @@ -52,35 +52,35 @@ interface OriginService { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): OriginResponse = update(params.toBuilder().id(id).build(), requestOptions) + ): Origin = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: OriginUpdateParams): OriginResponse = update(params, RequestOptions.none()) + fun update(params: OriginUpdateParams): Origin = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): OriginResponse + ): Origin /** * **Note:** This API is currently in beta. Returns an array of all configured origins for the * current account. */ - fun list(): List = list(OriginListParams.none()) + fun list(): List = list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): List + ): List /** @see list */ - fun list(params: OriginListParams = OriginListParams.none()): List = + fun list(params: OriginListParams = OriginListParams.none()): List = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): List = + fun list(requestOptions: RequestOptions): List = list(OriginListParams.none(), requestOptions) /** @@ -111,30 +111,27 @@ interface OriginService { 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()) + fun get(id: String): Origin = 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) + ): Origin = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ - fun get(id: String, params: OriginGetParams = OriginGetParams.none()): OriginResponse = + fun get(id: String, params: OriginGetParams = OriginGetParams.none()): Origin = get(id, params, RequestOptions.none()) /** @see get */ - fun get( - params: OriginGetParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): OriginResponse + fun get(params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none()): Origin /** @see get */ - fun get(params: OriginGetParams): OriginResponse = get(params, RequestOptions.none()) + fun get(params: OriginGetParams): Origin = get(params, RequestOptions.none()) /** @see get */ - fun get(id: String, requestOptions: RequestOptions): OriginResponse = + fun get(id: String, requestOptions: RequestOptions): Origin = get(id, OriginGetParams.none(), requestOptions) /** A view of [OriginService] that provides access to raw HTTP responses for each method. */ @@ -152,7 +149,7 @@ interface OriginService { * [OriginService.create]. */ @MustBeClosed - fun create(params: OriginCreateParams): HttpResponseFor = + fun create(params: OriginCreateParams): HttpResponseFor = create(params, RequestOptions.none()) /** @see create */ @@ -160,14 +157,14 @@ interface OriginService { fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun update(id: String, params: OriginUpdateParams): HttpResponseFor = update(id, params, RequestOptions.none()) /** @see update */ @@ -176,12 +173,11 @@ interface OriginService { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - update(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ @MustBeClosed - fun update(params: OriginUpdateParams): HttpResponseFor = + fun update(params: OriginUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) /** @see update */ @@ -189,31 +185,30 @@ interface OriginService { fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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()) + @MustBeClosed fun list(): HttpResponseFor> = list(OriginListParams.none()) /** @see list */ @MustBeClosed fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + ): HttpResponseFor> /** @see list */ @MustBeClosed fun list( params: OriginListParams = OriginListParams.none() - ): HttpResponseFor> = list(params, RequestOptions.none()) + ): HttpResponseFor> = list(params, RequestOptions.none()) /** @see list */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor> = + fun list(requestOptions: RequestOptions): HttpResponseFor> = list(OriginListParams.none(), requestOptions) /** @@ -257,8 +252,7 @@ interface OriginService { * 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()) + @MustBeClosed fun get(id: String): HttpResponseFor = get(id, OriginGetParams.none()) /** @see get */ @MustBeClosed @@ -266,30 +260,30 @@ interface OriginService { id: String, params: OriginGetParams = OriginGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = get(params.toBuilder().id(id).build(), requestOptions) + ): 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()) + ): HttpResponseFor = get(id, params, RequestOptions.none()) /** @see get */ @MustBeClosed fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see get */ @MustBeClosed - fun get(params: OriginGetParams): HttpResponseFor = + fun get(params: OriginGetParams): HttpResponseFor = get(params, RequestOptions.none()) /** @see get */ @MustBeClosed - fun get(id: String, requestOptions: RequestOptions): HttpResponseFor = + 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 index bbbd6358..ea913424 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/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt @@ -17,11 +17,11 @@ 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.Origin 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 @@ -38,24 +38,15 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): OriginService = OriginServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: OriginCreateParams, - requestOptions: RequestOptions, - ): OriginResponse = + override fun create(params: OriginCreateParams, requestOptions: RequestOptions): Origin = // post /v1/accounts/origins withRawResponse().create(params, requestOptions).parse() - override fun update( - params: OriginUpdateParams, - requestOptions: RequestOptions, - ): OriginResponse = + override fun update(params: OriginUpdateParams, requestOptions: RequestOptions): Origin = // put /v1/accounts/origins/{id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: OriginListParams, - requestOptions: RequestOptions, - ): List = + override fun list(params: OriginListParams, requestOptions: RequestOptions): List = // get /v1/accounts/origins withRawResponse().list(params, requestOptions).parse() @@ -64,7 +55,7 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp withRawResponse().delete(params, requestOptions) } - override fun get(params: OriginGetParams, requestOptions: RequestOptions): OriginResponse = + override fun get(params: OriginGetParams, requestOptions: RequestOptions): Origin = // get /v1/accounts/origins/{id} withRawResponse().get(params, requestOptions).parse() @@ -81,13 +72,12 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -109,13 +99,12 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -140,13 +129,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -191,13 +180,12 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/test/kotlin/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 6a10effe..253d8d7e 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 @@ -12,10 +12,9 @@ internal class OriginCreateParamsTest { OriginCreateParams.builder() .origin( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -30,10 +29,9 @@ internal class OriginCreateParamsTest { OriginCreateParams.builder() .origin( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -47,10 +45,9 @@ internal class OriginCreateParamsTest { .isEqualTo( Origin.ofS3( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -63,28 +60,14 @@ internal class OriginCreateParamsTest { fun bodyWithoutOptionalFields() { val params = OriginCreateParams.builder() - .origin( - Origin.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .build() - ) + .origin(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) .build() val body = params._body() assertThat(body) .isEqualTo( - Origin.ofS3( - Origin.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .build() - ) + Origin.ofS3(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) ) } } 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 deleted file mode 100644 index da0a3935..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt +++ /dev/null @@ -1,420 +0,0 @@ -// 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/OriginTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt index 3e702b59..8ab5df13 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt @@ -18,10 +18,9 @@ internal class OriginTest { fun ofS3() { val s3 = Origin.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("raw-assets") @@ -45,10 +44,9 @@ internal class OriginTest { val origin = Origin.ofS3( Origin.S3.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("raw-assets") @@ -65,11 +63,10 @@ internal class OriginTest { fun ofS3Compatible() { val s3Compatible = Origin.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("raw-assets") @@ -94,11 +91,10 @@ internal class OriginTest { val origin = Origin.ofS3Compatible( Origin.S3Compatible.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .endpoint("https://s3.eu-central-1.wasabisys.com") .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("raw-assets") @@ -116,10 +112,9 @@ internal class OriginTest { fun ofCloudinaryBackup() { val cloudinaryBackup = Origin.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("raw-assets") @@ -143,10 +138,9 @@ internal class OriginTest { val origin = Origin.ofCloudinaryBackup( Origin.CloudinaryBackup.builder() - .accessKey("AKIAIOSFODNN7EXAMPLE") .bucket("product-images") .name("US S3 Storage") - .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("raw-assets") @@ -165,6 +159,7 @@ internal class OriginTest { Origin.WebFolder.builder() .baseUrl("https://images.example.com/assets") .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) @@ -190,6 +185,7 @@ internal class OriginTest { Origin.WebFolder.builder() .baseUrl("https://images.example.com/assets") .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .forwardHostHeaderToOrigin(false) .includeCanonicalHeader(false) @@ -207,6 +203,7 @@ internal class OriginTest { val webProxy = Origin.WebProxy.builder() .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .build() @@ -230,6 +227,7 @@ internal class OriginTest { Origin.ofWebProxy( Origin.WebProxy.builder() .name("US S3 Storage") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .build() @@ -248,7 +246,7 @@ internal class OriginTest { .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("products") @@ -275,7 +273,7 @@ internal class OriginTest { .bucket("gcs-media") .clientEmail("service-account@project.iam.gserviceaccount.com") .name("US S3 Storage") - .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("products") @@ -295,7 +293,7 @@ internal class OriginTest { .accountName("account123") .container("images") .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("uploads") @@ -322,7 +320,7 @@ internal class OriginTest { .accountName("account123") .container("images") .name("US S3 Storage") - .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("uploads") @@ -340,11 +338,8 @@ internal class OriginTest { val akeneoPim = Origin.AkeneoPim.builder() .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .build() @@ -368,11 +363,8 @@ internal class OriginTest { Origin.ofAkeneoPim( Origin.AkeneoPim.builder() .baseUrl("https://akeneo.company.com") - .clientId("akeneo-client-id") - .clientSecret("akeneo-client-secret") .name("US S3 Storage") - .password("strongpassword123") - .username("integration-user") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .build() 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 f7bc6d19..3b1e46db 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 @@ -13,10 +13,9 @@ internal class OriginUpdateParamsTest { .id("id") .origin( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -30,14 +29,7 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .origin( - Origin.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .build() - ) + .origin(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) .build() assertThat(params._pathParam(0)).isEqualTo("id") @@ -52,10 +44,9 @@ internal class OriginUpdateParamsTest { .id("id") .origin( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -69,10 +60,9 @@ internal class OriginUpdateParamsTest { .isEqualTo( Origin.ofS3( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -86,28 +76,14 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .origin( - Origin.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .build() - ) + .origin(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) .build() val body = params._body() assertThat(body) .isEqualTo( - Origin.ofS3( - Origin.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .build() - ) + Origin.ofS3(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").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 f564bc59..478b8e42 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 @@ -25,15 +25,14 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originResponseFuture = + val originFuture = originServiceAsync.create( OriginCreateParams.builder() .origin( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -42,8 +41,8 @@ internal class OriginServiceAsyncTest { .build() ) - val originResponse = originResponseFuture.get() - originResponse.validate() + val origin = originFuture.get() + origin.validate() } @Disabled("Prism tests are disabled") @@ -57,16 +56,15 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originResponseFuture = + val originFuture = originServiceAsync.update( OriginUpdateParams.builder() .id("id") .origin( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -75,8 +73,8 @@ internal class OriginServiceAsyncTest { .build() ) - val originResponse = originResponseFuture.get() - originResponse.validate() + val origin = originFuture.get() + origin.validate() } @Disabled("Prism tests are disabled") @@ -90,10 +88,10 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originResponsesFuture = originServiceAsync.list() + val originsFuture = originServiceAsync.list() - val originResponses = originResponsesFuture.get() - originResponses.forEach { it.validate() } + val origins = originsFuture.get() + origins.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -123,9 +121,9 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originResponseFuture = originServiceAsync.get("id") + val originFuture = originServiceAsync.get("id") - val originResponse = originResponseFuture.get() - originResponse.validate() + val origin = originFuture.get() + origin.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 index 75d18afe..7122c049 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 @@ -25,15 +25,14 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val originResponse = + val origin = originService.create( OriginCreateParams.builder() .origin( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -42,7 +41,7 @@ internal class OriginServiceTest { .build() ) - originResponse.validate() + origin.validate() } @Disabled("Prism tests are disabled") @@ -56,16 +55,15 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val originResponse = + val origin = originService.update( OriginUpdateParams.builder() .id("id") .origin( Origin.S3.builder() - .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .secretKey("secrettest123") + .id("id") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -74,7 +72,7 @@ internal class OriginServiceTest { .build() ) - originResponse.validate() + origin.validate() } @Disabled("Prism tests are disabled") @@ -88,9 +86,9 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val originResponses = originService.list() + val origins = originService.list() - originResponses.forEach { it.validate() } + origins.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -118,8 +116,8 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val originResponse = originService.get("id") + val origin = originService.get("id") - originResponse.validate() + origin.validate() } } From 6f05045644acb3e9a66deb16015b929e37d248ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 06:13:47 +0000 Subject: [PATCH 052/125] feat(api): manual updates --- .stats.yml | 6 +- .../accounts/origins/OriginCreateParams.kt | 4016 ++++++++++++++++- .../origins/{Origin.kt => OriginResponse.kt} | 2278 ++++------ .../accounts/origins/OriginUpdateParams.kt | 4014 +++++++++++++++- .../async/accounts/OriginServiceAsync.kt | 76 +- .../async/accounts/OriginServiceAsyncImpl.kt | 31 +- .../blocking/accounts/OriginService.kt | 72 +- .../blocking/accounts/OriginServiceImpl.kt | 40 +- .../origins/OriginCreateParamsTest.kt | 35 +- .../accounts/origins/OriginResponseTest.kt | 420 ++ .../api/models/accounts/origins/OriginTest.kt | 395 -- .../origins/OriginUpdateParamsTest.kt | 44 +- .../async/accounts/OriginServiceAsyncTest.kt | 35 +- .../blocking/accounts/OriginServiceTest.kt | 27 +- 14 files changed, 9582 insertions(+), 1907 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/{Origin.kt => OriginResponse.kt} (81%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt diff --git a/.stats.yml b/.stats.yml index 6ac1eba7..8a42af3a 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-554f897c7f0061bb1fe51cd82f5f05e66050db5e868524c374dac827bd7b8c3d.yml -openapi_spec_hash: 95b7298e7f3977ea6c98d9557d2c8d27 -config_hash: 49e367d7f33aeaf63ed738c1c0392d0a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-fa82106bb6313906d2eaac167e0ca5f60f12a166c743c00a18c22be0e455c1b6.yml +openapi_spec_hash: 8ff6fc6886e8d7a9eee6d45d51e9673c +config_hash: 76b94bb341141f0e9b14cdbb1203b0fa 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 71bcb378..99d337f1 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 @@ -2,11 +2,33 @@ 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.Params 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.errors.ImageKitInvalidDataException +import java.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams @@ -16,7 +38,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Schema for origin resources. */ + /** Schema for origin request resources. */ fun origin(): Origin = origin /** Additional headers to send with the request. */ @@ -54,7 +76,7 @@ private constructor( additionalQueryParams = originCreateParams.additionalQueryParams.toBuilder() } - /** Schema for origin resources. */ + /** Schema for origin request resources. */ fun origin(origin: Origin) = apply { this.origin = origin } /** Alias for calling [origin] with `Origin.ofS3(s3)`. */ @@ -216,6 +238,3996 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + /** Schema for origin request resources. */ + @JsonDeserialize(using = Origin.Deserializer::class) + @JsonSerialize(using = Origin.Serializer::class) + class Origin + 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(): Origin = 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 Origin && + 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 -> "Origin{s3=$s3}" + s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "Origin{webFolder=$webFolder}" + webProxy != null -> "Origin{webProxy=$webProxy}" + gcs != null -> "Origin{gcs=$gcs}" + azureBlob != null -> "Origin{azureBlob=$azureBlob}" + akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" + _json != null -> "Origin{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Origin") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + Origin(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) + + @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) + + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) + } + + /** An interface that defines how to map each variant of [Origin] 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 [Origin] to a value of type [T]. + * + * An instance of [Origin] 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 Origin: $json") + } + } + + internal class Deserializer : BaseDeserializer(Origin::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Origin { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3 = it, _json = json) + } ?: Origin(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3Compatible = it, _json = json) + } ?: Origin(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(cloudinaryBackup = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webFolder = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webProxy = it, _json = json) + } ?: Origin(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(gcs = it, _json = json) + } ?: Origin(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(azureBlob = it, _json = json) + } ?: Origin(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(akeneoPim = it, _json = json) + } ?: Origin(_json = json) + } + } + + return Origin(_json = json) + } + } + + internal class Serializer : BaseSerializer(Origin::class) { + + override fun serialize( + value: Origin, + 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 Origin") + } + } + } + + 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}" + } + } + 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/accounts/origins/Origin.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt index 504b58db..5f8eed29 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/Origin.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt @@ -27,10 +27,10 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Schema for origin resources. */ -@JsonDeserialize(using = Origin.Deserializer::class) -@JsonSerialize(using = Origin.Serializer::class) -class Origin +/** 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, @@ -108,7 +108,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { + fun validate(): OriginResponse = apply { if (validated) { return@apply } @@ -194,7 +194,7 @@ private constructor( return true } - return other is Origin && + return other is OriginResponse && s3 == other.s3 && s3Compatible == other.s3Compatible && cloudinaryBackup == other.cloudinaryBackup && @@ -219,41 +219,43 @@ private constructor( override fun toString(): String = when { - s3 != null -> "Origin{s3=$s3}" - s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "Origin{webFolder=$webFolder}" - webProxy != null -> "Origin{webProxy=$webProxy}" - gcs != null -> "Origin{gcs=$gcs}" - azureBlob != null -> "Origin{azureBlob=$azureBlob}" - akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" - _json != null -> "Origin{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Origin") + 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) = Origin(s3 = s3) + @JvmStatic fun ofS3(s3: S3) = OriginResponse(s3 = s3) @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) + fun ofS3Compatible(s3Compatible: S3Compatible) = OriginResponse(s3Compatible = s3Compatible) @JvmStatic fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - Origin(cloudinaryBackup = cloudinaryBackup) + OriginResponse(cloudinaryBackup = cloudinaryBackup) - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = OriginResponse(webFolder = webFolder) - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginResponse(webProxy = webProxy) - @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) + @JvmStatic fun ofGcs(gcs: Gcs) = OriginResponse(gcs = gcs) - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginResponse(azureBlob = azureBlob) - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginResponse(akeneoPim = akeneoPim) } - /** An interface that defines how to map each variant of [Origin] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [OriginResponse] to a value of type [T]. + */ interface Visitor { fun visitS3(s3: S3): T @@ -273,76 +275,77 @@ private constructor( fun visitAkeneoPim(akeneoPim: AkeneoPim): T /** - * Maps an unknown variant of [Origin] to a value of type [T]. + * Maps an unknown variant of [OriginResponse] to a value of type [T]. * - * An instance of [Origin] 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 [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 Origin: $json") + throw ImageKitInvalidDataException("Unknown OriginResponse: $json") } } - internal class Deserializer : BaseDeserializer(Origin::class) { + internal class Deserializer : BaseDeserializer(OriginResponse::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Origin { + 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 { - Origin(s3 = it, _json = json) - } ?: Origin(_json = json) + OriginResponse(s3 = it, _json = json) + } ?: OriginResponse(_json = json) } "S3_COMPATIBLE" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3Compatible = it, _json = json) - } ?: Origin(_json = json) + OriginResponse(s3Compatible = it, _json = json) + } ?: OriginResponse(_json = json) } "CLOUDINARY_BACKUP" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(cloudinaryBackup = it, _json = json) - } ?: Origin(_json = json) + OriginResponse(cloudinaryBackup = it, _json = json) + } ?: OriginResponse(_json = json) } "WEB_FOLDER" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webFolder = it, _json = json) - } ?: Origin(_json = json) + OriginResponse(webFolder = it, _json = json) + } ?: OriginResponse(_json = json) } "WEB_PROXY" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webProxy = it, _json = json) - } ?: Origin(_json = json) + OriginResponse(webProxy = it, _json = json) + } ?: OriginResponse(_json = json) } "GCS" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(gcs = it, _json = json) - } ?: Origin(_json = json) + OriginResponse(gcs = it, _json = json) + } ?: OriginResponse(_json = json) } "AZURE_BLOB" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(azureBlob = it, _json = json) - } ?: Origin(_json = json) + OriginResponse(azureBlob = it, _json = json) + } ?: OriginResponse(_json = json) } "AKENEO_PIM" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(akeneoPim = it, _json = json) - } ?: Origin(_json = json) + OriginResponse(akeneoPim = it, _json = json) + } ?: OriginResponse(_json = json) } } - return Origin(_json = json) + return OriginResponse(_json = json) } } - internal class Serializer : BaseSerializer(Origin::class) { + internal class Serializer : BaseSerializer(OriginResponse::class) { override fun serialize( - value: Origin, + value: OriginResponse, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -356,64 +359,55 @@ private constructor( 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 Origin") + else -> throw IllegalStateException("Invalid OriginResponse") } } } class S3 private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -423,6 +417,15 @@ private constructor( */ 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. * @@ -432,12 +435,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -450,15 +453,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * 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 (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - /** * URL used in the Canonical header (if enabled). * @@ -469,28 +463,11 @@ private constructor( 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]. + * Returns the raw JSON value of [id]. * - * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -500,25 +477,28 @@ private constructor( @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [secretKey]. + * Returns the raw JSON value of [name]. * - * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -530,23 +510,6 @@ private constructor( @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) @@ -566,10 +529,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -578,42 +542,41 @@ private constructor( /** A builder for [S3]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("S3") - private var id: JsonField = JsonMissing.of() 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 + id = s3.id bucket = s3.bucket + includeCanonicalHeader = s3.includeCanonicalHeader name = s3.name - secretKey = s3.secretKey + prefix = s3.prefix type = s3.type - id = s3.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -627,6 +590,21 @@ private constructor( */ 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)) @@ -639,17 +617,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -665,21 +643,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** - * 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -695,33 +658,6 @@ private constructor( 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) @@ -748,25 +684,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3 = S3( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -778,19 +713,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("S3")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -810,15 +743,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -826,29 +757,25 @@ private constructor( } return other is S3 && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -856,72 +783,63 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "S3{id=$id, bucket=$bucket, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" } class S3Compatible private constructor( - private val accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, private val endpoint: JsonField, - private val name: JsonField, - private val secretKey: JsonField, - private val type: JsonValue, - private val id: JsonField, - private val baseUrlForCanonicalHeader: 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("accessKey") - @ExcludeMissing - accessKey: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -939,6 +857,15 @@ private constructor( */ 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. * @@ -948,12 +875,20 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") /** * Expected to always return the following: @@ -966,15 +901,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * 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 (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - /** * URL used in the Canonical header (if enabled). * @@ -985,36 +911,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -1030,37 +931,6 @@ private constructor( */ @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 [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 [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]. * @@ -1071,6 +941,13 @@ private constructor( @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]. * @@ -1088,6 +965,16 @@ private constructor( @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) @@ -1107,11 +994,13 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` */ @JvmStatic fun builder() = Builder() @@ -1120,46 +1009,45 @@ private constructor( /** A builder for [S3Compatible]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + 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 secretKey: JsonField? = null + private var prefix: JsonField? = null + private var s3ForcePathStyle: JsonField? = null private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") - private var id: JsonField = JsonMissing.of() 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 + id = s3Compatible.id bucket = s3Compatible.bucket endpoint = s3Compatible.endpoint - name = s3Compatible.name - secretKey = s3Compatible.secretKey - type = s3Compatible.type - id = s3Compatible.id - baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader includeCanonicalHeader = s3Compatible.includeCanonicalHeader + name = s3Compatible.name prefix = s3Compatible.prefix s3ForcePathStyle = s3Compatible.s3ForcePathStyle + type = s3Compatible.type + baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader additionalProperties = s3Compatible.additionalProperties.toMutableMap() } - /** Access key for the bucket. */ - fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1185,6 +1073,21 @@ private constructor( */ 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)) @@ -1197,17 +1100,32 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + 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. @@ -1223,21 +1141,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** - * 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1253,48 +1156,6 @@ private constructor( 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) @@ -1321,28 +1182,28 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() * .endpoint() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() + * .s3ForcePathStyle() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): S3Compatible = S3Compatible( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), checkRequired("endpoint", endpoint), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), + checkRequired("s3ForcePathStyle", s3ForcePathStyle), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, - s3ForcePathStyle, additionalProperties.toMutableMap(), ) } @@ -1354,21 +1215,19 @@ private constructor( return@apply } - accessKey() + id() bucket() endpoint() + includeCanonicalHeader() name() - secretKey() + prefix() + s3ForcePathStyle() _type().let { if (it != JsonValue.from("S3_COMPATIBLE")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() - s3ForcePathStyle() validated = true } @@ -1388,17 +1247,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (if (id.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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.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) + (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) { @@ -1406,33 +1263,29 @@ private constructor( } return other is S3Compatible && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && endpoint == other.endpoint && - name == other.name && - secretKey == other.secretKey && - type == other.type && - id == other.id && - baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && 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( - accessKey, + id, bucket, endpoint, - name, - secretKey, - type, - id, - baseUrlForCanonicalHeader, includeCanonicalHeader, + name, prefix, s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, additionalProperties, ) } @@ -1440,62 +1293,53 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" + "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 accessKey: JsonField, + private val id: JsonField, private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val secretKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("secretKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - secretKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = 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, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, mutableMapOf(), ) /** - * Access key for the bucket. + * 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 accessKey(): String = accessKey.getRequired("accessKey") + fun id(): String = id.getRequired("id") /** * S3 bucket name. @@ -1505,6 +1349,15 @@ private constructor( */ 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. * @@ -1514,12 +1367,12 @@ private constructor( fun name(): String = name.getRequired("name") /** - * Secret key for the bucket. + * 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 secretKey(): String = secretKey.getRequired("secretKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -1532,15 +1385,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * 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 (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - /** * URL used in the Canonical header (if enabled). * @@ -1551,35 +1395,28 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Path prefix inside the bucket. + * Returns the raw JSON value of [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. + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket /** - * Returns the raw JSON value of [bucket]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [name]. @@ -1589,18 +1426,11 @@ private constructor( @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 [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -1612,23 +1442,6 @@ private constructor( @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) @@ -1648,10 +1461,11 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -1660,42 +1474,41 @@ private constructor( /** A builder for [CloudinaryBackup]. */ class Builder internal constructor() { - private var accessKey: JsonField? = null + private var id: JsonField? = null private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null private var name: JsonField? = null - private var secretKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") - private var id: JsonField = JsonMissing.of() 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 + id = cloudinaryBackup.id bucket = cloudinaryBackup.bucket + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader name = cloudinaryBackup.name - secretKey = cloudinaryBackup.secretKey + prefix = cloudinaryBackup.prefix type = cloudinaryBackup.type - id = cloudinaryBackup.id 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)) + /** + * 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.accessKey] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + fun id(id: JsonField) = apply { this.id = id } /** S3 bucket name. */ fun bucket(bucket: String) = bucket(JsonField.of(bucket)) @@ -1709,6 +1522,21 @@ private constructor( */ 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)) @@ -1721,17 +1549,17 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Secret key for the bucket. */ - fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.secretKey] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * 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 secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -1747,21 +1575,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** - * 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -1777,33 +1590,6 @@ private constructor( 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) @@ -1830,25 +1616,24 @@ private constructor( * * The following fields are required: * ```java - * .accessKey() + * .id() * .bucket() + * .includeCanonicalHeader() * .name() - * .secretKey() + * .prefix() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): CloudinaryBackup = CloudinaryBackup( - checkRequired("accessKey", accessKey), + checkRequired("id", id), checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("secretKey", secretKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -1860,19 +1645,17 @@ private constructor( return@apply } - accessKey() + id() bucket() + includeCanonicalHeader() name() - secretKey() + prefix() _type().let { if (it != JsonValue.from("CLOUDINARY_BACKUP")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -1892,15 +1675,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accessKey.asKnown().isPresent) 1 else 0) + + (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 (secretKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1908,29 +1689,25 @@ private constructor( } return other is CloudinaryBackup && - accessKey == other.accessKey && + id == other.id && bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - secretKey == other.secretKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - accessKey, + id, bucket, + includeCanonicalHeader, name, - secretKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -1938,47 +1715,56 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 id: JsonField, 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - baseUrlForCanonicalHeader: 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, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, 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. * @@ -1987,6 +1773,24 @@ private constructor( */ 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. * @@ -2006,15 +1810,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * 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 (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - /** * URL used in the Canonical header (if enabled). * @@ -2024,38 +1819,6 @@ private constructor( 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 [id]. * @@ -2064,14 +1827,11 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [baseUrl]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") - @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl /** * Returns the raw JSON value of [forwardHostHeaderToOrigin]. @@ -2093,6 +1853,23 @@ private constructor( @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) @@ -2112,7 +1889,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2122,27 +1902,42 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() 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 { + id = webFolder.id baseUrl = webFolder.baseUrl + forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolder.includeCanonicalHeader name = webFolder.name type = webFolder.type - id = webFolder.id baseUrlForCanonicalHeader = webFolder.baseUrlForCanonicalHeader - forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin - includeCanonicalHeader = webFolder.includeCanonicalHeader 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)) @@ -2155,6 +1950,36 @@ private constructor( */ 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)) @@ -2181,21 +2006,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** - * 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2205,40 +2015,10 @@ private constructor( * * 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. + * undocumented or not yet supported value. */ - fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { - this.includeCanonicalHeader = includeCanonicalHeader + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader } fun additionalProperties(additionalProperties: Map) = apply { @@ -2267,7 +2047,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() * .name() * ``` * @@ -2275,13 +2058,13 @@ private constructor( */ fun build(): WebFolder = WebFolder( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), + checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2293,17 +2076,17 @@ private constructor( return@apply } + id() baseUrl() + forwardHostHeaderToOrigin() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_FOLDER")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - forwardHostHeaderToOrigin() - includeCanonicalHeader() validated = true } @@ -2323,13 +2106,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (baseUrl.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2337,25 +2120,25 @@ private constructor( } return other is WebFolder && + id == other.id && baseUrl == other.baseUrl && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - forwardHostHeaderToOrigin, - includeCanonicalHeader, additionalProperties, ) } @@ -2363,31 +2146,49 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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 id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - ) : this(name, type, id, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) + ) : 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. @@ -2408,15 +2209,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * 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 (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - /** * URL used in the Canonical header (if enabled). * @@ -2427,27 +2219,28 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [name]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -2459,16 +2252,6 @@ private constructor( @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) @@ -2488,6 +2271,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` */ @@ -2497,23 +2282,53 @@ private constructor( /** 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: 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 - id = webProxy.id baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader - includeCanonicalHeader = webProxy.includeCanonicalHeader 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)) @@ -2540,21 +2355,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** - * 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -2570,21 +2370,6 @@ private constructor( 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) @@ -2611,6 +2396,8 @@ private constructor( * * The following fields are required: * ```java + * .id() + * .includeCanonicalHeader() * .name() * ``` * @@ -2618,11 +2405,11 @@ private constructor( */ fun build(): WebProxy = WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -2634,15 +2421,15 @@ private constructor( return@apply } + id() + includeCanonicalHeader() name() _type().let { if (it != JsonValue.from("WEB_PROXY")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -2662,11 +2449,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + + (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2674,21 +2461,21 @@ private constructor( } return other is WebProxy && + id == other.id && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, + includeCanonicalHeader, name, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -2696,55 +2483,59 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "WebProxy{name=$name, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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 privateKey: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("privateKey") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - privateKey: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -2757,6 +2548,15 @@ private constructor( */ 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. * @@ -2769,7 +2569,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 privateKey(): String = privateKey.getRequired("privateKey") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -2782,15 +2582,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * 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 (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - /** * URL used in the Canonical header (if enabled). * @@ -2801,19 +2592,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [bucket]. @@ -2823,46 +2606,13 @@ private constructor( @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 [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 [baseUrlForCanonicalHeader]. + * Returns the raw JSON value of [clientEmail]. * - * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [clientEmail], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("baseUrlForCanonicalHeader") + @JsonProperty("clientEmail") @ExcludeMissing - fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + fun _clientEmail(): JsonField = clientEmail /** * Returns the raw JSON value of [includeCanonicalHeader]. @@ -2874,6 +2624,13 @@ private constructor( @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]. * @@ -2881,6 +2638,16 @@ private constructor( */ @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) @@ -2900,10 +2667,12 @@ private constructor( * * The following fields are required: * ```java + * .id() * .bucket() * .clientEmail() + * .includeCanonicalHeader() * .name() - * .privateKey() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -2912,31 +2681,44 @@ private constructor( /** 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 privateKey: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("GCS") - private var id: JsonField = JsonMissing.of() 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 { + id = gcs.id bucket = gcs.bucket clientEmail = gcs.clientEmail + includeCanonicalHeader = gcs.includeCanonicalHeader name = gcs.name - privateKey = gcs.privateKey + prefix = gcs.prefix type = gcs.type - id = gcs.id baseUrlForCanonicalHeader = gcs.baseUrlForCanonicalHeader - includeCanonicalHeader = gcs.includeCanonicalHeader - prefix = gcs.prefix 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)) /** @@ -2961,6 +2743,21 @@ private constructor( 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)) @@ -2973,16 +2770,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.privateKey] to an arbitrary JSON value. + * Sets [Builder.prefix] 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 + * 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 privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -2998,21 +2795,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** - * 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3028,32 +2810,6 @@ private constructor( 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) @@ -3080,25 +2836,26 @@ private constructor( * * The following fields are required: * ```java + * .id() * .bucket() * .clientEmail() + * .includeCanonicalHeader() * .name() - * .privateKey() + * .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("privateKey", privateKey), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -3110,19 +2867,18 @@ private constructor( return@apply } + id() bucket() clientEmail() + includeCanonicalHeader() name() - privateKey() + prefix() _type().let { if (it != JsonValue.from("GCS")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3142,15 +2898,14 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (bucket.asKnown().isPresent) 1 else 0) + + (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 (privateKey.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("GCS")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -3158,29 +2913,27 @@ private constructor( } return other is Gcs && + id == other.id && bucket == other.bucket && clientEmail == other.clientEmail && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - privateKey == other.privateKey && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, bucket, clientEmail, + includeCanonicalHeader, name, - privateKey, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3188,57 +2941,61 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Gcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 sasToken: JsonField, + private val prefix: JsonField, private val type: JsonValue, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, - private val prefix: 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("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("sasToken") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - sasToken: JsonField = JsonMissing.of(), + 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), ) : this( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, 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). @@ -3251,6 +3008,15 @@ private constructor( */ 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. * @@ -3263,7 +3029,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 sasToken(): String = sasToken.getRequired("sasToken") + fun prefix(): String = prefix.getRequired("prefix") /** * Expected to always return the following: @@ -3276,15 +3042,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * 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 (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - /** * URL used in the Canonical header (if enabled). * @@ -3295,19 +3052,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @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). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun prefix(): Optional = prefix.getOptional("prefix") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [accountName]. @@ -3326,25 +3075,28 @@ private constructor( @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** - * Returns the raw JSON value of [sasToken]. + * Returns the raw JSON value of [name]. * - * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [prefix]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix /** * Returns the raw JSON value of [baseUrlForCanonicalHeader]. @@ -3356,23 +3108,6 @@ private constructor( @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) @@ -3392,10 +3127,12 @@ private constructor( * * The following fields are required: * ```java + * .id() * .accountName() * .container() + * .includeCanonicalHeader() * .name() - * .sasToken() + * .prefix() * ``` */ @JvmStatic fun builder() = Builder() @@ -3404,31 +3141,44 @@ private constructor( /** 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 sasToken: JsonField? = null + private var prefix: JsonField? = null private var type: JsonValue = JsonValue.from("AZURE_BLOB") - private var id: JsonField = JsonMissing.of() 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 { + id = azureBlob.id accountName = azureBlob.accountName container = azureBlob.container + includeCanonicalHeader = azureBlob.includeCanonicalHeader name = azureBlob.name - sasToken = azureBlob.sasToken + prefix = azureBlob.prefix type = azureBlob.type - id = azureBlob.id baseUrlForCanonicalHeader = azureBlob.baseUrlForCanonicalHeader - includeCanonicalHeader = azureBlob.includeCanonicalHeader - prefix = azureBlob.prefix 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)) /** @@ -3447,11 +3197,26 @@ private constructor( /** * 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. + * 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 container(container: JsonField) = apply { this.container = container } + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } /** Display name of the origin. */ fun name(name: String) = name(JsonField.of(name)) @@ -3465,16 +3230,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) /** - * Sets [Builder.sasToken] to an arbitrary JSON value. + * Sets [Builder.prefix] to an arbitrary JSON value. * - * You should usually call [Builder.sasToken] with a well-typed [String] value instead. + * 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 sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } /** * Sets the field to an arbitrary JSON value. @@ -3490,21 +3255,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** - * 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -3520,32 +3270,6 @@ private constructor( 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) @@ -3572,25 +3296,26 @@ private constructor( * * The following fields are required: * ```java + * .id() * .accountName() * .container() + * .includeCanonicalHeader() * .name() - * .sasToken() + * .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("sasToken", sasToken), + checkRequired("prefix", prefix), type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties.toMutableMap(), ) } @@ -3602,19 +3327,18 @@ private constructor( return@apply } + id() accountName() container() + includeCanonicalHeader() name() - sasToken() + prefix() _type().let { if (it != JsonValue.from("AZURE_BLOB")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() - prefix() validated = true } @@ -3634,15 +3358,14 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (accountName.asKnown().isPresent) 1 else 0) + + (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 (sasToken.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("AZURE_BLOB")) 1 else 0 } + - (if (id.asKnown().isPresent) 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 (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -3650,29 +3373,27 @@ private constructor( } return other is AzureBlob && + id == other.id && accountName == other.accountName && container == other.container && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - sasToken == other.sasToken && + prefix == other.prefix && type == other.type && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && - prefix == other.prefix && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, accountName, container, + includeCanonicalHeader, name, - sasToken, + prefix, type, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, - prefix, additionalProperties, ) } @@ -3680,85 +3401,67 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AzureBlob{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + "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 clientId: JsonField, - private val clientSecret: JsonField, + private val includeCanonicalHeader: JsonField, private val name: JsonField, - private val password: JsonField, private val type: JsonValue, - private val username: JsonField, - private val id: JsonField, private val baseUrlForCanonicalHeader: JsonField, - private val includeCanonicalHeader: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), - @JsonProperty("clientId") - @ExcludeMissing - clientId: JsonField = JsonMissing.of(), - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - clientSecret: JsonField = JsonMissing.of(), + includeCanonicalHeader: 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("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("baseUrlForCanonicalHeader") @ExcludeMissing baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), - @JsonProperty("includeCanonicalHeader") - @ExcludeMissing - includeCanonicalHeader: JsonField = JsonMissing.of(), ) : this( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, mutableMapOf(), ) /** - * Akeneo instance base URL. + * 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 baseUrl(): String = baseUrl.getRequired("baseUrl") + fun id(): String = id.getRequired("id") /** - * Akeneo API client 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 clientId(): String = clientId.getRequired("clientId") + fun baseUrl(): String = baseUrl.getRequired("baseUrl") /** - * Akeneo API client secret. + * 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 clientSecret(): String = clientSecret.getRequired("clientSecret") + fun includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") /** * Display name of the origin. @@ -3768,14 +3471,6 @@ private constructor( */ 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 @@ -3787,23 +3482,6 @@ private constructor( */ @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") - - /** - * 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 (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - /** * URL used in the Canonical header (if enabled). * @@ -3814,13 +3492,11 @@ private constructor( baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") /** - * Whether to send a Canonical header. + * Returns the raw JSON value of [id]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (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. */ - fun includeCanonicalHeader(): Optional = - includeCanonicalHeader.getOptional("includeCanonicalHeader") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Returns the raw JSON value of [baseUrl]. @@ -3830,21 +3506,14 @@ private constructor( @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]. + * Returns the raw JSON value of [includeCanonicalHeader]. * - * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. */ - @JsonProperty("clientSecret") + @JsonProperty("includeCanonicalHeader") @ExcludeMissing - fun _clientSecret(): JsonField = clientSecret + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader /** * Returns the raw JSON value of [name]. @@ -3853,27 +3522,6 @@ private constructor( */ @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 [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 [baseUrlForCanonicalHeader]. * @@ -3884,16 +3532,6 @@ private constructor( @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) @@ -3913,12 +3551,10 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -3927,69 +3563,65 @@ private constructor( /** A builder for [AkeneoPim]. */ class Builder internal constructor() { + private var id: JsonField? = null private var baseUrl: JsonField? = null - private var clientId: JsonField? = null - private var clientSecret: JsonField? = null + private var includeCanonicalHeader: 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 id: JsonField = JsonMissing.of() private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() - private var includeCanonicalHeader: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(akeneoPim: AkeneoPim) = apply { + id = akeneoPim.id baseUrl = akeneoPim.baseUrl - clientId = akeneoPim.clientId - clientSecret = akeneoPim.clientSecret + includeCanonicalHeader = akeneoPim.includeCanonicalHeader name = akeneoPim.name - password = akeneoPim.password type = akeneoPim.type - username = akeneoPim.username - id = akeneoPim.id baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader - includeCanonicalHeader = akeneoPim.includeCanonicalHeader additionalProperties = akeneoPim.additionalProperties.toMutableMap() } - /** Akeneo instance base URL. */ - fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + /** + * 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.baseUrl] to an arbitrary JSON value. + * Sets [Builder.id] 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. + * 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 baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + fun id(id: JsonField) = apply { this.id = id } - /** Akeneo API client ID. */ - fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + /** Akeneo instance base URL. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) /** - * Sets [Builder.clientId] to an arbitrary JSON value. + * Sets [Builder.baseUrl] to an arbitrary JSON value. * - * You should usually call [Builder.clientId] with a well-typed [String] value instead. + * 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 clientId(clientId: JsonField) = apply { this.clientId = clientId } + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } - /** Akeneo API client secret. */ - fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) /** - * Sets [Builder.clientSecret] to an arbitrary JSON value. + * Sets [Builder.includeCanonicalHeader] 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. + * 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 clientSecret(clientSecret: JsonField) = apply { - this.clientSecret = clientSecret + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader } /** Display name of the origin. */ @@ -4004,18 +3636,6 @@ private constructor( */ 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. * @@ -4030,33 +3650,6 @@ private constructor( */ 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 } - - /** - * 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 } - /** URL used in the Canonical header (if enabled). */ fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) @@ -4072,21 +3665,6 @@ private constructor( 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) @@ -4113,28 +3691,22 @@ private constructor( * * The following fields are required: * ```java + * .id() * .baseUrl() - * .clientId() - * .clientSecret() + * .includeCanonicalHeader() * .name() - * .password() - * .username() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): AkeneoPim = AkeneoPim( + checkRequired("id", id), checkRequired("baseUrl", baseUrl), - checkRequired("clientId", clientId), - checkRequired("clientSecret", clientSecret), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), checkRequired("name", name), - checkRequired("password", password), type, - checkRequired("username", username), - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties.toMutableMap(), ) } @@ -4146,20 +3718,16 @@ private constructor( return@apply } + id() baseUrl() - clientId() - clientSecret() + includeCanonicalHeader() name() - password() _type().let { if (it != JsonValue.from("AKENEO_PIM")) { throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - username() - id() baseUrlForCanonicalHeader() - includeCanonicalHeader() validated = true } @@ -4179,16 +3747,12 @@ private constructor( */ @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 (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) + - (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 (id.asKnown().isPresent) 1 else 0) + - (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + - (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -4196,31 +3760,23 @@ private constructor( } return other is AkeneoPim && + id == other.id && baseUrl == other.baseUrl && - clientId == other.clientId && - clientSecret == other.clientSecret && + includeCanonicalHeader == other.includeCanonicalHeader && name == other.name && - password == other.password && type == other.type && - username == other.username && - id == other.id && baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && - includeCanonicalHeader == other.includeCanonicalHeader && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( + id, baseUrl, - clientId, - clientSecret, + includeCanonicalHeader, name, - password, type, - username, - id, baseUrlForCanonicalHeader, - includeCanonicalHeader, additionalProperties, ) } @@ -4228,6 +3784,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, id=$id, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + "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 index b8b7df8d..d7d23c32 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 @@ -2,10 +2,30 @@ 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.Params 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.errors.ImageKitInvalidDataException +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -27,7 +47,7 @@ private constructor( */ fun id(): Optional = Optional.ofNullable(id) - /** Schema for origin resources. */ + /** Schema for origin request resources. */ fun origin(): Origin = origin /** Additional headers to send with the request. */ @@ -76,7 +96,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Schema for origin resources. */ + /** Schema for origin request resources. */ fun origin(origin: Origin) = apply { this.origin = origin } /** Alias for calling [origin] with `Origin.ofS3(s3)`. */ @@ -245,6 +265,3996 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + /** Schema for origin request resources. */ + @JsonDeserialize(using = Origin.Deserializer::class) + @JsonSerialize(using = Origin.Serializer::class) + class Origin + 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(): Origin = 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 Origin && + 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 -> "Origin{s3=$s3}" + s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "Origin{webFolder=$webFolder}" + webProxy != null -> "Origin{webProxy=$webProxy}" + gcs != null -> "Origin{gcs=$gcs}" + azureBlob != null -> "Origin{azureBlob=$azureBlob}" + akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" + _json != null -> "Origin{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Origin") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + Origin(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) + + @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) + + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) + } + + /** An interface that defines how to map each variant of [Origin] 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 [Origin] to a value of type [T]. + * + * An instance of [Origin] 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 Origin: $json") + } + } + + internal class Deserializer : BaseDeserializer(Origin::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Origin { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3 = it, _json = json) + } ?: Origin(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(s3Compatible = it, _json = json) + } ?: Origin(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(cloudinaryBackup = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webFolder = it, _json = json) + } ?: Origin(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(webProxy = it, _json = json) + } ?: Origin(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(gcs = it, _json = json) + } ?: Origin(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(azureBlob = it, _json = json) + } ?: Origin(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Origin(akeneoPim = it, _json = json) + } ?: Origin(_json = json) + } + } + + return Origin(_json = json) + } + } + + internal class Serializer : BaseSerializer(Origin::class) { + + override fun serialize( + value: Origin, + 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 Origin") + } + } + } + + 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}" + } + } + 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/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt index 181e4def..0852af1b 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 @@ -6,11 +6,11 @@ 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.Origin 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 @@ -32,20 +32,20 @@ interface OriginServiceAsync { /** * **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ - fun create(params: OriginCreateParams): CompletableFuture = + fun create(params: OriginCreateParams): CompletableFuture = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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 = + fun update(id: String, params: OriginUpdateParams): CompletableFuture = update(id, params, RequestOptions.none()) /** @see update */ @@ -53,36 +53,37 @@ interface OriginServiceAsync { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) + ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: OriginUpdateParams): CompletableFuture = + fun update(params: OriginUpdateParams): CompletableFuture = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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()) + fun list(): CompletableFuture> = list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see list */ - fun list(params: OriginListParams = OriginListParams.none()): CompletableFuture> = - list(params, RequestOptions.none()) + fun list( + params: OriginListParams = OriginListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture> = + fun list(requestOptions: RequestOptions): CompletableFuture> = list(OriginListParams.none(), requestOptions) /** @@ -119,32 +120,33 @@ interface OriginServiceAsync { 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()) + 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) + ): CompletableFuture = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: OriginGetParams = OriginGetParams.none(), - ): CompletableFuture = get(id, params, RequestOptions.none()) + ): CompletableFuture = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see get */ - fun get(params: OriginGetParams): CompletableFuture = get(params, RequestOptions.none()) + fun get(params: OriginGetParams): CompletableFuture = + get(params, RequestOptions.none()) /** @see get */ - fun get(id: String, requestOptions: RequestOptions): CompletableFuture = + fun get(id: String, requestOptions: RequestOptions): CompletableFuture = get(id, OriginGetParams.none(), requestOptions) /** @@ -165,14 +167,14 @@ interface OriginServiceAsync { * Returns a raw HTTP response for `post /v1/accounts/origins`, but is otherwise the same as * [OriginServiceAsync.create]. */ - fun create(params: OriginCreateParams): CompletableFuture> = + fun create(params: OriginCreateParams): CompletableFuture> = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the @@ -181,45 +183,50 @@ interface OriginServiceAsync { fun update( id: String, params: OriginUpdateParams, - ): CompletableFuture> = update(id, params, RequestOptions.none()) + ): CompletableFuture> = + update(id, params, RequestOptions.none()) /** @see update */ fun update( id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: OriginUpdateParams): CompletableFuture> = + fun update(params: OriginUpdateParams): CompletableFuture> = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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()) + fun list(): CompletableFuture>> = + list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + ): CompletableFuture>> /** @see list */ fun list( params: OriginListParams = OriginListParams.none() - ): CompletableFuture>> = list(params, RequestOptions.none()) + ): CompletableFuture>> = + list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture>> = + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = list(OriginListParams.none(), requestOptions) /** @@ -261,7 +268,7 @@ interface OriginServiceAsync { * Returns a raw HTTP response for `get /v1/accounts/origins/{id}`, but is otherwise the * same as [OriginServiceAsync.get]. */ - fun get(id: String): CompletableFuture> = + fun get(id: String): CompletableFuture> = get(id, OriginGetParams.none()) /** @see get */ @@ -269,30 +276,31 @@ interface OriginServiceAsync { id: String, params: OriginGetParams = OriginGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: OriginGetParams = OriginGetParams.none(), - ): CompletableFuture> = get(id, params, RequestOptions.none()) + ): CompletableFuture> = + get(id, params, RequestOptions.none()) /** @see get */ fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see get */ - fun get(params: OriginGetParams): CompletableFuture> = + fun get(params: OriginGetParams): CompletableFuture> = get(params, RequestOptions.none()) /** @see get */ fun get( id: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): 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 index 969c544d..7b9da703 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/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt @@ -17,11 +17,11 @@ 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.Origin 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 @@ -42,21 +42,21 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/accounts/origins withRawResponse().create(params, requestOptions).thenApply { it.parse() } override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // put /v1/accounts/origins/{id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = // get /v1/accounts/origins withRawResponse().list(params, requestOptions).thenApply { it.parse() } @@ -70,7 +70,7 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/accounts/origins/{id} withRawResponse().get(params, requestOptions).thenApply { it.parse() } @@ -87,12 +87,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -117,12 +118,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -150,13 +152,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture>> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -207,12 +209,13 @@ class OriginServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/main/kotlin/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 72ee79f2..5d735334 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 @@ -7,11 +7,11 @@ 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.Origin 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 @@ -32,19 +32,19 @@ interface OriginService { /** * **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ - fun create(params: OriginCreateParams): Origin = create(params, RequestOptions.none()) + fun create(params: OriginCreateParams): OriginResponse = create(params, RequestOptions.none()) /** @see create */ fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Origin + ): 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): Origin = + fun update(id: String, params: OriginUpdateParams): OriginResponse = update(id, params, RequestOptions.none()) /** @see update */ @@ -52,35 +52,35 @@ interface OriginService { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Origin = update(params.toBuilder().id(id).build(), requestOptions) + ): OriginResponse = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: OriginUpdateParams): Origin = update(params, RequestOptions.none()) + fun update(params: OriginUpdateParams): OriginResponse = update(params, RequestOptions.none()) /** @see update */ fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Origin + ): 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()) + fun list(): List = list(OriginListParams.none()) /** @see list */ fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): List + ): List /** @see list */ - fun list(params: OriginListParams = OriginListParams.none()): List = + fun list(params: OriginListParams = OriginListParams.none()): List = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): List = + fun list(requestOptions: RequestOptions): List = list(OriginListParams.none(), requestOptions) /** @@ -111,27 +111,30 @@ interface OriginService { delete(id, OriginDeleteParams.none(), requestOptions) /** **Note:** This API is currently in beta. Retrieves the origin identified by `id`. */ - fun get(id: String): Origin = get(id, OriginGetParams.none()) + fun get(id: String): OriginResponse = get(id, OriginGetParams.none()) /** @see get */ fun get( id: String, params: OriginGetParams = OriginGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): Origin = get(params.toBuilder().id(id).build(), requestOptions) + ): OriginResponse = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ - fun get(id: String, params: OriginGetParams = OriginGetParams.none()): Origin = + fun get(id: String, params: OriginGetParams = OriginGetParams.none()): OriginResponse = get(id, params, RequestOptions.none()) /** @see get */ - fun get(params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none()): Origin + fun get( + params: OriginGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse /** @see get */ - fun get(params: OriginGetParams): Origin = get(params, RequestOptions.none()) + fun get(params: OriginGetParams): OriginResponse = get(params, RequestOptions.none()) /** @see get */ - fun get(id: String, requestOptions: RequestOptions): Origin = + 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. */ @@ -149,7 +152,7 @@ interface OriginService { * [OriginService.create]. */ @MustBeClosed - fun create(params: OriginCreateParams): HttpResponseFor = + fun create(params: OriginCreateParams): HttpResponseFor = create(params, RequestOptions.none()) /** @see create */ @@ -157,14 +160,14 @@ interface OriginService { fun create( params: OriginCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun update(id: String, params: OriginUpdateParams): HttpResponseFor = update(id, params, RequestOptions.none()) /** @see update */ @@ -173,11 +176,12 @@ interface OriginService { id: String, params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = update(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ @MustBeClosed - fun update(params: OriginUpdateParams): HttpResponseFor = + fun update(params: OriginUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) /** @see update */ @@ -185,30 +189,31 @@ interface OriginService { fun update( params: OriginUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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()) + @MustBeClosed + fun list(): HttpResponseFor> = list(OriginListParams.none()) /** @see list */ @MustBeClosed fun list( params: OriginListParams = OriginListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + ): HttpResponseFor> /** @see list */ @MustBeClosed fun list( params: OriginListParams = OriginListParams.none() - ): HttpResponseFor> = list(params, RequestOptions.none()) + ): HttpResponseFor> = list(params, RequestOptions.none()) /** @see list */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor> = + fun list(requestOptions: RequestOptions): HttpResponseFor> = list(OriginListParams.none(), requestOptions) /** @@ -252,7 +257,8 @@ interface OriginService { * 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()) + @MustBeClosed + fun get(id: String): HttpResponseFor = get(id, OriginGetParams.none()) /** @see get */ @MustBeClosed @@ -260,30 +266,30 @@ interface OriginService { id: String, params: OriginGetParams = OriginGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = get(params.toBuilder().id(id).build(), requestOptions) + ): 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()) + ): HttpResponseFor = get(id, params, RequestOptions.none()) /** @see get */ @MustBeClosed fun get( params: OriginGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see get */ @MustBeClosed - fun get(params: OriginGetParams): HttpResponseFor = + fun get(params: OriginGetParams): HttpResponseFor = get(params, RequestOptions.none()) /** @see get */ @MustBeClosed - fun get(id: String, requestOptions: RequestOptions): HttpResponseFor = + 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 index ea913424..bbbd6358 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/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt @@ -17,11 +17,11 @@ 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.Origin 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 @@ -38,15 +38,24 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): OriginService = OriginServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create(params: OriginCreateParams, requestOptions: RequestOptions): Origin = + override fun create( + params: OriginCreateParams, + requestOptions: RequestOptions, + ): OriginResponse = // post /v1/accounts/origins withRawResponse().create(params, requestOptions).parse() - override fun update(params: OriginUpdateParams, requestOptions: RequestOptions): Origin = + 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 = + override fun list( + params: OriginListParams, + requestOptions: RequestOptions, + ): List = // get /v1/accounts/origins withRawResponse().list(params, requestOptions).parse() @@ -55,7 +64,7 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp withRawResponse().delete(params, requestOptions) } - override fun get(params: OriginGetParams, requestOptions: RequestOptions): Origin = + override fun get(params: OriginGetParams, requestOptions: RequestOptions): OriginResponse = // get /v1/accounts/origins/{id} withRawResponse().get(params, requestOptions).parse() @@ -72,12 +81,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: OriginCreateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -99,12 +109,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: OriginUpdateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -129,13 +140,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: OriginListParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -180,12 +191,13 @@ class OriginServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun get( params: OriginGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/test/kotlin/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 253d8d7e..e8defa1a 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 @@ -11,10 +11,11 @@ internal class OriginCreateParamsTest { fun create() { OriginCreateParams.builder() .origin( - Origin.S3.builder() + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -28,10 +29,11 @@ internal class OriginCreateParamsTest { val params = OriginCreateParams.builder() .origin( - Origin.S3.builder() + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -43,11 +45,12 @@ internal class OriginCreateParamsTest { assertThat(body) .isEqualTo( - Origin.ofS3( - Origin.S3.builder() + OriginCreateParams.Origin.ofS3( + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -60,14 +63,28 @@ internal class OriginCreateParamsTest { fun bodyWithoutOptionalFields() { val params = OriginCreateParams.builder() - .origin(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) + .origin( + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) .build() val body = params._body() assertThat(body) .isEqualTo( - Origin.ofS3(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) + OriginCreateParams.Origin.ofS3( + OriginCreateParams.Origin.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/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/OriginTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt deleted file mode 100644 index 8ab5df13..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginTest.kt +++ /dev/null @@ -1,395 +0,0 @@ -// 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 OriginTest { - - @Test - fun ofS3() { - val s3 = - Origin.S3.builder() - .bucket("product-images") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - - val origin = Origin.ofS3(s3) - - assertThat(origin.s3()).contains(s3) - assertThat(origin.s3Compatible()).isEmpty - assertThat(origin.cloudinaryBackup()).isEmpty - assertThat(origin.webFolder()).isEmpty - assertThat(origin.webProxy()).isEmpty - assertThat(origin.gcs()).isEmpty - assertThat(origin.azureBlob()).isEmpty - assertThat(origin.akeneoPim()).isEmpty - } - - @Test - fun ofS3Roundtrip() { - val jsonMapper = jsonMapper() - val origin = - Origin.ofS3( - Origin.S3.builder() - .bucket("product-images") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) - - val roundtrippedOrigin = - jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) - - assertThat(roundtrippedOrigin).isEqualTo(origin) - } - - @Test - fun ofS3Compatible() { - val s3Compatible = - Origin.S3Compatible.builder() - .bucket("product-images") - .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .s3ForcePathStyle(true) - .build() - - val origin = Origin.ofS3Compatible(s3Compatible) - - assertThat(origin.s3()).isEmpty - assertThat(origin.s3Compatible()).contains(s3Compatible) - assertThat(origin.cloudinaryBackup()).isEmpty - assertThat(origin.webFolder()).isEmpty - assertThat(origin.webProxy()).isEmpty - assertThat(origin.gcs()).isEmpty - assertThat(origin.azureBlob()).isEmpty - assertThat(origin.akeneoPim()).isEmpty - } - - @Test - fun ofS3CompatibleRoundtrip() { - val jsonMapper = jsonMapper() - val origin = - Origin.ofS3Compatible( - Origin.S3Compatible.builder() - .bucket("product-images") - .endpoint("https://s3.eu-central-1.wasabisys.com") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .s3ForcePathStyle(true) - .build() - ) - - val roundtrippedOrigin = - jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) - - assertThat(roundtrippedOrigin).isEqualTo(origin) - } - - @Test - fun ofCloudinaryBackup() { - val cloudinaryBackup = - Origin.CloudinaryBackup.builder() - .bucket("product-images") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - - val origin = Origin.ofCloudinaryBackup(cloudinaryBackup) - - assertThat(origin.s3()).isEmpty - assertThat(origin.s3Compatible()).isEmpty - assertThat(origin.cloudinaryBackup()).contains(cloudinaryBackup) - assertThat(origin.webFolder()).isEmpty - assertThat(origin.webProxy()).isEmpty - assertThat(origin.gcs()).isEmpty - assertThat(origin.azureBlob()).isEmpty - assertThat(origin.akeneoPim()).isEmpty - } - - @Test - fun ofCloudinaryBackupRoundtrip() { - val jsonMapper = jsonMapper() - val origin = - Origin.ofCloudinaryBackup( - Origin.CloudinaryBackup.builder() - .bucket("product-images") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("raw-assets") - .build() - ) - - val roundtrippedOrigin = - jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) - - assertThat(roundtrippedOrigin).isEqualTo(origin) - } - - @Test - fun ofWebFolder() { - val webFolder = - Origin.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) - .build() - - val origin = Origin.ofWebFolder(webFolder) - - assertThat(origin.s3()).isEmpty - assertThat(origin.s3Compatible()).isEmpty - assertThat(origin.cloudinaryBackup()).isEmpty - assertThat(origin.webFolder()).contains(webFolder) - assertThat(origin.webProxy()).isEmpty - assertThat(origin.gcs()).isEmpty - assertThat(origin.azureBlob()).isEmpty - assertThat(origin.akeneoPim()).isEmpty - } - - @Test - fun ofWebFolderRoundtrip() { - val jsonMapper = jsonMapper() - val origin = - Origin.ofWebFolder( - Origin.WebFolder.builder() - .baseUrl("https://images.example.com/assets") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .forwardHostHeaderToOrigin(false) - .includeCanonicalHeader(false) - .build() - ) - - val roundtrippedOrigin = - jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) - - assertThat(roundtrippedOrigin).isEqualTo(origin) - } - - @Test - fun ofWebProxy() { - val webProxy = - Origin.WebProxy.builder() - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .build() - - val origin = Origin.ofWebProxy(webProxy) - - assertThat(origin.s3()).isEmpty - assertThat(origin.s3Compatible()).isEmpty - assertThat(origin.cloudinaryBackup()).isEmpty - assertThat(origin.webFolder()).isEmpty - assertThat(origin.webProxy()).contains(webProxy) - assertThat(origin.gcs()).isEmpty - assertThat(origin.azureBlob()).isEmpty - assertThat(origin.akeneoPim()).isEmpty - } - - @Test - fun ofWebProxyRoundtrip() { - val jsonMapper = jsonMapper() - val origin = - Origin.ofWebProxy( - Origin.WebProxy.builder() - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .build() - ) - - val roundtrippedOrigin = - jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) - - assertThat(roundtrippedOrigin).isEqualTo(origin) - } - - @Test - fun ofGcs() { - val gcs = - Origin.Gcs.builder() - .bucket("gcs-media") - .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("products") - .build() - - val origin = Origin.ofGcs(gcs) - - assertThat(origin.s3()).isEmpty - assertThat(origin.s3Compatible()).isEmpty - assertThat(origin.cloudinaryBackup()).isEmpty - assertThat(origin.webFolder()).isEmpty - assertThat(origin.webProxy()).isEmpty - assertThat(origin.gcs()).contains(gcs) - assertThat(origin.azureBlob()).isEmpty - assertThat(origin.akeneoPim()).isEmpty - } - - @Test - fun ofGcsRoundtrip() { - val jsonMapper = jsonMapper() - val origin = - Origin.ofGcs( - Origin.Gcs.builder() - .bucket("gcs-media") - .clientEmail("service-account@project.iam.gserviceaccount.com") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("products") - .build() - ) - - val roundtrippedOrigin = - jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) - - assertThat(roundtrippedOrigin).isEqualTo(origin) - } - - @Test - fun ofAzureBlob() { - val azureBlob = - Origin.AzureBlob.builder() - .accountName("account123") - .container("images") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("uploads") - .build() - - val origin = Origin.ofAzureBlob(azureBlob) - - assertThat(origin.s3()).isEmpty - assertThat(origin.s3Compatible()).isEmpty - assertThat(origin.cloudinaryBackup()).isEmpty - assertThat(origin.webFolder()).isEmpty - assertThat(origin.webProxy()).isEmpty - assertThat(origin.gcs()).isEmpty - assertThat(origin.azureBlob()).contains(azureBlob) - assertThat(origin.akeneoPim()).isEmpty - } - - @Test - fun ofAzureBlobRoundtrip() { - val jsonMapper = jsonMapper() - val origin = - Origin.ofAzureBlob( - Origin.AzureBlob.builder() - .accountName("account123") - .container("images") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("uploads") - .build() - ) - - val roundtrippedOrigin = - jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) - - assertThat(roundtrippedOrigin).isEqualTo(origin) - } - - @Test - fun ofAkeneoPim() { - val akeneoPim = - Origin.AkeneoPim.builder() - .baseUrl("https://akeneo.company.com") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .build() - - val origin = Origin.ofAkeneoPim(akeneoPim) - - assertThat(origin.s3()).isEmpty - assertThat(origin.s3Compatible()).isEmpty - assertThat(origin.cloudinaryBackup()).isEmpty - assertThat(origin.webFolder()).isEmpty - assertThat(origin.webProxy()).isEmpty - assertThat(origin.gcs()).isEmpty - assertThat(origin.azureBlob()).isEmpty - assertThat(origin.akeneoPim()).contains(akeneoPim) - } - - @Test - fun ofAkeneoPimRoundtrip() { - val jsonMapper = jsonMapper() - val origin = - Origin.ofAkeneoPim( - Origin.AkeneoPim.builder() - .baseUrl("https://akeneo.company.com") - .name("US S3 Storage") - .id("id") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .build() - ) - - val roundtrippedOrigin = - jsonMapper.readValue(jsonMapper.writeValueAsString(origin), jacksonTypeRef()) - - assertThat(roundtrippedOrigin).isEqualTo(origin) - } - - 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 origin = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { origin.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 index 3b1e46db..e9be0a35 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 @@ -12,10 +12,11 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - Origin.S3.builder() + OriginUpdateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -29,7 +30,14 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .origin(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) + .origin( + OriginUpdateParams.Origin.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) .build() assertThat(params._pathParam(0)).isEqualTo("id") @@ -43,10 +51,11 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - Origin.S3.builder() + OriginUpdateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -58,11 +67,12 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - Origin.ofS3( - Origin.S3.builder() + OriginUpdateParams.Origin.ofS3( + OriginUpdateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -76,14 +86,28 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .origin(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) + .origin( + OriginUpdateParams.Origin.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) .build() val body = params._body() assertThat(body) .isEqualTo( - Origin.ofS3(Origin.S3.builder().bucket("test-bucket").name("My S3 Origin").build()) + OriginUpdateParams.Origin.ofS3( + OriginUpdateParams.Origin.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/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index 478b8e42..2119f16b 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.Origin import com.imagekit.api.models.accounts.origins.OriginCreateParams import com.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled @@ -25,14 +24,15 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originFuture = + val originResponseFuture = originServiceAsync.create( OriginCreateParams.builder() .origin( - Origin.S3.builder() + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -41,8 +41,8 @@ internal class OriginServiceAsyncTest { .build() ) - val origin = originFuture.get() - origin.validate() + val originResponse = originResponseFuture.get() + originResponse.validate() } @Disabled("Prism tests are disabled") @@ -56,15 +56,16 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originFuture = + val originResponseFuture = originServiceAsync.update( OriginUpdateParams.builder() .id("id") .origin( - Origin.S3.builder() + OriginUpdateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -73,8 +74,8 @@ internal class OriginServiceAsyncTest { .build() ) - val origin = originFuture.get() - origin.validate() + val originResponse = originResponseFuture.get() + originResponse.validate() } @Disabled("Prism tests are disabled") @@ -88,10 +89,10 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originsFuture = originServiceAsync.list() + val originResponsesFuture = originServiceAsync.list() - val origins = originsFuture.get() - origins.forEach { it.validate() } + val originResponses = originResponsesFuture.get() + originResponses.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -121,9 +122,9 @@ internal class OriginServiceAsyncTest { .build() val originServiceAsync = client.accounts().origins() - val originFuture = originServiceAsync.get("id") + val originResponseFuture = originServiceAsync.get("id") - val origin = originFuture.get() - origin.validate() + val originResponse = originResponseFuture.get() + originResponse.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 index 7122c049..a42d7f4a 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.Origin import com.imagekit.api.models.accounts.origins.OriginCreateParams import com.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled @@ -25,14 +24,15 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val origin = + val originResponse = originService.create( OriginCreateParams.builder() .origin( - Origin.S3.builder() + OriginCreateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -41,7 +41,7 @@ internal class OriginServiceTest { .build() ) - origin.validate() + originResponse.validate() } @Disabled("Prism tests are disabled") @@ -55,15 +55,16 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val origin = + val originResponse = originService.update( OriginUpdateParams.builder() .id("id") .origin( - Origin.S3.builder() + OriginUpdateParams.Origin.S3.builder() + .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") - .id("id") + .secretKey("secrettest123") .baseUrlForCanonicalHeader("https://cdn.example.com") .includeCanonicalHeader(false) .prefix("images") @@ -72,7 +73,7 @@ internal class OriginServiceTest { .build() ) - origin.validate() + originResponse.validate() } @Disabled("Prism tests are disabled") @@ -86,9 +87,9 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val origins = originService.list() + val originResponses = originService.list() - origins.forEach { it.validate() } + originResponses.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -116,8 +117,8 @@ internal class OriginServiceTest { .build() val originService = client.accounts().origins() - val origin = originService.get("id") + val originResponse = originService.get("id") - origin.validate() + originResponse.validate() } } From 7acab3511910ad34fa3da03f1a0d29ed7fb485b7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 06:15:48 +0000 Subject: [PATCH 053/125] feat(api): manual updates --- .stats.yml | 6 +- .../accounts/origins/OriginCreateParams.kt | 4065 +---------------- .../models/accounts/origins/OriginRequest.kt | 3908 ++++++++++++++++ .../accounts/origins/OriginUpdateParams.kt | 4063 +--------------- .../urlendpoints/UrlEndpointCreateParams.kt | 29 +- .../urlendpoints/UrlEndpointCreateResponse.kt | 825 ---- .../urlendpoints/UrlEndpointListResponse.kt | 825 ---- .../{UrlEndpoint.kt => UrlEndpointRequest.kt} | 30 +- ...tGetResponse.kt => UrlEndpointResponse.kt} | 32 +- .../urlendpoints/UrlEndpointUpdateParams.kt | 29 +- .../urlendpoints/UrlEndpointUpdateResponse.kt | 825 ---- .../async/accounts/UrlEndpointServiceAsync.kt | 70 +- .../accounts/UrlEndpointServiceAsyncImpl.kt | 37 +- .../blocking/accounts/UrlEndpointService.kt | 74 +- .../accounts/UrlEndpointServiceImpl.kt | 37 +- .../origins/OriginCreateParamsTest.kt | 14 +- .../accounts/origins/OriginRequestTest.kt | 428 ++ .../origins/OriginUpdateParamsTest.kt | 16 +- .../UrlEndpointCreateParamsTest.kt | 22 +- .../UrlEndpointCreateResponseTest.kt | 60 - .../UrlEndpointListResponseTest.kt | 59 - ...pointTest.kt => UrlEndpointRequestTest.kt} | 34 +- ...onseTest.kt => UrlEndpointResponseTest.kt} | 32 +- .../UrlEndpointUpdateParamsTest.kt | 26 +- .../UrlEndpointUpdateResponseTest.kt | 60 - .../async/accounts/OriginServiceAsyncTest.kt | 5 +- .../accounts/UrlEndpointServiceAsyncTest.kt | 38 +- .../blocking/accounts/OriginServiceTest.kt | 5 +- .../accounts/UrlEndpointServiceTest.kt | 30 +- 29 files changed, 4675 insertions(+), 11009 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/{UrlEndpoint.kt => UrlEndpointRequest.kt} (96%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/{UrlEndpointGetResponse.kt => UrlEndpointResponse.kt} (96%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginRequestTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/{UrlEndpointTest.kt => UrlEndpointRequestTest.kt} (55%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/{UrlEndpointGetResponseTest.kt => UrlEndpointResponseTest.kt} (53%) delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 8a42af3a..e88489f2 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-fa82106bb6313906d2eaac167e0ca5f60f12a166c743c00a18c22be0e455c1b6.yml -openapi_spec_hash: 8ff6fc6886e8d7a9eee6d45d51e9673c -config_hash: 76b94bb341141f0e9b14cdbb1203b0fa +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-547b616849eececf3f5b1ea38ebe1dba718e1877c787e3642b9c91e552548789.yml +openapi_spec_hash: fba0bf8c1ee034067ab6ae93f84abeae +config_hash: befd7c8f04cc5b4992ec11efe0d6934b 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 99d337f1..85b329b8 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 @@ -2,44 +2,22 @@ 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.Params 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.errors.ImageKitInvalidDataException -import java.util.Collections import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams private constructor( - private val origin: Origin, + private val origin: OriginRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** Schema for origin request resources. */ - fun origin(): Origin = origin + fun origin(): OriginRequest = origin /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -65,7 +43,7 @@ private constructor( /** A builder for [OriginCreateParams]. */ class Builder internal constructor() { - private var origin: Origin? = null + private var origin: OriginRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -77,42 +55,47 @@ private constructor( } /** Schema for origin request resources. */ - fun origin(origin: Origin) = apply { this.origin = origin } + fun origin(origin: OriginRequest) = apply { this.origin = origin } - /** Alias for calling [origin] with `Origin.ofS3(s3)`. */ - fun origin(s3: Origin.S3) = origin(Origin.ofS3(s3)) + /** Alias for calling [origin] with `OriginRequest.ofS3(s3)`. */ + fun origin(s3: OriginRequest.S3) = origin(OriginRequest.ofS3(s3)) - /** Alias for calling [origin] with `Origin.ofS3Compatible(s3Compatible)`. */ - fun origin(s3Compatible: Origin.S3Compatible) = origin(Origin.ofS3Compatible(s3Compatible)) + /** Alias for calling [origin] with `OriginRequest.ofS3Compatible(s3Compatible)`. */ + fun origin(s3Compatible: OriginRequest.S3Compatible) = + origin(OriginRequest.ofS3Compatible(s3Compatible)) - /** Alias for calling [origin] with `Origin.ofCloudinaryBackup(cloudinaryBackup)`. */ - fun origin(cloudinaryBackup: Origin.CloudinaryBackup) = - origin(Origin.ofCloudinaryBackup(cloudinaryBackup)) + /** Alias for calling [origin] with `OriginRequest.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun origin(cloudinaryBackup: OriginRequest.CloudinaryBackup) = + origin(OriginRequest.ofCloudinaryBackup(cloudinaryBackup)) - /** Alias for calling [origin] with `Origin.ofWebFolder(webFolder)`. */ - fun origin(webFolder: Origin.WebFolder) = origin(Origin.ofWebFolder(webFolder)) + /** Alias for calling [origin] with `OriginRequest.ofWebFolder(webFolder)`. */ + fun origin(webFolder: OriginRequest.WebFolder) = + origin(OriginRequest.ofWebFolder(webFolder)) - /** Alias for calling [origin] with `Origin.ofWebProxy(webProxy)`. */ - fun origin(webProxy: Origin.WebProxy) = origin(Origin.ofWebProxy(webProxy)) + /** 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 - * Origin.WebProxy.builder() + * OriginRequest.WebProxy.builder() * .name(name) * .build() * ``` */ - fun webProxyOrigin(name: String) = origin(Origin.WebProxy.builder().name(name).build()) + fun webProxyOrigin(name: String) = + origin(OriginRequest.WebProxy.builder().name(name).build()) - /** Alias for calling [origin] with `Origin.ofGcs(gcs)`. */ - fun origin(gcs: Origin.Gcs) = origin(Origin.ofGcs(gcs)) + /** Alias for calling [origin] with `OriginRequest.ofGcs(gcs)`. */ + fun origin(gcs: OriginRequest.Gcs) = origin(OriginRequest.ofGcs(gcs)) - /** Alias for calling [origin] with `Origin.ofAzureBlob(azureBlob)`. */ - fun origin(azureBlob: Origin.AzureBlob) = origin(Origin.ofAzureBlob(azureBlob)) + /** Alias for calling [origin] with `OriginRequest.ofAzureBlob(azureBlob)`. */ + fun origin(azureBlob: OriginRequest.AzureBlob) = + origin(OriginRequest.ofAzureBlob(azureBlob)) - /** Alias for calling [origin] with `Origin.ofAkeneoPim(akeneoPim)`. */ - fun origin(akeneoPim: Origin.AkeneoPim) = origin(Origin.ofAkeneoPim(akeneoPim)) + /** 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() @@ -232,4002 +215,12 @@ private constructor( ) } - fun _body(): Origin = origin + fun _body(): OriginRequest = origin override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** Schema for origin request resources. */ - @JsonDeserialize(using = Origin.Deserializer::class) - @JsonSerialize(using = Origin.Serializer::class) - class Origin - 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(): Origin = 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 Origin && - 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 -> "Origin{s3=$s3}" - s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "Origin{webFolder=$webFolder}" - webProxy != null -> "Origin{webProxy=$webProxy}" - gcs != null -> "Origin{gcs=$gcs}" - azureBlob != null -> "Origin{azureBlob=$azureBlob}" - akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" - _json != null -> "Origin{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Origin") - } - - companion object { - - @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) - - @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) - - @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - Origin(cloudinaryBackup = cloudinaryBackup) - - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) - - @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) - - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) - - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) - } - - /** An interface that defines how to map each variant of [Origin] 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 [Origin] to a value of type [T]. - * - * An instance of [Origin] 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 Origin: $json") - } - } - - internal class Deserializer : BaseDeserializer(Origin::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Origin { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3 = it, _json = json) - } ?: Origin(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3Compatible = it, _json = json) - } ?: Origin(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(cloudinaryBackup = it, _json = json) - } ?: Origin(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webFolder = it, _json = json) - } ?: Origin(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webProxy = it, _json = json) - } ?: Origin(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(gcs = it, _json = json) - } ?: Origin(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(azureBlob = it, _json = json) - } ?: Origin(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(akeneoPim = it, _json = json) - } ?: Origin(_json = json) - } - } - - return Origin(_json = json) - } - } - - internal class Serializer : BaseSerializer(Origin::class) { - - override fun serialize( - value: Origin, - 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 Origin") - } - } - } - - 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}" - } - } - 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/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/OriginUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt index d7d23c32..3b73cbad 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 @@ -2,30 +2,10 @@ 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.Params 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.errors.ImageKitInvalidDataException -import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -37,7 +17,7 @@ import kotlin.jvm.optionals.getOrNull class OriginUpdateParams private constructor( private val id: String?, - private val origin: Origin, + private val origin: OriginRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -48,7 +28,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** Schema for origin request resources. */ - fun origin(): Origin = origin + fun origin(): OriginRequest = origin /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -75,7 +55,7 @@ private constructor( class Builder internal constructor() { private var id: String? = null - private var origin: Origin? = null + private var origin: OriginRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -97,42 +77,47 @@ private constructor( fun id(id: Optional) = id(id.getOrNull()) /** Schema for origin request resources. */ - fun origin(origin: Origin) = apply { this.origin = origin } + fun origin(origin: OriginRequest) = apply { this.origin = origin } - /** Alias for calling [origin] with `Origin.ofS3(s3)`. */ - fun origin(s3: Origin.S3) = origin(Origin.ofS3(s3)) + /** Alias for calling [origin] with `OriginRequest.ofS3(s3)`. */ + fun origin(s3: OriginRequest.S3) = origin(OriginRequest.ofS3(s3)) - /** Alias for calling [origin] with `Origin.ofS3Compatible(s3Compatible)`. */ - fun origin(s3Compatible: Origin.S3Compatible) = origin(Origin.ofS3Compatible(s3Compatible)) + /** Alias for calling [origin] with `OriginRequest.ofS3Compatible(s3Compatible)`. */ + fun origin(s3Compatible: OriginRequest.S3Compatible) = + origin(OriginRequest.ofS3Compatible(s3Compatible)) - /** Alias for calling [origin] with `Origin.ofCloudinaryBackup(cloudinaryBackup)`. */ - fun origin(cloudinaryBackup: Origin.CloudinaryBackup) = - origin(Origin.ofCloudinaryBackup(cloudinaryBackup)) + /** Alias for calling [origin] with `OriginRequest.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun origin(cloudinaryBackup: OriginRequest.CloudinaryBackup) = + origin(OriginRequest.ofCloudinaryBackup(cloudinaryBackup)) - /** Alias for calling [origin] with `Origin.ofWebFolder(webFolder)`. */ - fun origin(webFolder: Origin.WebFolder) = origin(Origin.ofWebFolder(webFolder)) + /** Alias for calling [origin] with `OriginRequest.ofWebFolder(webFolder)`. */ + fun origin(webFolder: OriginRequest.WebFolder) = + origin(OriginRequest.ofWebFolder(webFolder)) - /** Alias for calling [origin] with `Origin.ofWebProxy(webProxy)`. */ - fun origin(webProxy: Origin.WebProxy) = origin(Origin.ofWebProxy(webProxy)) + /** 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 - * Origin.WebProxy.builder() + * OriginRequest.WebProxy.builder() * .name(name) * .build() * ``` */ - fun webProxyOrigin(name: String) = origin(Origin.WebProxy.builder().name(name).build()) + fun webProxyOrigin(name: String) = + origin(OriginRequest.WebProxy.builder().name(name).build()) - /** Alias for calling [origin] with `Origin.ofGcs(gcs)`. */ - fun origin(gcs: Origin.Gcs) = origin(Origin.ofGcs(gcs)) + /** Alias for calling [origin] with `OriginRequest.ofGcs(gcs)`. */ + fun origin(gcs: OriginRequest.Gcs) = origin(OriginRequest.ofGcs(gcs)) - /** Alias for calling [origin] with `Origin.ofAzureBlob(azureBlob)`. */ - fun origin(azureBlob: Origin.AzureBlob) = origin(Origin.ofAzureBlob(azureBlob)) + /** Alias for calling [origin] with `OriginRequest.ofAzureBlob(azureBlob)`. */ + fun origin(azureBlob: OriginRequest.AzureBlob) = + origin(OriginRequest.ofAzureBlob(azureBlob)) - /** Alias for calling [origin] with `Origin.ofAkeneoPim(akeneoPim)`. */ - fun origin(akeneoPim: Origin.AkeneoPim) = origin(Origin.ofAkeneoPim(akeneoPim)) + /** 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() @@ -253,7 +238,7 @@ private constructor( ) } - fun _body(): Origin = origin + fun _body(): OriginRequest = origin fun _pathParam(index: Int): String = when (index) { @@ -265,3996 +250,6 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - /** Schema for origin request resources. */ - @JsonDeserialize(using = Origin.Deserializer::class) - @JsonSerialize(using = Origin.Serializer::class) - class Origin - 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(): Origin = 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 Origin && - 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 -> "Origin{s3=$s3}" - s3Compatible != null -> "Origin{s3Compatible=$s3Compatible}" - cloudinaryBackup != null -> "Origin{cloudinaryBackup=$cloudinaryBackup}" - webFolder != null -> "Origin{webFolder=$webFolder}" - webProxy != null -> "Origin{webProxy=$webProxy}" - gcs != null -> "Origin{gcs=$gcs}" - azureBlob != null -> "Origin{azureBlob=$azureBlob}" - akeneoPim != null -> "Origin{akeneoPim=$akeneoPim}" - _json != null -> "Origin{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Origin") - } - - companion object { - - @JvmStatic fun ofS3(s3: S3) = Origin(s3 = s3) - - @JvmStatic - fun ofS3Compatible(s3Compatible: S3Compatible) = Origin(s3Compatible = s3Compatible) - - @JvmStatic - fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = - Origin(cloudinaryBackup = cloudinaryBackup) - - @JvmStatic fun ofWebFolder(webFolder: WebFolder) = Origin(webFolder = webFolder) - - @JvmStatic fun ofWebProxy(webProxy: WebProxy) = Origin(webProxy = webProxy) - - @JvmStatic fun ofGcs(gcs: Gcs) = Origin(gcs = gcs) - - @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = Origin(azureBlob = azureBlob) - - @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = Origin(akeneoPim = akeneoPim) - } - - /** An interface that defines how to map each variant of [Origin] 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 [Origin] to a value of type [T]. - * - * An instance of [Origin] 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 Origin: $json") - } - } - - internal class Deserializer : BaseDeserializer(Origin::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Origin { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "S3" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3 = it, _json = json) - } ?: Origin(_json = json) - } - "S3_COMPATIBLE" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(s3Compatible = it, _json = json) - } ?: Origin(_json = json) - } - "CLOUDINARY_BACKUP" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(cloudinaryBackup = it, _json = json) - } ?: Origin(_json = json) - } - "WEB_FOLDER" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webFolder = it, _json = json) - } ?: Origin(_json = json) - } - "WEB_PROXY" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(webProxy = it, _json = json) - } ?: Origin(_json = json) - } - "GCS" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(gcs = it, _json = json) - } ?: Origin(_json = json) - } - "AZURE_BLOB" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(azureBlob = it, _json = json) - } ?: Origin(_json = json) - } - "AKENEO_PIM" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Origin(akeneoPim = it, _json = json) - } ?: Origin(_json = json) - } - } - - return Origin(_json = json) - } - } - - internal class Serializer : BaseSerializer(Origin::class) { - - override fun serialize( - value: Origin, - 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 Origin") - } - } - } - - 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}" - } - } - 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/accounts/urlendpoints/UrlEndpointCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt index c7c87a41..82e57e9a 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt @@ -15,15 +15,16 @@ import java.util.Objects */ class UrlEndpointCreateParams private constructor( - private val urlEndpoint: UrlEndpoint, + private val urlEndpointRequest: UrlEndpointRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** Schema for URL endpoint resource. */ - fun urlEndpoint(): UrlEndpoint = urlEndpoint + fun urlEndpointRequest(): UrlEndpointRequest = urlEndpointRequest - fun _additionalBodyProperties(): Map = urlEndpoint._additionalProperties() + fun _additionalBodyProperties(): Map = + urlEndpointRequest._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -40,7 +41,7 @@ private constructor( * * The following fields are required: * ```java - * .urlEndpoint() + * .urlEndpointRequest() * ``` */ @JvmStatic fun builder() = Builder() @@ -49,19 +50,21 @@ private constructor( /** A builder for [UrlEndpointCreateParams]. */ class Builder internal constructor() { - private var urlEndpoint: UrlEndpoint? = null + 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 { - urlEndpoint = urlEndpointCreateParams.urlEndpoint + urlEndpointRequest = urlEndpointCreateParams.urlEndpointRequest additionalHeaders = urlEndpointCreateParams.additionalHeaders.toBuilder() additionalQueryParams = urlEndpointCreateParams.additionalQueryParams.toBuilder() } /** Schema for URL endpoint resource. */ - fun urlEndpoint(urlEndpoint: UrlEndpoint) = apply { this.urlEndpoint = urlEndpoint } + fun urlEndpointRequest(urlEndpointRequest: UrlEndpointRequest) = apply { + this.urlEndpointRequest = urlEndpointRequest + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -168,20 +171,20 @@ private constructor( * * The following fields are required: * ```java - * .urlEndpoint() + * .urlEndpointRequest() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): UrlEndpointCreateParams = UrlEndpointCreateParams( - checkRequired("urlEndpoint", urlEndpoint), + checkRequired("urlEndpointRequest", urlEndpointRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): UrlEndpoint = urlEndpoint + fun _body(): UrlEndpointRequest = urlEndpointRequest override fun _headers(): Headers = additionalHeaders @@ -193,14 +196,14 @@ private constructor( } return other is UrlEndpointCreateParams && - urlEndpoint == other.urlEndpoint && + urlEndpointRequest == other.urlEndpointRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(urlEndpoint, additionalHeaders, additionalQueryParams) + Objects.hash(urlEndpointRequest, additionalHeaders, additionalQueryParams) override fun toString() = - "UrlEndpointCreateParams{urlEndpoint=$urlEndpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "UrlEndpointCreateParams{urlEndpointRequest=$urlEndpointRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt deleted file mode 100644 index 2abf66c0..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponse.kt +++ /dev/null @@ -1,825 +0,0 @@ -// 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 UrlEndpointCreateResponse -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 [UrlEndpointCreateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .description() - * .origins() - * .urlPrefix() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UrlEndpointCreateResponse]. */ - 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(urlEndpointCreateResponse: UrlEndpointCreateResponse) = apply { - id = urlEndpointCreateResponse.id - description = urlEndpointCreateResponse.description - origins = urlEndpointCreateResponse.origins.map { it.toMutableList() } - urlPrefix = urlEndpointCreateResponse.urlPrefix - urlRewriter = urlEndpointCreateResponse.urlRewriter - additionalProperties = urlEndpointCreateResponse.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 [UrlEndpointCreateResponse]. - * - * 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(): UrlEndpointCreateResponse = - UrlEndpointCreateResponse( - 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(): UrlEndpointCreateResponse = 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 UrlEndpointCreateResponse && - 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() = - "UrlEndpointCreateResponse{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/UrlEndpointListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt deleted file mode 100644 index 42d660f9..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponse.kt +++ /dev/null @@ -1,825 +0,0 @@ -// 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 UrlEndpointListResponse -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 [UrlEndpointListResponse]. - * - * The following fields are required: - * ```java - * .id() - * .description() - * .origins() - * .urlPrefix() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UrlEndpointListResponse]. */ - 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(urlEndpointListResponse: UrlEndpointListResponse) = apply { - id = urlEndpointListResponse.id - description = urlEndpointListResponse.description - origins = urlEndpointListResponse.origins.map { it.toMutableList() } - urlPrefix = urlEndpointListResponse.urlPrefix - urlRewriter = urlEndpointListResponse.urlRewriter - additionalProperties = urlEndpointListResponse.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 [UrlEndpointListResponse]. - * - * 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(): UrlEndpointListResponse = - UrlEndpointListResponse( - 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(): UrlEndpointListResponse = 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 UrlEndpointListResponse && - 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() = - "UrlEndpointListResponse{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/UrlEndpoint.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpoint.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt index b1c839cf..40f3d600 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpoint.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt @@ -30,7 +30,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Schema for URL endpoint resource. */ -class UrlEndpoint +class UrlEndpointRequest private constructor( private val description: JsonField, private val origins: JsonField>, @@ -133,7 +133,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UrlEndpoint]. + * Returns a mutable builder for constructing an instance of [UrlEndpointRequest]. * * The following fields are required: * ```java @@ -143,7 +143,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UrlEndpoint]. */ + /** A builder for [UrlEndpointRequest]. */ class Builder internal constructor() { private var description: JsonField? = null @@ -153,12 +153,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(urlEndpoint: UrlEndpoint) = apply { - description = urlEndpoint.description - origins = urlEndpoint.origins.map { it.toMutableList() } - urlPrefix = urlEndpoint.urlPrefix - urlRewriter = urlEndpoint.urlRewriter - additionalProperties = urlEndpoint.additionalProperties.toMutableMap() + 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. */ @@ -262,7 +262,7 @@ private constructor( } /** - * Returns an immutable instance of [UrlEndpoint]. + * Returns an immutable instance of [UrlEndpointRequest]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -273,8 +273,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UrlEndpoint = - UrlEndpoint( + fun build(): UrlEndpointRequest = + UrlEndpointRequest( checkRequired("description", description), (origins ?: JsonMissing.of()).map { it.toImmutable() }, urlPrefix, @@ -285,7 +285,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UrlEndpoint = apply { + fun validate(): UrlEndpointRequest = apply { if (validated) { return@apply } @@ -732,7 +732,7 @@ private constructor( return true } - return other is UrlEndpoint && + return other is UrlEndpointRequest && description == other.description && origins == other.origins && urlPrefix == other.urlPrefix && @@ -747,5 +747,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UrlEndpoint{description=$description, origins=$origins, urlPrefix=$urlPrefix, urlRewriter=$urlRewriter, additionalProperties=$additionalProperties}" + "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/UrlEndpointGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt index e595cbd3..e6bbbd71 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt @@ -30,7 +30,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** URL‑endpoint object as returned by the API. */ -class UrlEndpointGetResponse +class UrlEndpointResponse private constructor( private val id: JsonField, private val description: JsonField, @@ -151,7 +151,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UrlEndpointGetResponse]. + * Returns a mutable builder for constructing an instance of [UrlEndpointResponse]. * * The following fields are required: * ```java @@ -164,7 +164,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UrlEndpointGetResponse]. */ + /** A builder for [UrlEndpointResponse]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -175,13 +175,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(urlEndpointGetResponse: UrlEndpointGetResponse) = apply { - id = urlEndpointGetResponse.id - description = urlEndpointGetResponse.description - origins = urlEndpointGetResponse.origins.map { it.toMutableList() } - urlPrefix = urlEndpointGetResponse.urlPrefix - urlRewriter = urlEndpointGetResponse.urlRewriter - additionalProperties = urlEndpointGetResponse.additionalProperties.toMutableMap() + 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() } /** @@ -314,7 +314,7 @@ private constructor( } /** - * Returns an immutable instance of [UrlEndpointGetResponse]. + * Returns an immutable instance of [UrlEndpointResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -328,8 +328,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UrlEndpointGetResponse = - UrlEndpointGetResponse( + fun build(): UrlEndpointResponse = + UrlEndpointResponse( checkRequired("id", id), checkRequired("description", description), checkRequired("origins", origins).map { it.toImmutable() }, @@ -341,7 +341,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UrlEndpointGetResponse = apply { + fun validate(): UrlEndpointResponse = apply { if (validated) { return@apply } @@ -805,7 +805,7 @@ private constructor( return true } - return other is UrlEndpointGetResponse && + return other is UrlEndpointResponse && id == other.id && description == other.description && origins == other.origins && @@ -821,5 +821,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UrlEndpointGetResponse{id=$id, description=$description, origins=$origins, urlPrefix=$urlPrefix, urlRewriter=$urlRewriter, additionalProperties=$additionalProperties}" + "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 index caf4749a..0af7b50e 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt @@ -18,7 +18,7 @@ import kotlin.jvm.optionals.getOrNull class UrlEndpointUpdateParams private constructor( private val id: String?, - private val urlEndpoint: UrlEndpoint, + private val urlEndpointRequest: UrlEndpointRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -30,9 +30,10 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** Schema for URL endpoint resource. */ - fun urlEndpoint(): UrlEndpoint = urlEndpoint + fun urlEndpointRequest(): UrlEndpointRequest = urlEndpointRequest - fun _additionalBodyProperties(): Map = urlEndpoint._additionalProperties() + fun _additionalBodyProperties(): Map = + urlEndpointRequest._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -49,7 +50,7 @@ private constructor( * * The following fields are required: * ```java - * .urlEndpoint() + * .urlEndpointRequest() * ``` */ @JvmStatic fun builder() = Builder() @@ -59,14 +60,14 @@ private constructor( class Builder internal constructor() { private var id: String? = null - private var urlEndpoint: UrlEndpoint? = 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 - urlEndpoint = urlEndpointUpdateParams.urlEndpoint + urlEndpointRequest = urlEndpointUpdateParams.urlEndpointRequest additionalHeaders = urlEndpointUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = urlEndpointUpdateParams.additionalQueryParams.toBuilder() } @@ -81,7 +82,9 @@ private constructor( fun id(id: Optional) = id(id.getOrNull()) /** Schema for URL endpoint resource. */ - fun urlEndpoint(urlEndpoint: UrlEndpoint) = apply { this.urlEndpoint = urlEndpoint } + fun urlEndpointRequest(urlEndpointRequest: UrlEndpointRequest) = apply { + this.urlEndpointRequest = urlEndpointRequest + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -188,7 +191,7 @@ private constructor( * * The following fields are required: * ```java - * .urlEndpoint() + * .urlEndpointRequest() * ``` * * @throws IllegalStateException if any required field is unset. @@ -196,13 +199,13 @@ private constructor( fun build(): UrlEndpointUpdateParams = UrlEndpointUpdateParams( id, - checkRequired("urlEndpoint", urlEndpoint), + checkRequired("urlEndpointRequest", urlEndpointRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): UrlEndpoint = urlEndpoint + fun _body(): UrlEndpointRequest = urlEndpointRequest fun _pathParam(index: Int): String = when (index) { @@ -221,14 +224,14 @@ private constructor( return other is UrlEndpointUpdateParams && id == other.id && - urlEndpoint == other.urlEndpoint && + urlEndpointRequest == other.urlEndpointRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(id, urlEndpoint, additionalHeaders, additionalQueryParams) + Objects.hash(id, urlEndpointRequest, additionalHeaders, additionalQueryParams) override fun toString() = - "UrlEndpointUpdateParams{id=$id, urlEndpoint=$urlEndpoint, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "UrlEndpointUpdateParams{id=$id, urlEndpointRequest=$urlEndpointRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt deleted file mode 100644 index 0a01479c..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponse.kt +++ /dev/null @@ -1,825 +0,0 @@ -// 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 UrlEndpointUpdateResponse -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 [UrlEndpointUpdateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .description() - * .origins() - * .urlPrefix() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UrlEndpointUpdateResponse]. */ - 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(urlEndpointUpdateResponse: UrlEndpointUpdateResponse) = apply { - id = urlEndpointUpdateResponse.id - description = urlEndpointUpdateResponse.description - origins = urlEndpointUpdateResponse.origins.map { it.toMutableList() } - urlPrefix = urlEndpointUpdateResponse.urlPrefix - urlRewriter = urlEndpointUpdateResponse.urlRewriter - additionalProperties = urlEndpointUpdateResponse.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 [UrlEndpointUpdateResponse]. - * - * 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(): UrlEndpointUpdateResponse = - UrlEndpointUpdateResponse( - 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(): UrlEndpointUpdateResponse = 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 UrlEndpointUpdateResponse && - 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() = - "UrlEndpointUpdateResponse{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/services/async/accounts/UrlEndpointServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt index 884b8832..334612e2 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 @@ -7,14 +7,11 @@ 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.UrlEndpointCreateResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -36,14 +33,14 @@ interface UrlEndpointServiceAsync { * **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns the resulting * object. */ - fun create(params: UrlEndpointCreateParams): CompletableFuture = + fun create(params: UrlEndpointCreateParams): CompletableFuture = create(params, RequestOptions.none()) /** @see create */ fun create( params: UrlEndpointCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * **Note:** This API is currently in beta. Updates the URL‑endpoint identified by `id` and @@ -52,46 +49,45 @@ interface UrlEndpointServiceAsync { fun update( id: String, params: UrlEndpointUpdateParams, - ): CompletableFuture = update(id, params, RequestOptions.none()) + ): CompletableFuture = update(id, params, RequestOptions.none()) /** @see update */ fun update( id: String, params: UrlEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: UrlEndpointUpdateParams): CompletableFuture = + fun update(params: UrlEndpointUpdateParams): CompletableFuture = update(params, RequestOptions.none()) /** @see update */ fun update( params: UrlEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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()) + fun list(): CompletableFuture> = list(UrlEndpointListParams.none()) /** @see list */ fun list( params: UrlEndpointListParams = UrlEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see list */ fun list( params: UrlEndpointListParams = UrlEndpointListParams.none() - ): CompletableFuture> = list(params, RequestOptions.none()) + ): CompletableFuture> = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture> = + fun list(requestOptions: RequestOptions): CompletableFuture> = list(UrlEndpointListParams.none(), requestOptions) /** @@ -128,7 +124,7 @@ interface UrlEndpointServiceAsync { delete(id, UrlEndpointDeleteParams.none(), requestOptions) /** **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified by `id`. */ - fun get(id: String): CompletableFuture = + fun get(id: String): CompletableFuture = get(id, UrlEndpointGetParams.none()) /** @see get */ @@ -136,27 +132,27 @@ interface UrlEndpointServiceAsync { id: String, params: UrlEndpointGetParams = UrlEndpointGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: UrlEndpointGetParams = UrlEndpointGetParams.none(), - ): CompletableFuture = get(id, params, RequestOptions.none()) + ): CompletableFuture = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: UrlEndpointGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see get */ - fun get(params: UrlEndpointGetParams): CompletableFuture = + fun get(params: UrlEndpointGetParams): CompletableFuture = get(params, RequestOptions.none()) /** @see get */ - fun get(id: String, requestOptions: RequestOptions): CompletableFuture = + fun get(id: String, requestOptions: RequestOptions): CompletableFuture = get(id, UrlEndpointGetParams.none(), requestOptions) /** @@ -180,14 +176,14 @@ interface UrlEndpointServiceAsync { */ fun create( params: UrlEndpointCreateParams - ): CompletableFuture> = + ): CompletableFuture> = create(params, RequestOptions.none()) /** @see create */ fun create( params: UrlEndpointCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/accounts/url-endpoints/{id}`, but is otherwise @@ -196,7 +192,7 @@ interface UrlEndpointServiceAsync { fun update( id: String, params: UrlEndpointUpdateParams, - ): CompletableFuture> = + ): CompletableFuture> = update(id, params, RequestOptions.none()) /** @see update */ @@ -204,44 +200,44 @@ interface UrlEndpointServiceAsync { id: String, params: UrlEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ fun update( params: UrlEndpointUpdateParams - ): CompletableFuture> = + ): CompletableFuture> = update(params, RequestOptions.none()) /** @see update */ fun update( params: UrlEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/accounts/url-endpoints`, but is otherwise the * same as [UrlEndpointServiceAsync.list]. */ - fun list(): CompletableFuture>> = + fun list(): CompletableFuture>> = list(UrlEndpointListParams.none()) /** @see list */ fun list( params: UrlEndpointListParams = UrlEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + ): CompletableFuture>> /** @see list */ fun list( params: UrlEndpointListParams = UrlEndpointListParams.none() - ): CompletableFuture>> = + ): CompletableFuture>> = list(params, RequestOptions.none()) /** @see list */ fun list( requestOptions: RequestOptions - ): CompletableFuture>> = + ): CompletableFuture>> = list(UrlEndpointListParams.none(), requestOptions) /** @@ -283,7 +279,7 @@ interface UrlEndpointServiceAsync { * 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> = + fun get(id: String): CompletableFuture> = get(id, UrlEndpointGetParams.none()) /** @see get */ @@ -291,33 +287,33 @@ interface UrlEndpointServiceAsync { id: String, params: UrlEndpointGetParams = UrlEndpointGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: UrlEndpointGetParams = UrlEndpointGetParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: UrlEndpointGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see get */ fun get( params: UrlEndpointGetParams - ): CompletableFuture> = + ): CompletableFuture> = get(params, RequestOptions.none()) /** @see get */ fun get( id: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): 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 index 45bf38ac..de716666 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/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt @@ -18,14 +18,11 @@ 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.UrlEndpointCreateResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -45,21 +42,21 @@ class UrlEndpointServiceAsyncImpl internal constructor(private val clientOptions override fun create( params: UrlEndpointCreateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/accounts/url-endpoints withRawResponse().create(params, requestOptions).thenApply { it.parse() } override fun update( params: UrlEndpointUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // put /v1/accounts/url-endpoints/{id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } override fun list( params: UrlEndpointListParams, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = // get /v1/accounts/url-endpoints withRawResponse().list(params, requestOptions).thenApply { it.parse() } @@ -73,7 +70,7 @@ class UrlEndpointServiceAsyncImpl internal constructor(private val clientOptions override fun get( params: UrlEndpointGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/accounts/url-endpoints/{id} withRawResponse().get(params, requestOptions).thenApply { it.parse() } @@ -90,13 +87,13 @@ class UrlEndpointServiceAsyncImpl internal constructor(private val clientOptions clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: UrlEndpointCreateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -121,13 +118,13 @@ class UrlEndpointServiceAsyncImpl internal constructor(private val clientOptions } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: UrlEndpointUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -155,13 +152,13 @@ class UrlEndpointServiceAsyncImpl internal constructor(private val clientOptions } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: UrlEndpointListParams, requestOptions: RequestOptions, - ): CompletableFuture>> { + ): CompletableFuture>> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -212,13 +209,13 @@ class UrlEndpointServiceAsyncImpl internal constructor(private val clientOptions } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun get( params: UrlEndpointGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/main/kotlin/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 56d86643..bdd10fd3 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 @@ -8,14 +8,11 @@ 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.UrlEndpointCreateResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateResponse import java.util.function.Consumer interface UrlEndpointService { @@ -36,20 +33,20 @@ interface UrlEndpointService { * **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns the resulting * object. */ - fun create(params: UrlEndpointCreateParams): UrlEndpointCreateResponse = + fun create(params: UrlEndpointCreateParams): UrlEndpointResponse = create(params, RequestOptions.none()) /** @see create */ fun create( params: UrlEndpointCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): UrlEndpointCreateResponse + ): 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): UrlEndpointUpdateResponse = + fun update(id: String, params: UrlEndpointUpdateParams): UrlEndpointResponse = update(id, params, RequestOptions.none()) /** @see update */ @@ -57,37 +54,37 @@ interface UrlEndpointService { id: String, params: UrlEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): UrlEndpointUpdateResponse = update(params.toBuilder().id(id).build(), requestOptions) + ): UrlEndpointResponse = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ - fun update(params: UrlEndpointUpdateParams): UrlEndpointUpdateResponse = + fun update(params: UrlEndpointUpdateParams): UrlEndpointResponse = update(params, RequestOptions.none()) /** @see update */ fun update( params: UrlEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): UrlEndpointUpdateResponse + ): 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()) + fun list(): List = list(UrlEndpointListParams.none()) /** @see list */ fun list( params: UrlEndpointListParams = UrlEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): List + ): List /** @see list */ fun list( params: UrlEndpointListParams = UrlEndpointListParams.none() - ): List = list(params, RequestOptions.none()) + ): List = list(params, RequestOptions.none()) /** @see list */ - fun list(requestOptions: RequestOptions): List = + fun list(requestOptions: RequestOptions): List = list(UrlEndpointListParams.none(), requestOptions) /** @@ -121,33 +118,32 @@ interface UrlEndpointService { delete(id, UrlEndpointDeleteParams.none(), requestOptions) /** **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified by `id`. */ - fun get(id: String): UrlEndpointGetResponse = get(id, UrlEndpointGetParams.none()) + fun get(id: String): UrlEndpointResponse = get(id, UrlEndpointGetParams.none()) /** @see get */ fun get( id: String, params: UrlEndpointGetParams = UrlEndpointGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): UrlEndpointGetResponse = get(params.toBuilder().id(id).build(), requestOptions) + ): UrlEndpointResponse = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ fun get( id: String, params: UrlEndpointGetParams = UrlEndpointGetParams.none(), - ): UrlEndpointGetResponse = get(id, params, RequestOptions.none()) + ): UrlEndpointResponse = get(id, params, RequestOptions.none()) /** @see get */ fun get( params: UrlEndpointGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): UrlEndpointGetResponse + ): UrlEndpointResponse /** @see get */ - fun get(params: UrlEndpointGetParams): UrlEndpointGetResponse = - get(params, RequestOptions.none()) + fun get(params: UrlEndpointGetParams): UrlEndpointResponse = get(params, RequestOptions.none()) /** @see get */ - fun get(id: String, requestOptions: RequestOptions): UrlEndpointGetResponse = + fun get(id: String, requestOptions: RequestOptions): UrlEndpointResponse = get(id, UrlEndpointGetParams.none(), requestOptions) /** @@ -169,7 +165,7 @@ interface UrlEndpointService { * same as [UrlEndpointService.create]. */ @MustBeClosed - fun create(params: UrlEndpointCreateParams): HttpResponseFor = + fun create(params: UrlEndpointCreateParams): HttpResponseFor = create(params, RequestOptions.none()) /** @see create */ @@ -177,7 +173,7 @@ interface UrlEndpointService { fun create( params: UrlEndpointCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/accounts/url-endpoints/{id}`, but is otherwise @@ -187,7 +183,7 @@ interface UrlEndpointService { fun update( id: String, params: UrlEndpointUpdateParams, - ): HttpResponseFor = update(id, params, RequestOptions.none()) + ): HttpResponseFor = update(id, params, RequestOptions.none()) /** @see update */ @MustBeClosed @@ -195,12 +191,12 @@ interface UrlEndpointService { id: String, params: UrlEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = update(params.toBuilder().id(id).build(), requestOptions) /** @see update */ @MustBeClosed - fun update(params: UrlEndpointUpdateParams): HttpResponseFor = + fun update(params: UrlEndpointUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) /** @see update */ @@ -208,32 +204,31 @@ interface UrlEndpointService { fun update( params: UrlEndpointUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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()) + fun list(): HttpResponseFor> = list(UrlEndpointListParams.none()) /** @see list */ @MustBeClosed fun list( params: UrlEndpointListParams = UrlEndpointListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + ): HttpResponseFor> /** @see list */ @MustBeClosed fun list( params: UrlEndpointListParams = UrlEndpointListParams.none() - ): HttpResponseFor> = list(params, RequestOptions.none()) + ): HttpResponseFor> = list(params, RequestOptions.none()) /** @see list */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor> = + fun list(requestOptions: RequestOptions): HttpResponseFor> = list(UrlEndpointListParams.none(), requestOptions) /** @@ -280,7 +275,7 @@ interface UrlEndpointService { * the same as [UrlEndpointService.get]. */ @MustBeClosed - fun get(id: String): HttpResponseFor = + fun get(id: String): HttpResponseFor = get(id, UrlEndpointGetParams.none()) /** @see get */ @@ -289,7 +284,7 @@ interface UrlEndpointService { id: String, params: UrlEndpointGetParams = UrlEndpointGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = get(params.toBuilder().id(id).build(), requestOptions) /** @see get */ @@ -297,26 +292,23 @@ interface UrlEndpointService { fun get( id: String, params: UrlEndpointGetParams = UrlEndpointGetParams.none(), - ): HttpResponseFor = get(id, params, RequestOptions.none()) + ): HttpResponseFor = get(id, params, RequestOptions.none()) /** @see get */ @MustBeClosed fun get( params: UrlEndpointGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see get */ @MustBeClosed - fun get(params: UrlEndpointGetParams): HttpResponseFor = + fun get(params: UrlEndpointGetParams): HttpResponseFor = get(params, RequestOptions.none()) /** @see get */ @MustBeClosed - fun get( - id: String, - requestOptions: RequestOptions, - ): HttpResponseFor = + 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 index 6c52c43e..5d2e17e0 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/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt @@ -18,14 +18,11 @@ 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.UrlEndpointCreateResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -44,21 +41,21 @@ class UrlEndpointServiceImpl internal constructor(private val clientOptions: Cli override fun create( params: UrlEndpointCreateParams, requestOptions: RequestOptions, - ): UrlEndpointCreateResponse = + ): UrlEndpointResponse = // post /v1/accounts/url-endpoints withRawResponse().create(params, requestOptions).parse() override fun update( params: UrlEndpointUpdateParams, requestOptions: RequestOptions, - ): UrlEndpointUpdateResponse = + ): UrlEndpointResponse = // put /v1/accounts/url-endpoints/{id} withRawResponse().update(params, requestOptions).parse() override fun list( params: UrlEndpointListParams, requestOptions: RequestOptions, - ): List = + ): List = // get /v1/accounts/url-endpoints withRawResponse().list(params, requestOptions).parse() @@ -70,7 +67,7 @@ class UrlEndpointServiceImpl internal constructor(private val clientOptions: Cli override fun get( params: UrlEndpointGetParams, requestOptions: RequestOptions, - ): UrlEndpointGetResponse = + ): UrlEndpointResponse = // get /v1/accounts/url-endpoints/{id} withRawResponse().get(params, requestOptions).parse() @@ -87,13 +84,13 @@ class UrlEndpointServiceImpl internal constructor(private val clientOptions: Cli clientOptions.toBuilder().apply(modifier::accept).build() ) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: UrlEndpointCreateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -115,13 +112,13 @@ class UrlEndpointServiceImpl internal constructor(private val clientOptions: Cli } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: UrlEndpointUpdateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -146,13 +143,13 @@ class UrlEndpointServiceImpl internal constructor(private val clientOptions: Cli } } - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: UrlEndpointListParams, requestOptions: RequestOptions, - ): HttpResponseFor> { + ): HttpResponseFor> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -197,13 +194,13 @@ class UrlEndpointServiceImpl internal constructor(private val clientOptions: Cli } } - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun get( params: UrlEndpointGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) diff --git a/image-kit-java-core/src/test/kotlin/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 e8defa1a..98b6d47a 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 @@ -11,7 +11,7 @@ internal class OriginCreateParamsTest { fun create() { OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -29,7 +29,7 @@ internal class OriginCreateParamsTest { val params = OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -45,8 +45,8 @@ internal class OriginCreateParamsTest { assertThat(body) .isEqualTo( - OriginCreateParams.Origin.ofS3( - OriginCreateParams.Origin.S3.builder() + OriginRequest.ofS3( + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -64,7 +64,7 @@ internal class OriginCreateParamsTest { val params = OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -77,8 +77,8 @@ internal class OriginCreateParamsTest { assertThat(body) .isEqualTo( - OriginCreateParams.Origin.ofS3( - OriginCreateParams.Origin.S3.builder() + OriginRequest.ofS3( + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") 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/OriginUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt index e9be0a35..f8a57949 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 @@ -12,7 +12,7 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -31,7 +31,7 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -51,7 +51,7 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -67,8 +67,8 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - OriginUpdateParams.Origin.ofS3( - OriginUpdateParams.Origin.S3.builder() + OriginRequest.ofS3( + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -87,7 +87,7 @@ internal class OriginUpdateParamsTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -100,8 +100,8 @@ internal class OriginUpdateParamsTest { assertThat(body) .isEqualTo( - OriginUpdateParams.Origin.ofS3( - OriginUpdateParams.Origin.S3.builder() + OriginRequest.ofS3( + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") 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 index fefb3a58..93293ea4 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt @@ -10,13 +10,13 @@ internal class UrlEndpointCreateParamsTest { @Test fun create() { UrlEndpointCreateParams.builder() - .urlEndpoint( - UrlEndpoint.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -29,13 +29,13 @@ internal class UrlEndpointCreateParamsTest { fun body() { val params = UrlEndpointCreateParams.builder() - .urlEndpoint( - UrlEndpoint.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -47,12 +47,12 @@ internal class UrlEndpointCreateParamsTest { assertThat(body) .isEqualTo( - UrlEndpoint.builder() + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -64,12 +64,14 @@ internal class UrlEndpointCreateParamsTest { fun bodyWithoutOptionalFields() { val params = UrlEndpointCreateParams.builder() - .urlEndpoint(UrlEndpoint.builder().description("My custom URL endpoint").build()) + .urlEndpointRequest( + UrlEndpointRequest.builder().description("My custom URL endpoint").build() + ) .build() val body = params._body() assertThat(body) - .isEqualTo(UrlEndpoint.builder().description("My custom URL endpoint").build()) + .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/UrlEndpointCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt deleted file mode 100644 index cfdc7b73..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateResponseTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -// 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 UrlEndpointCreateResponseTest { - - @Test - fun create() { - val urlEndpointCreateResponse = - UrlEndpointCreateResponse.builder() - .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .addOrigin("origin-id-2") - .urlPrefix("product-images") - .cloudinaryUrlRewriter(true) - .build() - - assertThat(urlEndpointCreateResponse.id()).isEqualTo("id") - assertThat(urlEndpointCreateResponse.description()).isEqualTo("My custom URL endpoint") - assertThat(urlEndpointCreateResponse.origins()) - .containsExactly("origin-id-1", "origin-id-2") - assertThat(urlEndpointCreateResponse.urlPrefix()).isEqualTo("product-images") - assertThat(urlEndpointCreateResponse.urlRewriter()) - .contains( - UrlEndpointCreateResponse.UrlRewriter.ofCloudinary( - UrlEndpointCreateResponse.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val urlEndpointCreateResponse = - UrlEndpointCreateResponse.builder() - .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .addOrigin("origin-id-2") - .urlPrefix("product-images") - .cloudinaryUrlRewriter(true) - .build() - - val roundtrippedUrlEndpointCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(urlEndpointCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedUrlEndpointCreateResponse).isEqualTo(urlEndpointCreateResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt deleted file mode 100644 index ea471e4a..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListResponseTest.kt +++ /dev/null @@ -1,59 +0,0 @@ -// 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 UrlEndpointListResponseTest { - - @Test - fun create() { - val urlEndpointListResponse = - UrlEndpointListResponse.builder() - .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .addOrigin("origin-id-2") - .urlPrefix("product-images") - .cloudinaryUrlRewriter(true) - .build() - - assertThat(urlEndpointListResponse.id()).isEqualTo("id") - assertThat(urlEndpointListResponse.description()).isEqualTo("My custom URL endpoint") - assertThat(urlEndpointListResponse.origins()).containsExactly("origin-id-1", "origin-id-2") - assertThat(urlEndpointListResponse.urlPrefix()).isEqualTo("product-images") - assertThat(urlEndpointListResponse.urlRewriter()) - .contains( - UrlEndpointListResponse.UrlRewriter.ofCloudinary( - UrlEndpointListResponse.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val urlEndpointListResponse = - UrlEndpointListResponse.builder() - .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .addOrigin("origin-id-2") - .urlPrefix("product-images") - .cloudinaryUrlRewriter(true) - .build() - - val roundtrippedUrlEndpointListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(urlEndpointListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedUrlEndpointListResponse).isEqualTo(urlEndpointListResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt similarity index 55% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt index b20b173e..7c2de876 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt @@ -8,29 +8,29 @@ import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class UrlEndpointTest { +internal class UrlEndpointRequestTest { @Test fun create() { - val urlEndpoint = - UrlEndpoint.builder() + val urlEndpointRequest = + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) .build() - assertThat(urlEndpoint.description()).isEqualTo("My custom URL endpoint") - assertThat(urlEndpoint.origins().getOrNull()).containsExactly("origin-id-1") - assertThat(urlEndpoint.urlPrefix()).contains("product-images") - assertThat(urlEndpoint.urlRewriter()) + 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( - UrlEndpoint.UrlRewriter.ofCloudinary( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.ofCloudinary( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -40,24 +40,24 @@ internal class UrlEndpointTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val urlEndpoint = - UrlEndpoint.builder() + val urlEndpointRequest = + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) .build() - val roundtrippedUrlEndpoint = + val roundtrippedUrlEndpointRequest = jsonMapper.readValue( - jsonMapper.writeValueAsString(urlEndpoint), - jacksonTypeRef(), + jsonMapper.writeValueAsString(urlEndpointRequest), + jacksonTypeRef(), ) - assertThat(roundtrippedUrlEndpoint).isEqualTo(urlEndpoint) + assertThat(roundtrippedUrlEndpointRequest).isEqualTo(urlEndpointRequest) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt similarity index 53% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt index 8a4924cd..fa5854c1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt @@ -7,12 +7,12 @@ import com.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class UrlEndpointGetResponseTest { +internal class UrlEndpointResponseTest { @Test fun create() { - val urlEndpointGetResponse = - UrlEndpointGetResponse.builder() + val urlEndpointResponse = + UrlEndpointResponse.builder() .id("id") .description("My custom URL endpoint") .addOrigin("origin-id-1") @@ -21,14 +21,14 @@ internal class UrlEndpointGetResponseTest { .cloudinaryUrlRewriter(true) .build() - assertThat(urlEndpointGetResponse.id()).isEqualTo("id") - assertThat(urlEndpointGetResponse.description()).isEqualTo("My custom URL endpoint") - assertThat(urlEndpointGetResponse.origins()).containsExactly("origin-id-1", "origin-id-2") - assertThat(urlEndpointGetResponse.urlPrefix()).isEqualTo("product-images") - assertThat(urlEndpointGetResponse.urlRewriter()) + 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( - UrlEndpointGetResponse.UrlRewriter.ofCloudinary( - UrlEndpointGetResponse.UrlRewriter.Cloudinary.builder() + UrlEndpointResponse.UrlRewriter.ofCloudinary( + UrlEndpointResponse.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -38,8 +38,8 @@ internal class UrlEndpointGetResponseTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val urlEndpointGetResponse = - UrlEndpointGetResponse.builder() + val urlEndpointResponse = + UrlEndpointResponse.builder() .id("id") .description("My custom URL endpoint") .addOrigin("origin-id-1") @@ -48,12 +48,12 @@ internal class UrlEndpointGetResponseTest { .cloudinaryUrlRewriter(true) .build() - val roundtrippedUrlEndpointGetResponse = + val roundtrippedUrlEndpointResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(urlEndpointGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(urlEndpointResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedUrlEndpointGetResponse).isEqualTo(urlEndpointGetResponse) + 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 index a7ebb60a..434647b2 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/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt @@ -11,13 +11,13 @@ internal class UrlEndpointUpdateParamsTest { fun create() { UrlEndpointUpdateParams.builder() .id("id") - .urlEndpoint( - UrlEndpoint.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -31,7 +31,9 @@ internal class UrlEndpointUpdateParamsTest { val params = UrlEndpointUpdateParams.builder() .id("id") - .urlEndpoint(UrlEndpoint.builder().description("My custom URL endpoint").build()) + .urlEndpointRequest( + UrlEndpointRequest.builder().description("My custom URL endpoint").build() + ) .build() assertThat(params._pathParam(0)).isEqualTo("id") @@ -44,13 +46,13 @@ internal class UrlEndpointUpdateParamsTest { val params = UrlEndpointUpdateParams.builder() .id("id") - .urlEndpoint( - UrlEndpoint.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -62,12 +64,12 @@ internal class UrlEndpointUpdateParamsTest { assertThat(body) .isEqualTo( - UrlEndpoint.builder() + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -80,12 +82,14 @@ internal class UrlEndpointUpdateParamsTest { val params = UrlEndpointUpdateParams.builder() .id("id") - .urlEndpoint(UrlEndpoint.builder().description("My custom URL endpoint").build()) + .urlEndpointRequest( + UrlEndpointRequest.builder().description("My custom URL endpoint").build() + ) .build() val body = params._body() assertThat(body) - .isEqualTo(UrlEndpoint.builder().description("My custom URL endpoint").build()) + .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/UrlEndpointUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt deleted file mode 100644 index ea15aa1d..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateResponseTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -// 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 UrlEndpointUpdateResponseTest { - - @Test - fun create() { - val urlEndpointUpdateResponse = - UrlEndpointUpdateResponse.builder() - .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .addOrigin("origin-id-2") - .urlPrefix("product-images") - .cloudinaryUrlRewriter(true) - .build() - - assertThat(urlEndpointUpdateResponse.id()).isEqualTo("id") - assertThat(urlEndpointUpdateResponse.description()).isEqualTo("My custom URL endpoint") - assertThat(urlEndpointUpdateResponse.origins()) - .containsExactly("origin-id-1", "origin-id-2") - assertThat(urlEndpointUpdateResponse.urlPrefix()).isEqualTo("product-images") - assertThat(urlEndpointUpdateResponse.urlRewriter()) - .contains( - UrlEndpointUpdateResponse.UrlRewriter.ofCloudinary( - UrlEndpointUpdateResponse.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val urlEndpointUpdateResponse = - UrlEndpointUpdateResponse.builder() - .id("id") - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .addOrigin("origin-id-2") - .urlPrefix("product-images") - .cloudinaryUrlRewriter(true) - .build() - - val roundtrippedUrlEndpointUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(urlEndpointUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedUrlEndpointUpdateResponse).isEqualTo(urlEndpointUpdateResponse) - } -} 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 2119f16b..55c67968 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 @@ -5,6 +5,7 @@ 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 @@ -28,7 +29,7 @@ internal class OriginServiceAsyncTest { originServiceAsync.create( OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -61,7 +62,7 @@ internal class OriginServiceAsyncTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") 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 cf838cbf..e95e7e55 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,8 +4,8 @@ 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.UrlEndpoint 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 @@ -25,16 +25,16 @@ internal class UrlEndpointServiceAsyncTest { .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() - val urlEndpointFuture = + val urlEndpointResponseFuture = urlEndpointServiceAsync.create( UrlEndpointCreateParams.builder() - .urlEndpoint( - UrlEndpoint.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -43,8 +43,8 @@ internal class UrlEndpointServiceAsyncTest { .build() ) - val urlEndpoint = urlEndpointFuture.get() - urlEndpoint.validate() + val urlEndpointResponse = urlEndpointResponseFuture.get() + urlEndpointResponse.validate() } @Disabled("Prism tests are disabled") @@ -58,17 +58,17 @@ internal class UrlEndpointServiceAsyncTest { .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() - val urlEndpointFuture = + val urlEndpointResponseFuture = urlEndpointServiceAsync.update( UrlEndpointUpdateParams.builder() .id("id") - .urlEndpoint( - UrlEndpoint.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -77,8 +77,8 @@ internal class UrlEndpointServiceAsyncTest { .build() ) - val urlEndpoint = urlEndpointFuture.get() - urlEndpoint.validate() + val urlEndpointResponse = urlEndpointResponseFuture.get() + urlEndpointResponse.validate() } @Disabled("Prism tests are disabled") @@ -92,10 +92,10 @@ internal class UrlEndpointServiceAsyncTest { .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() - val urlEndpointsFuture = urlEndpointServiceAsync.list() + val urlEndpointResponsesFuture = urlEndpointServiceAsync.list() - val urlEndpoints = urlEndpointsFuture.get() - urlEndpoints.forEach { it.validate() } + val urlEndpointResponses = urlEndpointResponsesFuture.get() + urlEndpointResponses.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -125,9 +125,9 @@ internal class UrlEndpointServiceAsyncTest { .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() - val urlEndpointFuture = urlEndpointServiceAsync.get("id") + val urlEndpointResponseFuture = urlEndpointServiceAsync.get("id") - val urlEndpoint = urlEndpointFuture.get() - urlEndpoint.validate() + val urlEndpointResponse = urlEndpointResponseFuture.get() + urlEndpointResponse.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 index a42d7f4a..324a0687 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 @@ -5,6 +5,7 @@ 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 @@ -28,7 +29,7 @@ internal class OriginServiceTest { originService.create( OriginCreateParams.builder() .origin( - OriginCreateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") @@ -60,7 +61,7 @@ internal class OriginServiceTest { OriginUpdateParams.builder() .id("id") .origin( - OriginUpdateParams.Origin.S3.builder() + OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") .name("My S3 Origin") 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 6341f99e..cdd0f580 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,8 +4,8 @@ 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.UrlEndpoint 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 @@ -25,16 +25,16 @@ internal class UrlEndpointServiceTest { .build() val urlEndpointService = client.accounts().urlEndpoints() - val urlEndpoint = + val urlEndpointResponse = urlEndpointService.create( UrlEndpointCreateParams.builder() - .urlEndpoint( - UrlEndpoint.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -43,7 +43,7 @@ internal class UrlEndpointServiceTest { .build() ) - urlEndpoint.validate() + urlEndpointResponse.validate() } @Disabled("Prism tests are disabled") @@ -57,17 +57,17 @@ internal class UrlEndpointServiceTest { .build() val urlEndpointService = client.accounts().urlEndpoints() - val urlEndpoint = + val urlEndpointResponse = urlEndpointService.update( UrlEndpointUpdateParams.builder() .id("id") - .urlEndpoint( - UrlEndpoint.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() .description("My custom URL endpoint") .addOrigin("origin-id-1") .urlPrefix("product-images") .urlRewriter( - UrlEndpoint.UrlRewriter.Cloudinary.builder() + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() .preserveAssetDeliveryTypes(true) .build() ) @@ -76,7 +76,7 @@ internal class UrlEndpointServiceTest { .build() ) - urlEndpoint.validate() + urlEndpointResponse.validate() } @Disabled("Prism tests are disabled") @@ -90,9 +90,9 @@ internal class UrlEndpointServiceTest { .build() val urlEndpointService = client.accounts().urlEndpoints() - val urlEndpoints = urlEndpointService.list() + val urlEndpointResponses = urlEndpointService.list() - urlEndpoints.forEach { it.validate() } + urlEndpointResponses.forEach { it.validate() } } @Disabled("Prism tests are disabled") @@ -120,8 +120,8 @@ internal class UrlEndpointServiceTest { .build() val urlEndpointService = client.accounts().urlEndpoints() - val urlEndpoint = urlEndpointService.get("id") + val urlEndpointResponse = urlEndpointService.get("id") - urlEndpoint.validate() + urlEndpointResponse.validate() } } From 20eee9d65aefa65657dc05f46b8d53f6b4182822 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 06:23:51 +0000 Subject: [PATCH 054/125] feat(api): manual updates --- .stats.yml | 2 +- .../beta/v2/files/FileUploadResponse.kt | 3618 +---------------- .../api/models/files/FileUploadResponse.kt | 3617 ---------------- .../MetadataGetResponse.kt => Metadata.kt} | 52 +- .../metadata/MetadataGetFromUrlResponse.kt | 3576 ---------------- .../async/files/MetadataServiceAsync.kt | 47 +- .../async/files/MetadataServiceAsyncImpl.kt | 18 +- .../blocking/files/MetadataService.kt | 46 +- .../blocking/files/MetadataServiceImpl.kt | 21 +- .../beta/v2/files/FileUploadResponseTest.kt | 61 +- .../models/files/FileUploadResponseTest.kt | 60 +- ...dataGetResponseTest.kt => MetadataTest.kt} | 90 +- .../MetadataGetFromUrlResponseTest.kt | 297 -- .../async/files/MetadataServiceAsyncTest.kt | 6 +- .../blocking/files/MetadataServiceTest.kt | 4 +- 15 files changed, 180 insertions(+), 11335 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{metadata/MetadataGetResponse.kt => Metadata.kt} (98%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{metadata/MetadataGetResponseTest.kt => MetadataTest.kt} (77%) delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt diff --git a/.stats.yml b/.stats.yml index e88489f2..eae87049 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-547b616849eececf3f5b1ea38ebe1dba718e1877c787e3642b9c91e552548789.yml openapi_spec_hash: fba0bf8c1ee034067ab6ae93f84abeae -config_hash: befd7c8f04cc5b4992ec11efe0d6934b +config_hash: 659d086a034de739b7423470b2c13ae0 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 72fb5e91..17406ed9 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,7 @@ 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 @@ -2146,3623 +2147,6 @@ private constructor( "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } - /** - * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the - * upload API response. - */ - 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}" - } - /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo private constructor( 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 fa6f9d79..65988000 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 @@ -2146,3623 +2146,6 @@ private constructor( "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } - /** - * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the - * upload API response. - */ - 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}" - } - /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo private constructor( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt index cca25a2a..69891ec1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.metadata +package com.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,7 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** JSON object containing metadata. */ -class MetadataGetResponse +class Metadata private constructor( private val audioCodec: JsonField, private val bitRate: JsonField, @@ -306,11 +306,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [MetadataGetResponse]. */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [MetadataGetResponse]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var audioCodec: JsonField = JsonMissing.of() @@ -330,22 +330,22 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadataGetResponse: MetadataGetResponse) = apply { - audioCodec = metadataGetResponse.audioCodec - bitRate = metadataGetResponse.bitRate - density = metadataGetResponse.density - duration = metadataGetResponse.duration - exif = metadataGetResponse.exif - format = metadataGetResponse.format - hasColorProfile = metadataGetResponse.hasColorProfile - hasTransparency = metadataGetResponse.hasTransparency - height = metadataGetResponse.height - pHash = metadataGetResponse.pHash - quality = metadataGetResponse.quality - size = metadataGetResponse.size - videoCodec = metadataGetResponse.videoCodec - width = metadataGetResponse.width - additionalProperties = metadataGetResponse.additionalProperties.toMutableMap() + 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). */ @@ -531,12 +531,12 @@ private constructor( } /** - * Returns an immutable instance of [MetadataGetResponse]. + * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): MetadataGetResponse = - MetadataGetResponse( + fun build(): Metadata = + Metadata( audioCodec, bitRate, density, @@ -557,7 +557,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MetadataGetResponse = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -3529,7 +3529,7 @@ private constructor( return true } - return other is MetadataGetResponse && + return other is Metadata && audioCodec == other.audioCodec && bitRate == other.bitRate && density == other.density && @@ -3570,5 +3570,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MetadataGetResponse{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}" + "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/metadata/MetadataGetFromUrlResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt deleted file mode 100644 index c88f4cbd..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponse.kt +++ /dev/null @@ -1,3576 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.metadata - -import 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 MetadataGetFromUrlResponse -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 [MetadataGetFromUrlResponse]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MetadataGetFromUrlResponse]. */ - 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(metadataGetFromUrlResponse: MetadataGetFromUrlResponse) = apply { - audioCodec = metadataGetFromUrlResponse.audioCodec - bitRate = metadataGetFromUrlResponse.bitRate - density = metadataGetFromUrlResponse.density - duration = metadataGetFromUrlResponse.duration - exif = metadataGetFromUrlResponse.exif - format = metadataGetFromUrlResponse.format - hasColorProfile = metadataGetFromUrlResponse.hasColorProfile - hasTransparency = metadataGetFromUrlResponse.hasTransparency - height = metadataGetFromUrlResponse.height - pHash = metadataGetFromUrlResponse.pHash - quality = metadataGetFromUrlResponse.quality - size = metadataGetFromUrlResponse.size - videoCodec = metadataGetFromUrlResponse.videoCodec - width = metadataGetFromUrlResponse.width - additionalProperties = metadataGetFromUrlResponse.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 [MetadataGetFromUrlResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MetadataGetFromUrlResponse = - MetadataGetFromUrlResponse( - audioCodec, - bitRate, - density, - duration, - exif, - format, - hasColorProfile, - hasTransparency, - height, - pHash, - quality, - size, - videoCodec, - width, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MetadataGetFromUrlResponse = 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 MetadataGetFromUrlResponse && - 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() = - "MetadataGetFromUrlResponse{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/services/async/files/MetadataServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt index 4520527f..1d7f3856 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 @@ -5,10 +5,9 @@ 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.MetadataGetFromUrlResponse import com.imagekit.api.models.files.metadata.MetadataGetParams -import com.imagekit.api.models.files.metadata.MetadataGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -33,52 +32,46 @@ interface MetadataServiceAsync { * 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()) + 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) + ): CompletableFuture = get(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see get */ fun get( fileId: String, params: MetadataGetParams = MetadataGetParams.none(), - ): CompletableFuture = get(fileId, params, RequestOptions.none()) + ): CompletableFuture = get(fileId, params, RequestOptions.none()) /** @see get */ fun get( params: MetadataGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see get */ - fun get(params: MetadataGetParams): CompletableFuture = + fun get(params: MetadataGetParams): CompletableFuture = get(params, RequestOptions.none()) /** @see get */ - fun get( - fileId: String, - requestOptions: RequestOptions, - ): CompletableFuture = + 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()) + fun getFromUrl(params: MetadataGetFromUrlParams): CompletableFuture = + getFromUrl(params, RequestOptions.none()) /** @see getFromUrl */ fun getFromUrl( params: MetadataGetFromUrlParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [MetadataServiceAsync] that provides access to raw HTTP responses for each method. @@ -98,7 +91,7 @@ interface MetadataServiceAsync { * Returns a raw HTTP response for `get /v1/files/{fileId}/metadata`, but is otherwise the * same as [MetadataServiceAsync.get]. */ - fun get(fileId: String): CompletableFuture> = + fun get(fileId: String): CompletableFuture> = get(fileId, MetadataGetParams.none()) /** @see get */ @@ -106,33 +99,30 @@ interface MetadataServiceAsync { fileId: String, params: MetadataGetParams = MetadataGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = get(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see get */ fun get( fileId: String, params: MetadataGetParams = MetadataGetParams.none(), - ): CompletableFuture> = - get(fileId, params, RequestOptions.none()) + ): CompletableFuture> = get(fileId, params, RequestOptions.none()) /** @see get */ fun get( params: MetadataGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see get */ - fun get( - params: MetadataGetParams - ): CompletableFuture> = + fun get(params: MetadataGetParams): CompletableFuture> = get(params, RequestOptions.none()) /** @see get */ fun get( fileId: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = get(fileId, MetadataGetParams.none(), requestOptions) /** @@ -141,13 +131,12 @@ interface MetadataServiceAsync { */ fun getFromUrl( params: MetadataGetFromUrlParams - ): CompletableFuture> = - getFromUrl(params, RequestOptions.none()) + ): CompletableFuture> = getFromUrl(params, RequestOptions.none()) /** @see getFromUrl */ fun getFromUrl( params: MetadataGetFromUrlParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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 index 5b78f236..b9a0336a 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 @@ -15,10 +15,9 @@ 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.MetadataGetFromUrlResponse import com.imagekit.api.models.files.metadata.MetadataGetParams -import com.imagekit.api.models.files.metadata.MetadataGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -38,14 +37,14 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C override fun get( params: MetadataGetParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/files/{fileId}/metadata withRawResponse().get(params, requestOptions).thenApply { it.parse() } override fun getFromUrl( params: MetadataGetFromUrlParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/files/metadata withRawResponse().getFromUrl(params, requestOptions).thenApply { it.parse() } @@ -62,13 +61,12 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C clientOptions.toBuilder().apply(modifier::accept).build() ) - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun get( params: MetadataGetParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fileId", params.fileId().getOrNull()) @@ -95,13 +93,13 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C } } - private val getFromUrlHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getFromUrlHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun getFromUrl( params: MetadataGetFromUrlParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) 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 ed9ded7f..d873401f 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 @@ -6,10 +6,9 @@ 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.MetadataGetFromUrlResponse import com.imagekit.api.models.files.metadata.MetadataGetParams -import com.imagekit.api.models.files.metadata.MetadataGetResponse import java.util.function.Consumer interface MetadataService { @@ -33,45 +32,43 @@ interface MetadataService { * You can also get the metadata in upload API response by passing `metadata` in * `responseFields` parameter. */ - fun get(fileId: String): MetadataGetResponse = get(fileId, MetadataGetParams.none()) + fun get(fileId: String): Metadata = get(fileId, MetadataGetParams.none()) /** @see get */ fun get( fileId: String, params: MetadataGetParams = MetadataGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): MetadataGetResponse = get(params.toBuilder().fileId(fileId).build(), requestOptions) + ): Metadata = get(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see get */ - fun get( - fileId: String, - params: MetadataGetParams = MetadataGetParams.none(), - ): MetadataGetResponse = get(fileId, params, RequestOptions.none()) + fun get(fileId: String, params: MetadataGetParams = MetadataGetParams.none()): Metadata = + get(fileId, params, RequestOptions.none()) /** @see get */ fun get( params: MetadataGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): MetadataGetResponse + ): Metadata /** @see get */ - fun get(params: MetadataGetParams): MetadataGetResponse = get(params, RequestOptions.none()) + fun get(params: MetadataGetParams): Metadata = get(params, RequestOptions.none()) /** @see get */ - fun get(fileId: String, requestOptions: RequestOptions): MetadataGetResponse = + 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): MetadataGetFromUrlResponse = + fun getFromUrl(params: MetadataGetFromUrlParams): Metadata = getFromUrl(params, RequestOptions.none()) /** @see getFromUrl */ fun getFromUrl( params: MetadataGetFromUrlParams, requestOptions: RequestOptions = RequestOptions.none(), - ): MetadataGetFromUrlResponse + ): Metadata /** A view of [MetadataService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -88,8 +85,7 @@ interface MetadataService { * same as [MetadataService.get]. */ @MustBeClosed - fun get(fileId: String): HttpResponseFor = - get(fileId, MetadataGetParams.none()) + fun get(fileId: String): HttpResponseFor = get(fileId, MetadataGetParams.none()) /** @see get */ @MustBeClosed @@ -97,7 +93,7 @@ interface MetadataService { fileId: String, params: MetadataGetParams = MetadataGetParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = get(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see get */ @@ -105,26 +101,23 @@ interface MetadataService { fun get( fileId: String, params: MetadataGetParams = MetadataGetParams.none(), - ): HttpResponseFor = get(fileId, params, RequestOptions.none()) + ): HttpResponseFor = get(fileId, params, RequestOptions.none()) /** @see get */ @MustBeClosed fun get( params: MetadataGetParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see get */ @MustBeClosed - fun get(params: MetadataGetParams): HttpResponseFor = + fun get(params: MetadataGetParams): HttpResponseFor = get(params, RequestOptions.none()) /** @see get */ @MustBeClosed - fun get( - fileId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = + fun get(fileId: String, requestOptions: RequestOptions): HttpResponseFor = get(fileId, MetadataGetParams.none(), requestOptions) /** @@ -132,15 +125,14 @@ interface MetadataService { * [MetadataService.getFromUrl]. */ @MustBeClosed - fun getFromUrl( - params: MetadataGetFromUrlParams - ): HttpResponseFor = getFromUrl(params, RequestOptions.none()) + fun getFromUrl(params: MetadataGetFromUrlParams): HttpResponseFor = + getFromUrl(params, RequestOptions.none()) /** @see getFromUrl */ @MustBeClosed fun getFromUrl( params: MetadataGetFromUrlParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 index d6627d75..558676a7 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 @@ -15,10 +15,9 @@ 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.MetadataGetFromUrlResponse import com.imagekit.api.models.files.metadata.MetadataGetParams -import com.imagekit.api.models.files.metadata.MetadataGetResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -34,17 +33,14 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client override fun withOptions(modifier: Consumer): MetadataService = MetadataServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun get( - params: MetadataGetParams, - requestOptions: RequestOptions, - ): MetadataGetResponse = + 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, - ): MetadataGetFromUrlResponse = + ): Metadata = // get /v1/files/metadata withRawResponse().getFromUrl(params, requestOptions).parse() @@ -61,13 +57,12 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun get( params: MetadataGetParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fileId", params.fileId().getOrNull()) @@ -91,13 +86,13 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client } } - private val getFromUrlHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val getFromUrlHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun getFromUrl( params: MetadataGetFromUrlParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) 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 99591ed1..d497ecf9 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,7 @@ 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 @@ -52,15 +53,15 @@ internal class FileUploadResponseTest { .isPrivateFile(true) .isPublished(true) .metadata( - FileUploadResponse.Metadata.builder() + Metadata.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - FileUploadResponse.Metadata.Exif.builder() + Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -89,13 +90,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -110,18 +107,18 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - FileUploadResponse.Metadata.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -193,15 +190,15 @@ internal class FileUploadResponseTest { assertThat(fileUploadResponse.isPublished()).contains(true) assertThat(fileUploadResponse.metadata()) .contains( - FileUploadResponse.Metadata.builder() + Metadata.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - FileUploadResponse.Metadata.Exif.builder() + Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -230,13 +227,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -251,18 +244,18 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - FileUploadResponse.Metadata.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -337,15 +330,15 @@ internal class FileUploadResponseTest { .isPrivateFile(true) .isPublished(true) .metadata( - FileUploadResponse.Metadata.builder() + Metadata.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - FileUploadResponse.Metadata.Exif.builder() + Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -374,13 +367,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -395,18 +384,18 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - FileUploadResponse.Metadata.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) 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 c8335d97..08ced347 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 @@ -52,15 +52,15 @@ internal class FileUploadResponseTest { .isPrivateFile(true) .isPublished(true) .metadata( - FileUploadResponse.Metadata.builder() + Metadata.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - FileUploadResponse.Metadata.Exif.builder() + Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -89,13 +89,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -110,18 +106,18 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - FileUploadResponse.Metadata.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -193,15 +189,15 @@ internal class FileUploadResponseTest { assertThat(fileUploadResponse.isPublished()).contains(true) assertThat(fileUploadResponse.metadata()) .contains( - FileUploadResponse.Metadata.builder() + Metadata.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - FileUploadResponse.Metadata.Exif.builder() + Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -230,13 +226,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -251,18 +243,18 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - FileUploadResponse.Metadata.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -337,15 +329,15 @@ internal class FileUploadResponseTest { .isPrivateFile(true) .isPublished(true) .metadata( - FileUploadResponse.Metadata.builder() + Metadata.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - FileUploadResponse.Metadata.Exif.builder() + Metadata.Exif.builder() .exif( - FileUploadResponse.Metadata.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -374,13 +366,9 @@ internal class FileUploadResponseTest { .whiteBalance(0L) .build() ) - .gps( - FileUploadResponse.Metadata.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - FileUploadResponse.Metadata.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -395,18 +383,18 @@ internal class FileUploadResponseTest { .build() ) .interoperability( - FileUploadResponse.Metadata.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - FileUploadResponse.Metadata.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - FileUploadResponse.Metadata.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt similarity index 77% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt index 28ff25c9..aacb71cb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.metadata +package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue @@ -8,20 +8,20 @@ import com.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class MetadataGetResponseTest { +internal class MetadataTest { @Test fun create() { - val metadataGetResponse = - MetadataGetResponse.builder() + val metadata = + Metadata.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - MetadataGetResponse.Exif.builder() + Metadata.Exif.builder() .exif( - MetadataGetResponse.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -50,9 +50,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetResponse.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -67,18 +67,18 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - MetadataGetResponse.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataGetResponse.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - MetadataGetResponse.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -100,15 +100,15 @@ internal class MetadataGetResponseTest { .width(0L) .build() - assertThat(metadataGetResponse.audioCodec()).contains("audioCodec") - assertThat(metadataGetResponse.bitRate()).contains(0L) - assertThat(metadataGetResponse.density()).contains(0L) - assertThat(metadataGetResponse.duration()).contains(0L) - assertThat(metadataGetResponse.exif()) + assertThat(metadata.audioCodec()).contains("audioCodec") + assertThat(metadata.bitRate()).contains(0L) + assertThat(metadata.density()).contains(0L) + assertThat(metadata.duration()).contains(0L) + assertThat(metadata.exif()) .contains( - MetadataGetResponse.Exif.builder() + Metadata.Exif.builder() .exif( - MetadataGetResponse.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -137,9 +137,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetResponse.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -154,18 +154,18 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - MetadataGetResponse.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataGetResponse.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - MetadataGetResponse.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -176,30 +176,30 @@ internal class MetadataGetResponseTest { ) .build() ) - assertThat(metadataGetResponse.format()).contains("format") - assertThat(metadataGetResponse.hasColorProfile()).contains(true) - assertThat(metadataGetResponse.hasTransparency()).contains(true) - assertThat(metadataGetResponse.height()).contains(0L) - assertThat(metadataGetResponse.pHash()).contains("pHash") - assertThat(metadataGetResponse.quality()).contains(0L) - assertThat(metadataGetResponse.size()).contains(0L) - assertThat(metadataGetResponse.videoCodec()).contains("videoCodec") - assertThat(metadataGetResponse.width()).contains(0L) + 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 metadataGetResponse = - MetadataGetResponse.builder() + val metadata = + Metadata.builder() .audioCodec("audioCodec") .bitRate(0L) .density(0L) .duration(0L) .exif( - MetadataGetResponse.Exif.builder() + Metadata.Exif.builder() .exif( - MetadataGetResponse.Exif.InnerExif.builder() + Metadata.Exif.InnerExif.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -228,9 +228,9 @@ internal class MetadataGetResponseTest { .whiteBalance(0L) .build() ) - .gps(MetadataGetResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) .image( - MetadataGetResponse.Exif.Image.builder() + Metadata.Exif.Image.builder() .exifOffset(0L) .gpsInfo(0L) .make("Make") @@ -245,18 +245,18 @@ internal class MetadataGetResponseTest { .build() ) .interoperability( - MetadataGetResponse.Exif.Interoperability.builder() + Metadata.Exif.Interoperability.builder() .interopIndex("InteropIndex") .interopVersion("InteropVersion") .build() ) .makernote( - MetadataGetResponse.Exif.Makernote.builder() + Metadata.Exif.Makernote.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .thumbnail( - MetadataGetResponse.Exif.Thumbnail.builder() + Metadata.Exif.Thumbnail.builder() .compression(0L) .resolutionUnit(0L) .thumbnailLength(0L) @@ -278,12 +278,12 @@ internal class MetadataGetResponseTest { .width(0L) .build() - val roundtrippedMetadataGetResponse = + val roundtrippedMetadata = jsonMapper.readValue( - jsonMapper.writeValueAsString(metadataGetResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(metadata), + jacksonTypeRef(), ) - assertThat(roundtrippedMetadataGetResponse).isEqualTo(metadataGetResponse) + assertThat(roundtrippedMetadata).isEqualTo(metadata) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt deleted file mode 100644 index f889b1e1..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlResponseTest.kt +++ /dev/null @@ -1,297 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.files.metadata - -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 MetadataGetFromUrlResponseTest { - - @Test - fun create() { - val metadataGetFromUrlResponse = - MetadataGetFromUrlResponse.builder() - .audioCodec("audioCodec") - .bitRate(0L) - .density(0L) - .duration(0L) - .exif( - MetadataGetFromUrlResponse.Exif.builder() - .exif( - MetadataGetFromUrlResponse.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( - MetadataGetFromUrlResponse.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) - .image( - MetadataGetFromUrlResponse.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( - MetadataGetFromUrlResponse.Exif.Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - MetadataGetFromUrlResponse.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - MetadataGetFromUrlResponse.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(metadataGetFromUrlResponse.audioCodec()).contains("audioCodec") - assertThat(metadataGetFromUrlResponse.bitRate()).contains(0L) - assertThat(metadataGetFromUrlResponse.density()).contains(0L) - assertThat(metadataGetFromUrlResponse.duration()).contains(0L) - assertThat(metadataGetFromUrlResponse.exif()) - .contains( - MetadataGetFromUrlResponse.Exif.builder() - .exif( - MetadataGetFromUrlResponse.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(MetadataGetFromUrlResponse.Exif.Gps.builder().addGpsVersionId(0L).build()) - .image( - MetadataGetFromUrlResponse.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( - MetadataGetFromUrlResponse.Exif.Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - MetadataGetFromUrlResponse.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - MetadataGetFromUrlResponse.Exif.Thumbnail.builder() - .compression(0L) - .resolutionUnit(0L) - .thumbnailLength(0L) - .thumbnailOffset(0L) - .xResolution(0L) - .yResolution(0L) - .build() - ) - .build() - ) - assertThat(metadataGetFromUrlResponse.format()).contains("format") - assertThat(metadataGetFromUrlResponse.hasColorProfile()).contains(true) - assertThat(metadataGetFromUrlResponse.hasTransparency()).contains(true) - assertThat(metadataGetFromUrlResponse.height()).contains(0L) - assertThat(metadataGetFromUrlResponse.pHash()).contains("pHash") - assertThat(metadataGetFromUrlResponse.quality()).contains(0L) - assertThat(metadataGetFromUrlResponse.size()).contains(0L) - assertThat(metadataGetFromUrlResponse.videoCodec()).contains("videoCodec") - assertThat(metadataGetFromUrlResponse.width()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val metadataGetFromUrlResponse = - MetadataGetFromUrlResponse.builder() - .audioCodec("audioCodec") - .bitRate(0L) - .density(0L) - .duration(0L) - .exif( - MetadataGetFromUrlResponse.Exif.builder() - .exif( - MetadataGetFromUrlResponse.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( - MetadataGetFromUrlResponse.Exif.Gps.builder() - .addGpsVersionId(0L) - .build() - ) - .image( - MetadataGetFromUrlResponse.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( - MetadataGetFromUrlResponse.Exif.Interoperability.builder() - .interopIndex("InteropIndex") - .interopVersion("InteropVersion") - .build() - ) - .makernote( - MetadataGetFromUrlResponse.Exif.Makernote.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .thumbnail( - MetadataGetFromUrlResponse.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 roundtrippedMetadataGetFromUrlResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(metadataGetFromUrlResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedMetadataGetFromUrlResponse).isEqualTo(metadataGetFromUrlResponse) - } -} 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 a2f9b677..827832b6 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 @@ -40,12 +40,12 @@ internal class MetadataServiceAsyncTest { .build() val metadataServiceAsync = client.files().metadata() - val responseFuture = + val metadataFuture = metadataServiceAsync.getFromUrl( MetadataGetFromUrlParams.builder().url("https://example.com").build() ) - val response = responseFuture.get() - response.validate() + val metadata = metadataFuture.get() + metadata.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 index fc0abfd8..fcdef81c 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 @@ -39,11 +39,11 @@ internal class MetadataServiceTest { .build() val metadataService = client.files().metadata() - val response = + val metadata = metadataService.getFromUrl( MetadataGetFromUrlParams.builder().url("https://example.com").build() ) - response.validate() + metadata.validate() } } From 4406c37e6df84b4eb69107c59a0eed24afe6e041 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 06:26:08 +0000 Subject: [PATCH 055/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index eae87049..b0b132c4 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-547b616849eececf3f5b1ea38ebe1dba718e1877c787e3642b9c91e552548789.yml openapi_spec_hash: fba0bf8c1ee034067ab6ae93f84abeae -config_hash: 659d086a034de739b7423470b2c13ae0 +config_hash: 90f5a16140d721a24bffafbc30abaf35 From 8c7c69ffe4bad04dee9b4988bed90d2e128e91f7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 06:46:16 +0000 Subject: [PATCH 056/125] feat(api): manual updates --- .stats.yml | 6 +- .../api/models/files/AsyncBulkJobResponse.kt | 114 ++++++++++++++++++ .../models/files/AsyncBulkJobResponseTest.kt | 30 +++++ 3 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponse.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponseTest.kt diff --git a/.stats.yml b/.stats.yml index b0b132c4..67dc4384 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-547b616849eececf3f5b1ea38ebe1dba718e1877c787e3642b9c91e552548789.yml -openapi_spec_hash: fba0bf8c1ee034067ab6ae93f84abeae -config_hash: 90f5a16140d721a24bffafbc30abaf35 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-ef47bed4a4585d2bdb4308a8710d748625a33548279a7b5ba04bbea0a0bbe1b8.yml +openapi_spec_hash: e64e91aa1603678f705d1ef4817f3304 +config_hash: 3e8cbbe505aa1a6dd7a72728dbf8fd4a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponse.kt new file mode 100644 index 00000000..5f8305b8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponse.kt @@ -0,0 +1,114 @@ +// 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 + +/** Job submitted successfully. A `jobId` will be returned. */ +class AsyncBulkJobResponse +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 [AsyncBulkJobResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsyncBulkJobResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asyncBulkJobResponse: AsyncBulkJobResponse) = apply { + additionalProperties = asyncBulkJobResponse.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 [AsyncBulkJobResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AsyncBulkJobResponse = + AsyncBulkJobResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AsyncBulkJobResponse = 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 AsyncBulkJobResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "AsyncBulkJobResponse{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponseTest.kt new file mode 100644 index 00000000..d944630b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponseTest.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 AsyncBulkJobResponseTest { + + @Test + fun create() { + val asyncBulkJobResponse = AsyncBulkJobResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val asyncBulkJobResponse = AsyncBulkJobResponse.builder().build() + + val roundtrippedAsyncBulkJobResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(asyncBulkJobResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAsyncBulkJobResponse).isEqualTo(asyncBulkJobResponse) + } +} From ba0971d62bac57ec96d7e9b82fdac14f5256bd4a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 06:50:22 +0000 Subject: [PATCH 057/125] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/{files => folders}/AsyncBulkJobResponse.kt | 2 +- .../api/models/{files => folders}/AsyncBulkJobResponseTest.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{files => folders}/AsyncBulkJobResponse.kt (98%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{files => folders}/AsyncBulkJobResponseTest.kt (95%) diff --git a/.stats.yml b/.stats.yml index 67dc4384..8c084b5d 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-ef47bed4a4585d2bdb4308a8710d748625a33548279a7b5ba04bbea0a0bbe1b8.yml openapi_spec_hash: e64e91aa1603678f705d1ef4817f3304 -config_hash: 3e8cbbe505aa1a6dd7a72728dbf8fd4a +config_hash: 9f3ce6ee05ee57f8d3f0330a5d18be26 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt index 5f8305b8..67067951 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponseTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt index d944630b..3c787dc5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/AsyncBulkJobResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.jsonMapper From 1e069e270c1f6e088d5336de9c2420f8415cb7b1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 06:58:03 +0000 Subject: [PATCH 058/125] feat(api): manual updates --- .stats.yml | 4 +- .../models/folders/AsyncBulkJobResponse.kt | 74 ++++++++- .../api/models/folders/FolderCopyResponse.kt | 157 ------------------ .../api/models/folders/FolderMoveResponse.kt | 157 ------------------ .../models/folders/FolderRenameResponse.kt | 157 ------------------ .../api/services/async/FolderServiceAsync.kt | 32 ++-- .../services/async/FolderServiceAsyncImpl.kt | 28 ++-- .../api/services/blocking/FolderService.kt | 28 ++-- .../services/blocking/FolderServiceImpl.kt | 28 ++-- .../folders/AsyncBulkJobResponseTest.kt | 6 +- .../models/folders/FolderCopyResponseTest.kt | 32 ---- .../models/folders/FolderMoveResponseTest.kt | 32 ---- .../folders/FolderRenameResponseTest.kt | 32 ---- .../services/async/FolderServiceAsyncTest.kt | 18 +- .../services/blocking/FolderServiceTest.kt | 12 +- 15 files changed, 143 insertions(+), 654 deletions(-) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 8c084b5d..a43e2d25 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-ef47bed4a4585d2bdb4308a8710d748625a33548279a7b5ba04bbea0a0bbe1b8.yml -openapi_spec_hash: e64e91aa1603678f705d1ef4817f3304 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-76121f82e0f399831eff2cf350f6f7737d8e22b996b22f5a5ca88fdf73c8a7fc.yml +openapi_spec_hash: 0913383eddc12609ad59e29d68dc6154 config_hash: 9f3ce6ee05ee57f8d3f0330a5d18be26 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt index 67067951..781b345d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt @@ -5,17 +5,42 @@ 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 AsyncBulkJobResponse -private constructor(private val additionalProperties: MutableMap) { +private constructor( + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { - @JsonCreator private constructor() : this(mutableMapOf()) + @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) { @@ -31,20 +56,42 @@ private constructor(private val additionalProperties: MutableMap? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(asyncBulkJobResponse: AsyncBulkJobResponse) = apply { + jobId = asyncBulkJobResponse.jobId additionalProperties = asyncBulkJobResponse.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) @@ -68,9 +115,16 @@ private constructor(private val additionalProperties: MutableMap, - 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 (e.g. if the - * server responded with an unexpected value). - */ - fun jobId(): Optional = jobId.getOptional("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]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FolderCopyResponse]. */ - class Builder internal constructor() { - - private var jobId: JsonField = JsonMissing.of() - 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. - */ - fun build(): FolderCopyResponse = - FolderCopyResponse(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/FolderMoveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt deleted file mode 100644 index 5a91000a..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt +++ /dev/null @@ -1,157 +0,0 @@ -// 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.errors.ImageKitInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional - -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 (e.g. if the - * server responded with an unexpected value). - */ - fun jobId(): Optional = jobId.getOptional("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]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FolderMoveResponse]. */ - class Builder internal constructor() { - - private var jobId: JsonField = JsonMissing.of() - 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. - */ - fun build(): FolderMoveResponse = - FolderMoveResponse(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/FolderRenameResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt deleted file mode 100644 index 8cd255ca..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt +++ /dev/null @@ -1,157 +0,0 @@ -// 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.errors.ImageKitInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional - -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 (e.g. if the - * server responded with an unexpected value). - */ - fun jobId(): Optional = jobId.getOptional("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]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FolderRenameResponse]. */ - class Builder internal constructor() { - - private var jobId: JsonField = JsonMissing.of() - 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. - */ - fun build(): FolderRenameResponse = - FolderRenameResponse(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/services/async/FolderServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt index aaa08ff2..af441922 100644 --- 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 @@ -5,16 +5,14 @@ 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.AsyncBulkJobResponse 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 @@ -67,14 +65,14 @@ interface FolderServiceAsync { * 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 = + fun copy(params: FolderCopyParams): CompletableFuture = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This will move one folder into another. The selected folder, its nested folders, files, and @@ -82,28 +80,28 @@ interface FolderServiceAsync { * 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 = + fun move(params: FolderMoveParams): CompletableFuture = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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 = + fun rename(params: FolderRenameParams): CompletableFuture = rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [FolderServiceAsync] that provides access to raw HTTP responses for each method. @@ -155,27 +153,31 @@ interface FolderServiceAsync { * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same * as [FolderServiceAsync.copy]. */ - fun copy(params: FolderCopyParams): CompletableFuture> = + fun copy( + params: FolderCopyParams + ): CompletableFuture> = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same * as [FolderServiceAsync.move]. */ - fun move(params: FolderMoveParams): CompletableFuture> = + fun move( + params: FolderMoveParams + ): CompletableFuture> = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/bulkJobs/renameFolder`, but is otherwise the @@ -183,13 +185,13 @@ interface FolderServiceAsync { */ fun rename( params: FolderRenameParams - ): CompletableFuture> = + ): CompletableFuture> = rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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 index 426fe095..b37019c7 100644 --- 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 @@ -15,16 +15,14 @@ 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.AsyncBulkJobResponse 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 @@ -63,21 +61,21 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/copyFolder withRawResponse().copy(params, requestOptions).thenApply { it.parse() } override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/moveFolder withRawResponse().move(params, requestOptions).thenApply { it.parse() } override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/renameFolder withRawResponse().rename(params, requestOptions).thenApply { it.parse() } @@ -162,13 +160,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val copyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -193,13 +191,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val moveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -224,13 +222,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val renameHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) 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 index e38020e4..921203f9 100644 --- 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 @@ -6,16 +6,14 @@ 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.AsyncBulkJobResponse 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 @@ -67,13 +65,13 @@ interface FolderService { * 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()) + fun copy(params: FolderCopyParams): AsyncBulkJobResponse = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): FolderCopyResponse + ): AsyncBulkJobResponse /** * This will move one folder into another. The selected folder, its nested folders, files, and @@ -81,27 +79,27 @@ interface FolderService { * 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()) + fun move(params: FolderMoveParams): AsyncBulkJobResponse = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): FolderMoveResponse + ): AsyncBulkJobResponse /** * 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 = + fun rename(params: FolderRenameParams): AsyncBulkJobResponse = rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): FolderRenameResponse + ): AsyncBulkJobResponse /** A view of [FolderService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -150,7 +148,7 @@ interface FolderService { * as [FolderService.copy]. */ @MustBeClosed - fun copy(params: FolderCopyParams): HttpResponseFor = + fun copy(params: FolderCopyParams): HttpResponseFor = copy(params, RequestOptions.none()) /** @see copy */ @@ -158,14 +156,14 @@ interface FolderService { fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun move(params: FolderMoveParams): HttpResponseFor = move(params, RequestOptions.none()) /** @see move */ @@ -173,14 +171,14 @@ interface FolderService { fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun rename(params: FolderRenameParams): HttpResponseFor = rename(params, RequestOptions.none()) /** @see rename */ @@ -188,6 +186,6 @@ interface FolderService { fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 index 42a20bf2..f825ed59 100644 --- 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 @@ -15,16 +15,14 @@ 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.AsyncBulkJobResponse 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 @@ -62,21 +60,21 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): FolderCopyResponse = + ): AsyncBulkJobResponse = // post /v1/bulkJobs/copyFolder withRawResponse().copy(params, requestOptions).parse() override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): FolderMoveResponse = + ): AsyncBulkJobResponse = // post /v1/bulkJobs/moveFolder withRawResponse().move(params, requestOptions).parse() override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): FolderRenameResponse = + ): AsyncBulkJobResponse = // post /v1/bulkJobs/renameFolder withRawResponse().rename(params, requestOptions).parse() @@ -155,13 +153,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val copyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -183,13 +181,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val moveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -211,13 +209,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val renameHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt index 3c787dc5..59d0e2a5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt @@ -11,13 +11,15 @@ internal class AsyncBulkJobResponseTest { @Test fun create() { - val asyncBulkJobResponse = AsyncBulkJobResponse.builder().build() + val asyncBulkJobResponse = AsyncBulkJobResponse.builder().jobId("jobId").build() + + assertThat(asyncBulkJobResponse.jobId()).isEqualTo("jobId") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val asyncBulkJobResponse = AsyncBulkJobResponse.builder().build() + val asyncBulkJobResponse = AsyncBulkJobResponse.builder().jobId("jobId").build() val roundtrippedAsyncBulkJobResponse = jsonMapper.readValue( 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 deleted file mode 100644 index e6784761..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// 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()).contains("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/FolderMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt deleted file mode 100644 index 0edbc945..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// 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()).contains("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/FolderRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt deleted file mode 100644 index 07fdc5f6..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// 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()).contains("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/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt index 175c051b..5a66a52c 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 @@ -70,7 +70,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val responseFuture = + val asyncBulkJobResponseFuture = folderServiceAsync.copy( FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") @@ -79,8 +79,8 @@ internal class FolderServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val asyncBulkJobResponse = asyncBulkJobResponseFuture.get() + asyncBulkJobResponse.validate() } @Disabled("Prism tests are disabled") @@ -94,7 +94,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val responseFuture = + val asyncBulkJobResponseFuture = folderServiceAsync.move( FolderMoveParams.builder() .destinationPath("/path/of/destination/folder") @@ -102,8 +102,8 @@ internal class FolderServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val asyncBulkJobResponse = asyncBulkJobResponseFuture.get() + asyncBulkJobResponse.validate() } @Disabled("Prism tests are disabled") @@ -117,7 +117,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val responseFuture = + val asyncBulkJobResponseFuture = folderServiceAsync.rename( FolderRenameParams.builder() .folderPath("/path/of/folder") @@ -126,7 +126,7 @@ internal class FolderServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val asyncBulkJobResponse = asyncBulkJobResponseFuture.get() + asyncBulkJobResponse.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 index 13026e90..ae89151a 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 @@ -68,7 +68,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val response = + val asyncBulkJobResponse = folderService.copy( FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") @@ -77,7 +77,7 @@ internal class FolderServiceTest { .build() ) - response.validate() + asyncBulkJobResponse.validate() } @Disabled("Prism tests are disabled") @@ -91,7 +91,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val response = + val asyncBulkJobResponse = folderService.move( FolderMoveParams.builder() .destinationPath("/path/of/destination/folder") @@ -99,7 +99,7 @@ internal class FolderServiceTest { .build() ) - response.validate() + asyncBulkJobResponse.validate() } @Disabled("Prism tests are disabled") @@ -113,7 +113,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val response = + val asyncBulkJobResponse = folderService.rename( FolderRenameParams.builder() .folderPath("/path/of/folder") @@ -122,6 +122,6 @@ internal class FolderServiceTest { .build() ) - response.validate() + asyncBulkJobResponse.validate() } } From 88c58574342eedaa53e05fa0cf2600db95796170 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:00:18 +0000 Subject: [PATCH 059/125] feat(api): manual updates --- .stats.yml | 6 ++-- ...AsyncBulkJobResponse.kt => JobResponse.kt} | 24 ++++++------- .../api/services/async/FolderServiceAsync.kt | 32 +++++++---------- .../services/async/FolderServiceAsyncImpl.kt | 26 +++++++------- .../api/services/blocking/FolderService.kt | 27 +++++++------- .../services/blocking/FolderServiceImpl.kt | 35 +++++++------------ .../folders/AsyncBulkJobResponseTest.kt | 32 ----------------- .../api/models/folders/JobResponseTest.kt | 32 +++++++++++++++++ .../services/async/FolderServiceAsyncTest.kt | 18 +++++----- .../services/blocking/FolderServiceTest.kt | 12 +++---- 10 files changed, 114 insertions(+), 130 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/{AsyncBulkJobResponse.kt => JobResponse.kt} (87%) delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/JobResponseTest.kt diff --git a/.stats.yml b/.stats.yml index a43e2d25..8cb350c9 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-76121f82e0f399831eff2cf350f6f7737d8e22b996b22f5a5ca88fdf73c8a7fc.yml -openapi_spec_hash: 0913383eddc12609ad59e29d68dc6154 -config_hash: 9f3ce6ee05ee57f8d3f0330a5d18be26 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-6fee8f335061dc7a308b9a2712dce5a1c16c81125f71e00dba3e4759a39d7bf0.yml +openapi_spec_hash: 205e083e0ab6b49d5bc8a2e5b323610b +config_hash: f7c2f1f50b841dabc54904c2e05f21c5 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/JobResponse.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/JobResponse.kt index 781b345d..c232a4a0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/JobResponse.kt @@ -16,7 +16,7 @@ import java.util.Collections import java.util.Objects /** Job submitted successfully. A `jobId` will be returned. */ -class AsyncBulkJobResponse +class JobResponse private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, @@ -57,7 +57,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AsyncBulkJobResponse]. + * Returns a mutable builder for constructing an instance of [JobResponse]. * * The following fields are required: * ```java @@ -67,16 +67,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AsyncBulkJobResponse]. */ + /** A builder for [JobResponse]. */ class Builder internal constructor() { private var jobId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(asyncBulkJobResponse: AsyncBulkJobResponse) = apply { - jobId = asyncBulkJobResponse.jobId - additionalProperties = asyncBulkJobResponse.additionalProperties.toMutableMap() + internal fun from(jobResponse: JobResponse) = apply { + jobId = jobResponse.jobId + additionalProperties = jobResponse.additionalProperties.toMutableMap() } /** @@ -112,7 +112,7 @@ private constructor( } /** - * Returns an immutable instance of [AsyncBulkJobResponse]. + * Returns an immutable instance of [JobResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -123,13 +123,13 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AsyncBulkJobResponse = - AsyncBulkJobResponse(checkRequired("jobId", jobId), additionalProperties.toMutableMap()) + fun build(): JobResponse = + JobResponse(checkRequired("jobId", jobId), additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): AsyncBulkJobResponse = apply { + fun validate(): JobResponse = apply { if (validated) { return@apply } @@ -158,7 +158,7 @@ private constructor( return true } - return other is AsyncBulkJobResponse && + return other is JobResponse && jobId == other.jobId && additionalProperties == other.additionalProperties } @@ -168,5 +168,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AsyncBulkJobResponse{jobId=$jobId, additionalProperties=$additionalProperties}" + "JobResponse{jobId=$jobId, additionalProperties=$additionalProperties}" } 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 index af441922..4af683e6 100644 --- 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 @@ -5,7 +5,6 @@ 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.AsyncBulkJobResponse import com.imagekit.api.models.folders.FolderCopyParams import com.imagekit.api.models.folders.FolderCreateParams import com.imagekit.api.models.folders.FolderCreateResponse @@ -13,6 +12,7 @@ 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.FolderRenameParams +import com.imagekit.api.models.folders.JobResponse import com.imagekit.api.services.async.folders.JobServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -65,14 +65,14 @@ interface FolderServiceAsync { * 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 = + fun copy(params: FolderCopyParams): CompletableFuture = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This will move one folder into another. The selected folder, its nested folders, files, and @@ -80,28 +80,28 @@ interface FolderServiceAsync { * 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 = + fun move(params: FolderMoveParams): CompletableFuture = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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 = + fun rename(params: FolderRenameParams): CompletableFuture = rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [FolderServiceAsync] that provides access to raw HTTP responses for each method. @@ -153,45 +153,39 @@ interface FolderServiceAsync { * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same * as [FolderServiceAsync.copy]. */ - fun copy( - params: FolderCopyParams - ): CompletableFuture> = + fun copy(params: FolderCopyParams): CompletableFuture> = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same * as [FolderServiceAsync.move]. */ - fun move( - params: FolderMoveParams - ): CompletableFuture> = + fun move(params: FolderMoveParams): CompletableFuture> = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/bulkJobs/renameFolder`, but is otherwise the * same as [FolderServiceAsync.rename]. */ - fun rename( - params: FolderRenameParams - ): CompletableFuture> = + fun rename(params: FolderRenameParams): CompletableFuture> = rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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 index b37019c7..96994383 100644 --- 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 @@ -15,7 +15,6 @@ 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.AsyncBulkJobResponse import com.imagekit.api.models.folders.FolderCopyParams import com.imagekit.api.models.folders.FolderCreateParams import com.imagekit.api.models.folders.FolderCreateResponse @@ -23,6 +22,7 @@ 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.FolderRenameParams +import com.imagekit.api.models.folders.JobResponse import com.imagekit.api.services.async.folders.JobServiceAsync import com.imagekit.api.services.async.folders.JobServiceAsyncImpl import java.util.concurrent.CompletableFuture @@ -61,21 +61,21 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/copyFolder withRawResponse().copy(params, requestOptions).thenApply { it.parse() } override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/moveFolder withRawResponse().move(params, requestOptions).thenApply { it.parse() } override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/renameFolder withRawResponse().rename(params, requestOptions).thenApply { it.parse() } @@ -160,13 +160,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val copyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -191,13 +191,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val moveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -222,13 +222,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val renameHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) 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 index 921203f9..ce8fa936 100644 --- 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 @@ -6,7 +6,6 @@ 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.AsyncBulkJobResponse import com.imagekit.api.models.folders.FolderCopyParams import com.imagekit.api.models.folders.FolderCreateParams import com.imagekit.api.models.folders.FolderCreateResponse @@ -14,6 +13,7 @@ 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.FolderRenameParams +import com.imagekit.api.models.folders.JobResponse import com.imagekit.api.services.blocking.folders.JobService import java.util.function.Consumer @@ -65,13 +65,13 @@ interface FolderService { * 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): AsyncBulkJobResponse = copy(params, RequestOptions.none()) + fun copy(params: FolderCopyParams): JobResponse = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): AsyncBulkJobResponse + ): JobResponse /** * This will move one folder into another. The selected folder, its nested folders, files, and @@ -79,27 +79,26 @@ interface FolderService { * 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): AsyncBulkJobResponse = move(params, RequestOptions.none()) + fun move(params: FolderMoveParams): JobResponse = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): AsyncBulkJobResponse + ): JobResponse /** * 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): AsyncBulkJobResponse = - rename(params, RequestOptions.none()) + fun rename(params: FolderRenameParams): JobResponse = rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): AsyncBulkJobResponse + ): JobResponse /** A view of [FolderService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -148,7 +147,7 @@ interface FolderService { * as [FolderService.copy]. */ @MustBeClosed - fun copy(params: FolderCopyParams): HttpResponseFor = + fun copy(params: FolderCopyParams): HttpResponseFor = copy(params, RequestOptions.none()) /** @see copy */ @@ -156,14 +155,14 @@ interface FolderService { fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun move(params: FolderMoveParams): HttpResponseFor = move(params, RequestOptions.none()) /** @see move */ @@ -171,14 +170,14 @@ interface FolderService { fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun rename(params: FolderRenameParams): HttpResponseFor = rename(params, RequestOptions.none()) /** @see rename */ @@ -186,6 +185,6 @@ interface FolderService { fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 index f825ed59..9e821642 100644 --- 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 @@ -15,7 +15,6 @@ 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.AsyncBulkJobResponse import com.imagekit.api.models.folders.FolderCopyParams import com.imagekit.api.models.folders.FolderCreateParams import com.imagekit.api.models.folders.FolderCreateResponse @@ -23,6 +22,7 @@ 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.FolderRenameParams +import com.imagekit.api.models.folders.JobResponse import com.imagekit.api.services.blocking.folders.JobService import com.imagekit.api.services.blocking.folders.JobServiceImpl import java.util.function.Consumer @@ -57,24 +57,15 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp // delete /v1/folder withRawResponse().delete(params, requestOptions).parse() - override fun copy( - params: FolderCopyParams, - requestOptions: RequestOptions, - ): AsyncBulkJobResponse = + override fun copy(params: FolderCopyParams, requestOptions: RequestOptions): JobResponse = // post /v1/bulkJobs/copyFolder withRawResponse().copy(params, requestOptions).parse() - override fun move( - params: FolderMoveParams, - requestOptions: RequestOptions, - ): AsyncBulkJobResponse = + override fun move(params: FolderMoveParams, requestOptions: RequestOptions): JobResponse = // post /v1/bulkJobs/moveFolder withRawResponse().move(params, requestOptions).parse() - override fun rename( - params: FolderRenameParams, - requestOptions: RequestOptions, - ): AsyncBulkJobResponse = + override fun rename(params: FolderRenameParams, requestOptions: RequestOptions): JobResponse = // post /v1/bulkJobs/renameFolder withRawResponse().rename(params, requestOptions).parse() @@ -153,13 +144,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val copyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -181,13 +172,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val moveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -209,13 +200,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val renameHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt deleted file mode 100644 index 59d0e2a5..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/AsyncBulkJobResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// 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 AsyncBulkJobResponseTest { - - @Test - fun create() { - val asyncBulkJobResponse = AsyncBulkJobResponse.builder().jobId("jobId").build() - - assertThat(asyncBulkJobResponse.jobId()).isEqualTo("jobId") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val asyncBulkJobResponse = AsyncBulkJobResponse.builder().jobId("jobId").build() - - val roundtrippedAsyncBulkJobResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(asyncBulkJobResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAsyncBulkJobResponse).isEqualTo(asyncBulkJobResponse) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/JobResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/JobResponseTest.kt new file mode 100644 index 00000000..6c28832c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/JobResponseTest.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 JobResponseTest { + + @Test + fun create() { + val jobResponse = JobResponse.builder().jobId("jobId").build() + + assertThat(jobResponse.jobId()).isEqualTo("jobId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val jobResponse = JobResponse.builder().jobId("jobId").build() + + val roundtrippedJobResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(jobResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedJobResponse).isEqualTo(jobResponse) + } +} 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 5a66a52c..10e51058 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 @@ -70,7 +70,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val asyncBulkJobResponseFuture = + val jobResponseFuture = folderServiceAsync.copy( FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") @@ -79,8 +79,8 @@ internal class FolderServiceAsyncTest { .build() ) - val asyncBulkJobResponse = asyncBulkJobResponseFuture.get() - asyncBulkJobResponse.validate() + val jobResponse = jobResponseFuture.get() + jobResponse.validate() } @Disabled("Prism tests are disabled") @@ -94,7 +94,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val asyncBulkJobResponseFuture = + val jobResponseFuture = folderServiceAsync.move( FolderMoveParams.builder() .destinationPath("/path/of/destination/folder") @@ -102,8 +102,8 @@ internal class FolderServiceAsyncTest { .build() ) - val asyncBulkJobResponse = asyncBulkJobResponseFuture.get() - asyncBulkJobResponse.validate() + val jobResponse = jobResponseFuture.get() + jobResponse.validate() } @Disabled("Prism tests are disabled") @@ -117,7 +117,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val asyncBulkJobResponseFuture = + val jobResponseFuture = folderServiceAsync.rename( FolderRenameParams.builder() .folderPath("/path/of/folder") @@ -126,7 +126,7 @@ internal class FolderServiceAsyncTest { .build() ) - val asyncBulkJobResponse = asyncBulkJobResponseFuture.get() - asyncBulkJobResponse.validate() + val jobResponse = jobResponseFuture.get() + jobResponse.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 index ae89151a..e94bce66 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 @@ -68,7 +68,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val asyncBulkJobResponse = + val jobResponse = folderService.copy( FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") @@ -77,7 +77,7 @@ internal class FolderServiceTest { .build() ) - asyncBulkJobResponse.validate() + jobResponse.validate() } @Disabled("Prism tests are disabled") @@ -91,7 +91,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val asyncBulkJobResponse = + val jobResponse = folderService.move( FolderMoveParams.builder() .destinationPath("/path/of/destination/folder") @@ -99,7 +99,7 @@ internal class FolderServiceTest { .build() ) - asyncBulkJobResponse.validate() + jobResponse.validate() } @Disabled("Prism tests are disabled") @@ -113,7 +113,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val asyncBulkJobResponse = + val jobResponse = folderService.rename( FolderRenameParams.builder() .folderPath("/path/of/folder") @@ -122,6 +122,6 @@ internal class FolderServiceTest { .build() ) - asyncBulkJobResponse.validate() + jobResponse.validate() } } From 0480fed5639decb57233db59c8055f4bb2482c25 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:04:48 +0000 Subject: [PATCH 060/125] feat(api): manual updates --- .stats.yml | 2 +- .../{JobResponse.kt => FolderCopyResponse.kt} | 24 +-- .../api/models/folders/FolderMoveResponse.kt | 172 ++++++++++++++++++ .../models/folders/FolderRenameResponse.kt | 172 ++++++++++++++++++ .../api/services/async/FolderServiceAsync.kt | 30 +-- .../services/async/FolderServiceAsyncImpl.kt | 28 +-- .../api/services/blocking/FolderService.kt | 29 +-- .../services/blocking/FolderServiceImpl.kt | 37 ++-- .../models/folders/FolderCopyResponseTest.kt | 32 ++++ .../models/folders/FolderMoveResponseTest.kt | 32 ++++ .../folders/FolderRenameResponseTest.kt | 32 ++++ .../api/models/folders/JobResponseTest.kt | 32 ---- .../services/async/FolderServiceAsyncTest.kt | 18 +- .../services/blocking/FolderServiceTest.kt | 12 +- 14 files changed, 540 insertions(+), 112 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/{JobResponse.kt => FolderCopyResponse.kt} (87%) 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/FolderRenameResponse.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/FolderMoveResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/JobResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 8cb350c9..f16eca03 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-6fee8f335061dc7a308b9a2712dce5a1c16c81125f71e00dba3e4759a39d7bf0.yml openapi_spec_hash: 205e083e0ab6b49d5bc8a2e5b323610b -config_hash: f7c2f1f50b841dabc54904c2e05f21c5 +config_hash: 90f5a16140d721a24bffafbc30abaf35 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/JobResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/JobResponse.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt index c232a4a0..3373e268 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/JobResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt @@ -16,7 +16,7 @@ import java.util.Collections import java.util.Objects /** Job submitted successfully. A `jobId` will be returned. */ -class JobResponse +class FolderCopyResponse private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, @@ -57,7 +57,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [JobResponse]. + * Returns a mutable builder for constructing an instance of [FolderCopyResponse]. * * The following fields are required: * ```java @@ -67,16 +67,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [JobResponse]. */ + /** A builder for [FolderCopyResponse]. */ class Builder internal constructor() { private var jobId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jobResponse: JobResponse) = apply { - jobId = jobResponse.jobId - additionalProperties = jobResponse.additionalProperties.toMutableMap() + internal fun from(folderCopyResponse: FolderCopyResponse) = apply { + jobId = folderCopyResponse.jobId + additionalProperties = folderCopyResponse.additionalProperties.toMutableMap() } /** @@ -112,7 +112,7 @@ private constructor( } /** - * Returns an immutable instance of [JobResponse]. + * Returns an immutable instance of [FolderCopyResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -123,13 +123,13 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): JobResponse = - JobResponse(checkRequired("jobId", jobId), additionalProperties.toMutableMap()) + fun build(): FolderCopyResponse = + FolderCopyResponse(checkRequired("jobId", jobId), additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): JobResponse = apply { + fun validate(): FolderCopyResponse = apply { if (validated) { return@apply } @@ -158,7 +158,7 @@ private constructor( return true } - return other is JobResponse && + return other is FolderCopyResponse && jobId == other.jobId && additionalProperties == other.additionalProperties } @@ -168,5 +168,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "JobResponse{jobId=$jobId, additionalProperties=$additionalProperties}" + "FolderCopyResponse{jobId=$jobId, additionalProperties=$additionalProperties}" } 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/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/services/async/FolderServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt index 4af683e6..aaa08ff2 100644 --- 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 @@ -6,13 +6,15 @@ 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.JobResponse +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 @@ -65,14 +67,14 @@ interface FolderServiceAsync { * 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 = + fun copy(params: FolderCopyParams): CompletableFuture = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This will move one folder into another. The selected folder, its nested folders, files, and @@ -80,28 +82,28 @@ interface FolderServiceAsync { * 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 = + fun move(params: FolderMoveParams): CompletableFuture = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): 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 = + fun rename(params: FolderRenameParams): CompletableFuture = rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [FolderServiceAsync] that provides access to raw HTTP responses for each method. @@ -153,39 +155,41 @@ interface FolderServiceAsync { * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same * as [FolderServiceAsync.copy]. */ - fun copy(params: FolderCopyParams): CompletableFuture> = + fun copy(params: FolderCopyParams): CompletableFuture> = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same * as [FolderServiceAsync.move]. */ - fun move(params: FolderMoveParams): CompletableFuture> = + fun move(params: FolderMoveParams): CompletableFuture> = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/bulkJobs/renameFolder`, but is otherwise the * same as [FolderServiceAsync.rename]. */ - fun rename(params: FolderRenameParams): CompletableFuture> = + fun rename( + params: FolderRenameParams + ): CompletableFuture> = rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): 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 index 96994383..426fe095 100644 --- 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 @@ -16,13 +16,15 @@ 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.JobResponse +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 @@ -61,21 +63,21 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/copyFolder withRawResponse().copy(params, requestOptions).thenApply { it.parse() } override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/moveFolder withRawResponse().move(params, requestOptions).thenApply { it.parse() } override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/bulkJobs/renameFolder withRawResponse().rename(params, requestOptions).thenApply { it.parse() } @@ -160,13 +162,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val copyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -191,13 +193,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val moveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -222,13 +224,13 @@ class FolderServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val renameHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) 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 index ce8fa936..e38020e4 100644 --- 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 @@ -7,13 +7,15 @@ 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.JobResponse +import com.imagekit.api.models.folders.FolderRenameResponse import com.imagekit.api.services.blocking.folders.JobService import java.util.function.Consumer @@ -65,13 +67,13 @@ interface FolderService { * 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): JobResponse = copy(params, RequestOptions.none()) + fun copy(params: FolderCopyParams): FolderCopyResponse = copy(params, RequestOptions.none()) /** @see copy */ fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): JobResponse + ): FolderCopyResponse /** * This will move one folder into another. The selected folder, its nested folders, files, and @@ -79,26 +81,27 @@ interface FolderService { * 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): JobResponse = move(params, RequestOptions.none()) + fun move(params: FolderMoveParams): FolderMoveResponse = move(params, RequestOptions.none()) /** @see move */ fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): JobResponse + ): 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): JobResponse = rename(params, RequestOptions.none()) + fun rename(params: FolderRenameParams): FolderRenameResponse = + rename(params, RequestOptions.none()) /** @see rename */ fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): JobResponse + ): FolderRenameResponse /** A view of [FolderService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -147,7 +150,7 @@ interface FolderService { * as [FolderService.copy]. */ @MustBeClosed - fun copy(params: FolderCopyParams): HttpResponseFor = + fun copy(params: FolderCopyParams): HttpResponseFor = copy(params, RequestOptions.none()) /** @see copy */ @@ -155,14 +158,14 @@ interface FolderService { fun copy( params: FolderCopyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun move(params: FolderMoveParams): HttpResponseFor = move(params, RequestOptions.none()) /** @see move */ @@ -170,14 +173,14 @@ interface FolderService { fun move( params: FolderMoveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 = + fun rename(params: FolderRenameParams): HttpResponseFor = rename(params, RequestOptions.none()) /** @see rename */ @@ -185,6 +188,6 @@ interface FolderService { fun rename( params: FolderRenameParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): 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 index 9e821642..42a20bf2 100644 --- 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 @@ -16,13 +16,15 @@ 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.JobResponse +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 @@ -57,15 +59,24 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp // delete /v1/folder withRawResponse().delete(params, requestOptions).parse() - override fun copy(params: FolderCopyParams, requestOptions: RequestOptions): JobResponse = + override fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions, + ): FolderCopyResponse = // post /v1/bulkJobs/copyFolder withRawResponse().copy(params, requestOptions).parse() - override fun move(params: FolderMoveParams, requestOptions: RequestOptions): JobResponse = + override fun move( + params: FolderMoveParams, + requestOptions: RequestOptions, + ): FolderMoveResponse = // post /v1/bulkJobs/moveFolder withRawResponse().move(params, requestOptions).parse() - override fun rename(params: FolderRenameParams, requestOptions: RequestOptions): JobResponse = + override fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions, + ): FolderRenameResponse = // post /v1/bulkJobs/renameFolder withRawResponse().rename(params, requestOptions).parse() @@ -144,13 +155,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val copyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun copy( params: FolderCopyParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -172,13 +183,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val moveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun move( params: FolderMoveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -200,13 +211,13 @@ class FolderServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val renameHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun rename( params: FolderRenameParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) 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/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/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/JobResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/JobResponseTest.kt deleted file mode 100644 index 6c28832c..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/JobResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// 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 JobResponseTest { - - @Test - fun create() { - val jobResponse = JobResponse.builder().jobId("jobId").build() - - assertThat(jobResponse.jobId()).isEqualTo("jobId") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val jobResponse = JobResponse.builder().jobId("jobId").build() - - val roundtrippedJobResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(jobResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedJobResponse).isEqualTo(jobResponse) - } -} 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 10e51058..175c051b 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 @@ -70,7 +70,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val jobResponseFuture = + val responseFuture = folderServiceAsync.copy( FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") @@ -79,8 +79,8 @@ internal class FolderServiceAsyncTest { .build() ) - val jobResponse = jobResponseFuture.get() - jobResponse.validate() + val response = responseFuture.get() + response.validate() } @Disabled("Prism tests are disabled") @@ -94,7 +94,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val jobResponseFuture = + val responseFuture = folderServiceAsync.move( FolderMoveParams.builder() .destinationPath("/path/of/destination/folder") @@ -102,8 +102,8 @@ internal class FolderServiceAsyncTest { .build() ) - val jobResponse = jobResponseFuture.get() - jobResponse.validate() + val response = responseFuture.get() + response.validate() } @Disabled("Prism tests are disabled") @@ -117,7 +117,7 @@ internal class FolderServiceAsyncTest { .build() val folderServiceAsync = client.folders() - val jobResponseFuture = + val responseFuture = folderServiceAsync.rename( FolderRenameParams.builder() .folderPath("/path/of/folder") @@ -126,7 +126,7 @@ internal class FolderServiceAsyncTest { .build() ) - val jobResponse = jobResponseFuture.get() - jobResponse.validate() + val response = responseFuture.get() + 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 index e94bce66..13026e90 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 @@ -68,7 +68,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val jobResponse = + val response = folderService.copy( FolderCopyParams.builder() .destinationPath("/path/of/destination/folder") @@ -77,7 +77,7 @@ internal class FolderServiceTest { .build() ) - jobResponse.validate() + response.validate() } @Disabled("Prism tests are disabled") @@ -91,7 +91,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val jobResponse = + val response = folderService.move( FolderMoveParams.builder() .destinationPath("/path/of/destination/folder") @@ -99,7 +99,7 @@ internal class FolderServiceTest { .build() ) - jobResponse.validate() + response.validate() } @Disabled("Prism tests are disabled") @@ -113,7 +113,7 @@ internal class FolderServiceTest { .build() val folderService = client.folders() - val jobResponse = + val response = folderService.rename( FolderRenameParams.builder() .folderPath("/path/of/folder") @@ -122,6 +122,6 @@ internal class FolderServiceTest { .build() ) - jobResponse.validate() + response.validate() } } From a406482ab6ae40d7adc20a88e8659bee7cbb7f57 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:11:37 +0000 Subject: [PATCH 061/125] feat(api): manual updates --- .stats.yml | 4 +- .../api/models/folders/job/JobGetResponse.kt | 314 ++++++++++++++++-- .../models/folders/job/JobGetResponseTest.kt | 12 +- 3 files changed, 296 insertions(+), 34 deletions(-) diff --git a/.stats.yml b/.stats.yml index f16eca03..5d95bc69 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-6fee8f335061dc7a308b9a2712dce5a1c16c81125f71e00dba3e4759a39d7bf0.yml -openapi_spec_hash: 205e083e0ab6b49d5bc8a2e5b323610b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e9ae4f96eddf09567444c458e190ab6f96d0f1e1aa594793466c78791330ffde.yml +openapi_spec_hash: 88836566c32f51ff2bf66404e8b8f40e config_hash: 90f5a16140d721a24bffafbc30abaf35 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 c63515ca..b6ed81c2 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 @@ -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 @@ -14,13 +15,14 @@ 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 status: JsonField, + private val type: JsonField, private val additionalProperties: MutableMap, ) { @@ -30,8 +32,8 @@ private constructor( @JsonProperty("purgeRequestId") @ExcludeMissing purgeRequestId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this(jobId, purgeRequestId, status, type, mutableMapOf()) /** @@ -52,20 +54,20 @@ private constructor( fun purgeRequestId(): Optional = purgeRequestId.getOptional("purgeRequestId") /** - * Status of the bulk job. Possible values - `Pending`, `Completed`. + * 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") + fun status(): Optional = status.getOptional("status") /** - * Type of the bulk job. Possible values - `COPY_FOLDER`, `MOVE_FOLDER`, `RENAME_FOLDER`. + * 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") + fun type(): Optional = type.getOptional("type") /** * Returns the raw JSON value of [jobId]. @@ -88,14 +90,14 @@ private constructor( * * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + @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 + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -120,8 +122,8 @@ private 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 status: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -161,29 +163,27 @@ private constructor( this.purgeRequestId = purgeRequestId } - /** Status of the bulk job. Possible values - `Pending`, `Completed`. */ - fun status(status: String) = status(JsonField.of(status)) + /** 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 [String] value instead. This + * 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 status(status: JsonField) = apply { this.status = status } - /** - * Type of the bulk job. Possible values - `COPY_FOLDER`, `MOVE_FOLDER`, `RENAME_FOLDER`. - */ - fun type(type: String) = type(JsonField.of(type)) + /** 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 [String] value instead. This + * 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 type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -222,8 +222,8 @@ private constructor( jobId() purgeRequestId() - status() - type() + status().ifPresent { it.validate() } + type().ifPresent { it.validate() } validated = true } @@ -244,8 +244,270 @@ private constructor( internal fun validity(): Int = (if (jobId.asKnown().isPresent) 1 else 0) + (if (purgeRequestId.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + - (if (type.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) { 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 index 2482872f..502bf546 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/com/imagekit/api/models/folders/job/JobGetResponseTest.kt @@ -15,14 +15,14 @@ internal class JobGetResponseTest { JobGetResponse.builder() .jobId("5d5b1a9b4c8c4c0001f3e4a2") .purgeRequestId("purgeRequestId") - .status("Completed") - .type("COPY_FOLDER") + .status(JobGetResponse.Status.COMPLETED) + .type(JobGetResponse.Type.COPY_FOLDER) .build() assertThat(jobGetResponse.jobId()).contains("5d5b1a9b4c8c4c0001f3e4a2") assertThat(jobGetResponse.purgeRequestId()).contains("purgeRequestId") - assertThat(jobGetResponse.status()).contains("Completed") - assertThat(jobGetResponse.type()).contains("COPY_FOLDER") + assertThat(jobGetResponse.status()).contains(JobGetResponse.Status.COMPLETED) + assertThat(jobGetResponse.type()).contains(JobGetResponse.Type.COPY_FOLDER) } @Test @@ -32,8 +32,8 @@ internal class JobGetResponseTest { JobGetResponse.builder() .jobId("5d5b1a9b4c8c4c0001f3e4a2") .purgeRequestId("purgeRequestId") - .status("Completed") - .type("COPY_FOLDER") + .status(JobGetResponse.Status.COMPLETED) + .type(JobGetResponse.Type.COPY_FOLDER) .build() val roundtrippedJobGetResponse = From ae623f7be75ebbc6d69ebb6271d9f7aef2ca4e39 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:17:12 +0000 Subject: [PATCH 062/125] feat(api): manual updates --- .stats.yml | 4 +- .../beta/v2/files/FileUploadResponse.kt | 45 +++++++++++++++++- .../com/imagekit/api/models/files/File.kt | 45 +++++++++++++++++- .../api/models/files/FileUpdateResponse.kt | 46 ++++++++++++++++++- .../api/models/files/FileUploadResponse.kt | 45 +++++++++++++++++- .../models/assets/AssetListResponseTest.kt | 2 + .../beta/v2/files/FileUploadResponseTest.kt | 3 ++ .../com/imagekit/api/models/files/FileTest.kt | 3 ++ .../models/files/FileUpdateResponseTest.kt | 3 ++ .../models/files/FileUploadResponseTest.kt | 3 ++ .../api/proguard/ProGuardCompatibilityTest.kt | 2 + 11 files changed, 195 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5d95bc69..7fff3c20 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-e9ae4f96eddf09567444c458e190ab6f96d0f1e1aa594793466c78791330ffde.yml -openapi_spec_hash: 88836566c32f51ff2bf66404e8b8f40e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-64e7f6a89ec59f5801a735655ff564f48bab5be2c4d8c1146a27cdab70538945.yml +openapi_spec_hash: 581fefcb95712f716fa46f84469e6655 config_hash: 90f5a16140d721a24bffafbc30abaf35 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 17406ed9..998dc5bc 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 @@ -28,6 +28,7 @@ private constructor( 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, @@ -62,6 +63,9 @@ private constructor( @JsonProperty("customMetadata") @ExcludeMissing customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("embeddedMetadata") @ExcludeMissing @@ -100,6 +104,7 @@ private constructor( bitRate, customCoordinates, customMetadata, + description, duration, embeddedMetadata, extensionStatus, @@ -166,6 +171,15 @@ private constructor( */ 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). * @@ -366,6 +380,13 @@ private constructor( @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]. * @@ -531,6 +552,7 @@ private constructor( 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() @@ -558,6 +580,7 @@ private constructor( bitRate = fileUploadResponse.bitRate customCoordinates = fileUploadResponse.customCoordinates customMetadata = fileUploadResponse.customMetadata + description = fileUploadResponse.description duration = fileUploadResponse.duration embeddedMetadata = fileUploadResponse.embeddedMetadata extensionStatus = fileUploadResponse.extensionStatus @@ -674,6 +697,21 @@ private constructor( 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)) @@ -970,6 +1008,7 @@ private constructor( bitRate, customCoordinates, customMetadata, + description, duration, embeddedMetadata, extensionStatus, @@ -1004,6 +1043,7 @@ private constructor( bitRate() customCoordinates() customMetadata().ifPresent { it.validate() } + description() duration() embeddedMetadata().ifPresent { it.validate() } extensionStatus().ifPresent { it.validate() } @@ -1045,6 +1085,7 @@ private constructor( (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) + @@ -2334,6 +2375,7 @@ private constructor( bitRate == other.bitRate && customCoordinates == other.customCoordinates && customMetadata == other.customMetadata && + description == other.description && duration == other.duration && embeddedMetadata == other.embeddedMetadata && extensionStatus == other.extensionStatus && @@ -2362,6 +2404,7 @@ private constructor( bitRate, customCoordinates, customMetadata, + description, duration, embeddedMetadata, extensionStatus, @@ -2387,5 +2430,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUploadResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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, 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/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index 7fc5fe6b..f0b39c85 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 @@ -27,6 +27,7 @@ private constructor( 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, @@ -59,6 +60,9 @@ private constructor( @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(), @@ -89,6 +93,7 @@ private constructor( createdAt, customCoordinates, customMetadata, + description, fileId, filePath, fileType, @@ -141,6 +146,15 @@ private constructor( */ 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. * @@ -315,6 +329,13 @@ private constructor( @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]. * @@ -467,6 +488,7 @@ private constructor( 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() @@ -492,6 +514,7 @@ private constructor( createdAt = file.createdAt customCoordinates = file.customCoordinates customMetadata = file.customMetadata + description = file.description fileId = file.fileId filePath = file.filePath fileType = file.fileType @@ -587,6 +610,21 @@ private constructor( 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)) @@ -839,6 +877,7 @@ private constructor( createdAt, customCoordinates, customMetadata, + description, fileId, filePath, fileType, @@ -871,6 +910,7 @@ private constructor( createdAt() customCoordinates() customMetadata().ifPresent { it.validate() } + description() fileId() filePath() fileType() @@ -910,6 +950,7 @@ private constructor( (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) + @@ -1561,6 +1602,7 @@ private constructor( createdAt == other.createdAt && customCoordinates == other.customCoordinates && customMetadata == other.customMetadata && + description == other.description && fileId == other.fileId && filePath == other.filePath && fileType == other.fileType && @@ -1587,6 +1629,7 @@ private constructor( createdAt, customCoordinates, customMetadata, + description, fileId, filePath, fileType, @@ -1611,5 +1654,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "File{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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, 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 b09444fd..d8ecc3ec 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 @@ -27,6 +27,7 @@ private constructor( 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, @@ -62,6 +63,9 @@ private constructor( @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(), @@ -95,6 +99,7 @@ private constructor( createdAt, customCoordinates, customMetadata, + description, fileId, filePath, fileType, @@ -122,6 +127,7 @@ private constructor( .createdAt(createdAt) .customCoordinates(customCoordinates) .customMetadata(customMetadata) + .description(description) .fileId(fileId) .filePath(filePath) .fileType(fileType) @@ -174,6 +180,15 @@ private constructor( 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. * @@ -355,6 +370,13 @@ private constructor( @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]. * @@ -516,6 +538,7 @@ private constructor( 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() @@ -542,6 +565,7 @@ private constructor( createdAt = fileUpdateResponse.createdAt customCoordinates = fileUpdateResponse.customCoordinates customMetadata = fileUpdateResponse.customMetadata + description = fileUpdateResponse.description fileId = fileUpdateResponse.fileId filePath = fileUpdateResponse.filePath fileType = fileUpdateResponse.fileType @@ -638,6 +662,21 @@ private constructor( 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)) @@ -904,6 +943,7 @@ private constructor( createdAt, customCoordinates, customMetadata, + description, fileId, filePath, fileType, @@ -937,6 +977,7 @@ private constructor( createdAt() customCoordinates() customMetadata().ifPresent { it.validate() } + description() fileId() filePath() fileType() @@ -977,6 +1018,7 @@ private constructor( (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) + @@ -1834,6 +1876,7 @@ private constructor( createdAt == other.createdAt && customCoordinates == other.customCoordinates && customMetadata == other.customMetadata && + description == other.description && fileId == other.fileId && filePath == other.filePath && fileType == other.fileType && @@ -1861,6 +1904,7 @@ private constructor( createdAt, customCoordinates, customMetadata, + description, fileId, filePath, fileType, @@ -1886,5 +1930,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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, 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/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index 65988000..bc35d2eb 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 @@ -27,6 +27,7 @@ private constructor( 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, @@ -61,6 +62,9 @@ private constructor( @JsonProperty("customMetadata") @ExcludeMissing customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("embeddedMetadata") @ExcludeMissing @@ -99,6 +103,7 @@ private constructor( bitRate, customCoordinates, customMetadata, + description, duration, embeddedMetadata, extensionStatus, @@ -165,6 +170,15 @@ private constructor( */ 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). * @@ -365,6 +379,13 @@ private constructor( @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]. * @@ -530,6 +551,7 @@ private constructor( 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() @@ -557,6 +579,7 @@ private constructor( bitRate = fileUploadResponse.bitRate customCoordinates = fileUploadResponse.customCoordinates customMetadata = fileUploadResponse.customMetadata + description = fileUploadResponse.description duration = fileUploadResponse.duration embeddedMetadata = fileUploadResponse.embeddedMetadata extensionStatus = fileUploadResponse.extensionStatus @@ -673,6 +696,21 @@ private constructor( 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)) @@ -969,6 +1007,7 @@ private constructor( bitRate, customCoordinates, customMetadata, + description, duration, embeddedMetadata, extensionStatus, @@ -1003,6 +1042,7 @@ private constructor( bitRate() customCoordinates() customMetadata().ifPresent { it.validate() } + description() duration() embeddedMetadata().ifPresent { it.validate() } extensionStatus().ifPresent { it.validate() } @@ -1044,6 +1084,7 @@ private constructor( (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) + @@ -2333,6 +2374,7 @@ private constructor( bitRate == other.bitRate && customCoordinates == other.customCoordinates && customMetadata == other.customMetadata && + description == other.description && duration == other.duration && embeddedMetadata == other.embeddedMetadata && extensionStatus == other.extensionStatus && @@ -2361,6 +2403,7 @@ private constructor( bitRate, customCoordinates, customMetadata, + description, duration, embeddedMetadata, extensionStatus, @@ -2386,5 +2429,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUploadResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, 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, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, 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 309be429..70896711 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 @@ -31,6 +31,7 @@ internal class AssetListResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -72,6 +73,7 @@ internal class AssetListResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .fileId("fileId") .filePath("filePath") .fileType("fileType") 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 d497ecf9..d20ca12d 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 @@ -31,6 +31,7 @@ internal class FileUploadResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .duration(0L) .embeddedMetadata( FileUploadResponse.EmbeddedMetadata.builder() @@ -167,6 +168,7 @@ internal class FileUploadResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + assertThat(fileUploadResponse.description()).contains("description") assertThat(fileUploadResponse.duration()).contains(0L) assertThat(fileUploadResponse.embeddedMetadata()) .contains( @@ -308,6 +310,7 @@ internal class FileUploadResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .duration(0L) .embeddedMetadata( FileUploadResponse.EmbeddedMetadata.builder() 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 744e6ec1..78282e94 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 @@ -26,6 +26,7 @@ internal class FileTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -57,6 +58,7 @@ internal class FileTest { .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") @@ -92,6 +94,7 @@ internal class FileTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .fileId("fileId") .filePath("filePath") .fileType("fileType") 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 28d9d15c..de6e3a66 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 @@ -26,6 +26,7 @@ internal class FileUpdateResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -70,6 +71,7 @@ internal class FileUpdateResponseTest { .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") @@ -115,6 +117,7 @@ internal class FileUpdateResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .fileId("fileId") .filePath("filePath") .fileType("fileType") 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 08ced347..44190124 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 @@ -30,6 +30,7 @@ internal class FileUploadResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .duration(0L) .embeddedMetadata( FileUploadResponse.EmbeddedMetadata.builder() @@ -166,6 +167,7 @@ internal class FileUploadResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + assertThat(fileUploadResponse.description()).contains("description") assertThat(fileUploadResponse.duration()).contains(0L) assertThat(fileUploadResponse.embeddedMetadata()) .contains( @@ -307,6 +309,7 @@ internal class FileUploadResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .duration(0L) .embeddedMetadata( FileUploadResponse.EmbeddedMetadata.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 fc696c50..25a1fd27 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 @@ -79,6 +79,7 @@ internal class ProGuardCompatibilityTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -120,6 +121,7 @@ internal class ProGuardCompatibilityTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .description("description") .fileId("fileId") .filePath("filePath") .fileType("fileType") From 4aa402278a846da5968e00c0dfe7be00a1e87818 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:22:34 +0000 Subject: [PATCH 063/125] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7fff3c20..b8f03deb 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-64e7f6a89ec59f5801a735655ff564f48bab5be2c4d8c1146a27cdab70538945.yml -openapi_spec_hash: 581fefcb95712f716fa46f84469e6655 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-53f7c35748f9b41bb07f888796c7417ea84e5e63ab0e9e2aa4a8d64e48713b24.yml +openapi_spec_hash: 098ce74bcff31c61870e3d0ce357814b config_hash: 90f5a16140d721a24bffafbc30abaf35 From 31827c08b53a704351fdf7a690fb7646a38d0481 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:28:04 +0000 Subject: [PATCH 064/125] feat(api): manual updates --- .stats.yml | 2 +- .../imagekit/api/models/{files => }/File.kt | 2 +- .../imagekit/api/models/{files => }/Folder.kt | 2 +- .../api/models/assets/AssetListResponse.kt | 4 +- .../api/models/files/FileUpdateResponse.kt | 1 + .../api/services/async/FileServiceAsync.kt | 2 +- .../services/async/FileServiceAsyncImpl.kt | 2 +- .../async/files/VersionServiceAsync.kt | 2 +- .../async/files/VersionServiceAsyncImpl.kt | 2 +- .../api/services/blocking/FileService.kt | 2 +- .../api/services/blocking/FileServiceImpl.kt | 2 +- .../services/blocking/files/VersionService.kt | 2 +- .../blocking/files/VersionServiceImpl.kt | 2 +- .../api/models/{files => }/FileTest.kt | 2 +- .../api/models/{files => }/FolderTest.kt | 2 +- .../models/assets/AssetListResponseTest.kt | 4 +- .../models/files/FileUpdateResponseTest.kt | 1 + .../api/proguard/ProGuardCompatibilityTest.kt | 126 +++++++++++++----- 18 files changed, 112 insertions(+), 50 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{files => }/File.kt (99%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{files => }/Folder.kt (99%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{files => }/FileTest.kt (99%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{files => }/FolderTest.kt (97%) diff --git a/.stats.yml b/.stats.yml index b8f03deb..cb0d8e12 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-53f7c35748f9b41bb07f888796c7417ea84e5e63ab0e9e2aa4a8d64e48713b24.yml openapi_spec_hash: 098ce74bcff31c61870e3d0ce357814b -config_hash: 90f5a16140d721a24bffafbc30abaf35 +config_hash: b8c48b915f11a452e84fafc0e851a772 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/File.kt similarity index 99% 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/com/imagekit/api/models/File.kt index f0b39c85..81191b6b 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/File.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter 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/Folder.kt similarity index 99% 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/com/imagekit/api/models/Folder.kt index 3e7c9a34..be7c0839 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/Folder.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter 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 index 8e1fbee8..a5b370d0 100644 --- 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 @@ -14,8 +14,8 @@ 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 com.imagekit.api.models.File +import com.imagekit.api.models.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/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index d8ecc3ec..3b8365e9 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,7 @@ 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.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/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index 3695f29f..c1aa6bd7 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 @@ -6,7 +6,7 @@ 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.File import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileCopyResponse import com.imagekit.api.models.files.FileDeleteParams 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..c9724710 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 @@ -18,7 +18,7 @@ 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.File import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileCopyResponse import com.imagekit.api.models.files.FileDeleteParams 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 index 62bdd118..5342ea6c 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/com/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -5,7 +5,7 @@ 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.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 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 index c601ebe2..52225b19 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/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -16,7 +16,7 @@ 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.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 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 0aba8894..4f2b407d 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 @@ -7,7 +7,7 @@ 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.File import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileCopyResponse import com.imagekit.api.models.files.FileDeleteParams 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..78ca4cf3 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 @@ -18,7 +18,7 @@ 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.File import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileCopyResponse import com.imagekit.api.models.files.FileDeleteParams 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 index eb1195eb..679b84ae 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/com/imagekit/api/services/blocking/files/VersionService.kt @@ -6,7 +6,7 @@ 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.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 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 index 2637882f..0f7431c1 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/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -16,7 +16,7 @@ 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.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 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/FileTest.kt similarity index 99% 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/com/imagekit/api/models/FileTest.kt index 78282e94..f3810341 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/FileTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue 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/FolderTest.kt similarity index 97% 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/com/imagekit/api/models/FolderTest.kt index e4c406e6..bd6807a6 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/FolderTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package com.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.jsonMapper 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..dc314a4d 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,8 +6,8 @@ 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 com.imagekit.api.models.File +import com.imagekit.api.models.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/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index de6e3a66..e89b4380 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,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 com.imagekit.api.models.File import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat 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 25a1fd27..f5800d7e 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,9 @@ 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.File import com.imagekit.api.models.assets.AssetListResponse -import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -65,44 +66,103 @@ internal class ProGuardCompatibilityTest { } @Test - fun fileRoundtrip() { + fun metadataRoundtrip() { 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")) + 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() ) - .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) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) .build() - val roundtrippedFile = - jsonMapper.readValue(jsonMapper.writeValueAsString(file), jacksonTypeRef()) + val roundtrippedMetadata = + jsonMapper.readValue( + jsonMapper.writeValueAsString(metadata), + jacksonTypeRef(), + ) - assertThat(roundtrippedFile).isEqualTo(file) + assertThat(roundtrippedMetadata).isEqualTo(metadata) } @Test From 0ed5a25331988c4116ec6371b3e734a25d468daa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:34:19 +0000 Subject: [PATCH 065/125] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/assets/AssetListResponse.kt | 4 +- .../imagekit/api/models/{ => files}/File.kt | 2 +- .../api/models/files/FileUpdateResponse.kt | 1 - .../imagekit/api/models/{ => files}/Folder.kt | 2 +- .../api/services/async/FileServiceAsync.kt | 2 +- .../services/async/FileServiceAsyncImpl.kt | 2 +- .../async/files/VersionServiceAsync.kt | 2 +- .../async/files/VersionServiceAsyncImpl.kt | 2 +- .../api/services/blocking/FileService.kt | 2 +- .../api/services/blocking/FileServiceImpl.kt | 2 +- .../services/blocking/files/VersionService.kt | 2 +- .../blocking/files/VersionServiceImpl.kt | 2 +- .../models/assets/AssetListResponseTest.kt | 4 +- .../api/models/{ => files}/FileTest.kt | 2 +- .../models/files/FileUpdateResponseTest.kt | 1 - .../api/models/{ => files}/FolderTest.kt | 2 +- .../api/proguard/ProGuardCompatibilityTest.kt | 126 +++++------------- 18 files changed, 50 insertions(+), 112 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{ => files}/File.kt (99%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/{ => files}/Folder.kt (99%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{ => files}/FileTest.kt (99%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/{ => files}/FolderTest.kt (97%) diff --git a/.stats.yml b/.stats.yml index cb0d8e12..b8f03deb 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-53f7c35748f9b41bb07f888796c7417ea84e5e63ab0e9e2aa4a8d64e48713b24.yml openapi_spec_hash: 098ce74bcff31c61870e3d0ce357814b -config_hash: b8c48b915f11a452e84fafc0e851a772 +config_hash: 90f5a16140d721a24bffafbc30abaf35 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 index a5b370d0..8e1fbee8 100644 --- 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 @@ -14,8 +14,8 @@ 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.File -import com.imagekit.api.models.Folder +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 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/File.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index 81191b6b..f0b39c85 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/File.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package com.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter 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 3b8365e9..d8ecc3ec 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,7 +14,6 @@ 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.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/Folder.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Folder.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt index be7c0839..3e7c9a34 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Folder.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package com.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter 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 c1aa6bd7..3695f29f 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 @@ -6,7 +6,7 @@ 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.File +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 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 c9724710..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 @@ -18,7 +18,7 @@ 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.File +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 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 index 5342ea6c..62bdd118 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/com/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -5,7 +5,7 @@ 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.File +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 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 index 52225b19..c601ebe2 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/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -16,7 +16,7 @@ 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.File +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 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 4f2b407d..0aba8894 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 @@ -7,7 +7,7 @@ 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.File +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 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 78ca4cf3..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 @@ -18,7 +18,7 @@ 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.File +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 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 index 679b84ae..eb1195eb 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/com/imagekit/api/services/blocking/files/VersionService.kt @@ -6,7 +6,7 @@ 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.File +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 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 index 0f7431c1..2637882f 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/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -16,7 +16,7 @@ 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.File +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 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 dc314a4d..70896711 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,8 +6,8 @@ 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.File -import com.imagekit.api.models.Folder +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 diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/FileTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/FileTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt index f3810341..78282e94 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/FileTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue 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 e89b4380..de6e3a66 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,7 +5,6 @@ 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.File 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/FolderTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/FolderTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt index bd6807a6..e4c406e6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/FolderTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.jsonMapper 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 f5800d7e..25a1fd27 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,9 +6,8 @@ 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.File import com.imagekit.api.models.assets.AssetListResponse -import com.imagekit.api.models.files.Metadata +import com.imagekit.api.models.files.File import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -66,103 +65,44 @@ internal class ProGuardCompatibilityTest { } @Test - fun metadataRoundtrip() { + fun fileRoundtrip() { 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() - ) + 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() ) - .format("format") - .hasColorProfile(true) - .hasTransparency(true) - .height(0L) - .pHash("pHash") - .quality(0L) - .size(0L) - .videoCodec("videoCodec") - .width(0L) + .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 roundtrippedMetadata = - jsonMapper.readValue( - jsonMapper.writeValueAsString(metadata), - jacksonTypeRef(), - ) + val roundtrippedFile = + jsonMapper.readValue(jsonMapper.writeValueAsString(file), jacksonTypeRef()) - assertThat(roundtrippedMetadata).isEqualTo(metadata) + assertThat(roundtrippedFile).isEqualTo(file) } @Test From f727a6cd5fba12f3ce309132870bab46fa3d3111 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 25 Aug 2025 07:50:45 +0000 Subject: [PATCH 066/125] feat(api): manual updates --- .stats.yml | 4 +- .../beta/v2/files/FileUploadParamsTest.kt | 87 +- .../api/models/files/FileUploadParamsTest.kt | 87 +- .../api/services/ErrorHandlingTest.kt | 765 ++++++++++-------- .../api/services/ServiceParamsTest.kt | 44 +- .../services/async/FileServiceAsyncTest.kt | 45 +- .../async/beta/v2/FileServiceAsyncTest.kt | 45 +- .../api/services/blocking/FileServiceTest.kt | 45 +- .../blocking/beta/v2/FileServiceTest.kt | 45 +- 9 files changed, 654 insertions(+), 513 deletions(-) diff --git a/.stats.yml b/.stats.yml index b8f03deb..82cd02a9 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-53f7c35748f9b41bb07f888796c7417ea84e5e63ab0e9e2aa4a8d64e48713b24.yml -openapi_spec_hash: 098ce74bcff31c61870e3d0ce357814b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e798e75f763868cfd2babe250a0d880a651b19f9e1b9a3b567d629eea9893147.yml +openapi_spec_hash: 45341845beb1363b7dcb4050934b9cf0 config_hash: 90f5a16140d721a24bffafbc30abaf35 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 6014cd06..89ff5672 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 @@ -25,24 +25,32 @@ internal class FileUploadParamsTest { .build() ) .description("Running shoes") - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name(FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) - .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) @@ -96,26 +104,32 @@ internal class FileUploadParamsTest { .build() ) .description("Running shoes") - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING - ) - .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) @@ -203,6 +217,7 @@ internal class FileUploadParamsTest { ) .build() ), + FileUploadParams.Extension.ofAiAutoDescription(), ) ), "folder" to MultipartField.of("folder"), 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 bd43f8d5..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 @@ -26,24 +26,32 @@ internal class FileUploadParamsTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name(FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) - .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) @@ -100,26 +108,32 @@ internal class FileUploadParamsTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING - ) - .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) @@ -210,6 +224,7 @@ internal class FileUploadParamsTest { ) .build() ), + FileUploadParams.Extension.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 b4e13c9c..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 @@ -86,27 +86,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -181,27 +186,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -276,27 +286,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -371,27 +386,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -466,27 +486,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -561,27 +586,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -656,27 +686,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -751,27 +786,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -846,27 +886,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -941,27 +986,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -1036,27 +1086,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -1131,27 +1186,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -1226,27 +1286,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -1321,27 +1386,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -1416,27 +1486,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -1511,27 +1586,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) @@ -1604,27 +1684,32 @@ internal class ErrorHandlingTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) 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 48b0f08d..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 @@ -58,26 +58,32 @@ internal class ServiceParamsTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING - ) - .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) 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 947eac17..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 @@ -240,27 +240,32 @@ internal class FileServiceAsyncTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) 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 152694fa..d98f98fc 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 @@ -39,27 +39,32 @@ internal class FileServiceAsyncTest { .build() ) .description("Running shoes") - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) 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 a55fbd4e..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 @@ -233,27 +233,32 @@ internal class FileServiceTest { ) .description("Running shoes") .expire(0L) - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) 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 d92b160a..07b702f8 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 @@ -39,27 +39,32 @@ internal class FileServiceTest { .build() ) .description("Running shoes") - .addExtension( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .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() - ) - .build() - ) - .addExtension( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .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) From b4af4d02f17f6fdb5ff43b012ce094d1859e29ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 26 Aug 2025 12:25:28 +0000 Subject: [PATCH 067/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 82cd02a9..2feea331 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-e798e75f763868cfd2babe250a0d880a651b19f9e1b9a3b567d629eea9893147.yml openapi_spec_hash: 45341845beb1363b7dcb4050934b9cf0 -config_hash: 90f5a16140d721a24bffafbc30abaf35 +config_hash: d1c62fed14fedf6774ac70983dc71d68 From 300fd9967cb642d93ff5e280bef7f2d059bd4a48 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 27 Aug 2025 14:58:04 +0000 Subject: [PATCH 068/125] feat(api): add models back to Webhooks --- .stats.yml | 2 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 73 +++---- .../api/models/webhooks/UnwrapWebhookEvent.kt | 67 +++---- ...kt => VideoTransformationAcceptedEvent.kt} | 39 ++-- ...nt.kt => VideoTransformationErrorEvent.kt} | 35 ++-- ...nt.kt => VideoTransformationReadyEvent.kt} | 37 ++-- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 182 ++++++++---------- .../models/webhooks/UnwrapWebhookEventTest.kt | 182 ++++++++---------- ...> VideoTransformationAcceptedEventTest.kt} | 102 +++++----- ...t => VideoTransformationErrorEventTest.kt} | 109 +++++------ ...t => VideoTransformationReadyEventTest.kt} | 117 ++++++----- 11 files changed, 413 insertions(+), 532 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationAcceptedWebhookEvent.kt => VideoTransformationAcceptedEvent.kt} (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationErrorWebhookEvent.kt => VideoTransformationErrorEvent.kt} (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationReadyWebhookEvent.kt => VideoTransformationReadyEvent.kt} (98%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationAcceptedWebhookEventTest.kt => VideoTransformationAcceptedEventTest.kt} (67%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationErrorWebhookEventTest.kt => VideoTransformationErrorEventTest.kt} (70%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationReadyWebhookEventTest.kt => VideoTransformationReadyEventTest.kt} (72%) diff --git a/.stats.yml b/.stats.yml index 2feea331..aa083b75 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-e798e75f763868cfd2babe250a0d880a651b19f9e1b9a3b567d629eea9893147.yml openapi_spec_hash: 45341845beb1363b7dcb4050934b9cf0 -config_hash: d1c62fed14fedf6774ac70983dc71d68 +config_hash: 128de0925828937e2ae36770e7f6029a 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 3d9637ee..49d16f6d 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 @@ -22,19 +22,19 @@ import java.util.Optional @JsonSerialize(using = UnsafeUnwrapWebhookEvent.Serializer::class) class UnsafeUnwrapWebhookEvent private constructor( - private val videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent? = null, - private val videoTransformationReady: VideoTransformationReadyWebhookEvent? = null, - private val videoTransformationError: VideoTransformationErrorWebhookEvent? = null, + private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, + private val videoTransformationReady: VideoTransformationReadyEvent? = null, + private val videoTransformationError: VideoTransformationErrorEvent? = null, private val _json: JsonValue? = null, ) { - fun videoTransformationAccepted(): Optional = + fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) - fun videoTransformationReady(): Optional = + fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) - fun videoTransformationError(): Optional = + fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -43,13 +43,13 @@ private constructor( fun isVideoTransformationError(): Boolean = videoTransformationError != null - fun asVideoTransformationAccepted(): VideoTransformationAcceptedWebhookEvent = + fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") - fun asVideoTransformationReady(): VideoTransformationReadyWebhookEvent = + fun asVideoTransformationReady(): VideoTransformationReadyEvent = videoTransformationReady.getOrThrow("videoTransformationReady") - fun asVideoTransformationError(): VideoTransformationErrorWebhookEvent = + fun asVideoTransformationError(): VideoTransformationErrorEvent = videoTransformationError.getOrThrow("videoTransformationError") fun _json(): Optional = Optional.ofNullable(_json) @@ -75,19 +75,19 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) { videoTransformationAccepted.validate() } override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ) { videoTransformationReady.validate() } override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ) { videoTransformationError.validate() } @@ -114,15 +114,15 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) = videoTransformationAccepted.validity() override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ) = videoTransformationReady.validity() override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ) = videoTransformationError.validity() override fun unknown(json: JsonValue?) = 0 @@ -163,18 +163,16 @@ private constructor( @JvmStatic fun ofVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) = UnsafeUnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) @JvmStatic - fun ofVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent - ) = UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = + UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) @JvmStatic - fun ofVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent - ) = UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) + fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = + UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) } /** @@ -184,15 +182,15 @@ private constructor( interface Visitor { fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ): T fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ): T fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ): T /** @@ -218,30 +216,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) + 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(videoTransformationReady = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(videoTransformationError = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } 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 20867724..14560566 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 @@ -22,19 +22,19 @@ import java.util.Optional @JsonSerialize(using = UnwrapWebhookEvent.Serializer::class) class UnwrapWebhookEvent private constructor( - private val videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent? = null, - private val videoTransformationReady: VideoTransformationReadyWebhookEvent? = null, - private val videoTransformationError: VideoTransformationErrorWebhookEvent? = null, + private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, + private val videoTransformationReady: VideoTransformationReadyEvent? = null, + private val videoTransformationError: VideoTransformationErrorEvent? = null, private val _json: JsonValue? = null, ) { - fun videoTransformationAccepted(): Optional = + fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) - fun videoTransformationReady(): Optional = + fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) - fun videoTransformationError(): Optional = + fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -43,13 +43,13 @@ private constructor( fun isVideoTransformationError(): Boolean = videoTransformationError != null - fun asVideoTransformationAccepted(): VideoTransformationAcceptedWebhookEvent = + fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") - fun asVideoTransformationReady(): VideoTransformationReadyWebhookEvent = + fun asVideoTransformationReady(): VideoTransformationReadyEvent = videoTransformationReady.getOrThrow("videoTransformationReady") - fun asVideoTransformationError(): VideoTransformationErrorWebhookEvent = + fun asVideoTransformationError(): VideoTransformationErrorEvent = videoTransformationError.getOrThrow("videoTransformationError") fun _json(): Optional = Optional.ofNullable(_json) @@ -75,19 +75,19 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) { videoTransformationAccepted.validate() } override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ) { videoTransformationReady.validate() } override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ) { videoTransformationError.validate() } @@ -114,15 +114,15 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) = videoTransformationAccepted.validity() override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ) = videoTransformationReady.validity() override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ) = videoTransformationError.validity() override fun unknown(json: JsonValue?) = 0 @@ -163,18 +163,16 @@ private constructor( @JvmStatic fun ofVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) = UnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) @JvmStatic - fun ofVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent - ) = UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = + UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) @JvmStatic - fun ofVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent - ) = UnwrapWebhookEvent(videoTransformationError = videoTransformationError) + fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = + UnwrapWebhookEvent(videoTransformationError = videoTransformationError) } /** @@ -184,15 +182,15 @@ private constructor( interface Visitor { fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ): T fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ): T fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ): T /** @@ -217,21 +215,16 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) + 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(videoTransformationReady = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(videoTransformationError = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt index 60f51bed..99f84cc8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationAcceptedWebhookEvent +class VideoTransformationAcceptedEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -125,7 +125,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationAcceptedWebhookEvent]. + * [VideoTransformationAcceptedEvent]. * * The following fields are required: * ```java @@ -138,7 +138,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationAcceptedWebhookEvent]. */ + /** A builder for [VideoTransformationAcceptedEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -149,17 +149,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - videoTransformationAcceptedWebhookEvent: VideoTransformationAcceptedWebhookEvent - ) = apply { - id = videoTransformationAcceptedWebhookEvent.id - createdAt = videoTransformationAcceptedWebhookEvent.createdAt - data = videoTransformationAcceptedWebhookEvent.data - request = videoTransformationAcceptedWebhookEvent.request - type = videoTransformationAcceptedWebhookEvent.type - additionalProperties = - videoTransformationAcceptedWebhookEvent.additionalProperties.toMutableMap() - } + 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)) @@ -237,7 +236,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationAcceptedWebhookEvent]. + * Returns an immutable instance of [VideoTransformationAcceptedEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -251,8 +250,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationAcceptedWebhookEvent = - VideoTransformationAcceptedWebhookEvent( + fun build(): VideoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -264,7 +263,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationAcceptedWebhookEvent = apply { + fun validate(): VideoTransformationAcceptedEvent = apply { if (validated) { return@apply } @@ -2211,7 +2210,7 @@ private constructor( return true } - return other is VideoTransformationAcceptedWebhookEvent && + return other is VideoTransformationAcceptedEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2227,5 +2226,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationAcceptedWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "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/VideoTransformationErrorWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt index 4e8911b5..009db96d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationErrorWebhookEvent +class VideoTransformationErrorEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -125,7 +125,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationErrorWebhookEvent]. + * [VideoTransformationErrorEvent]. * * The following fields are required: * ```java @@ -138,7 +138,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationErrorWebhookEvent]. */ + /** A builder for [VideoTransformationErrorEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -149,16 +149,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - videoTransformationErrorWebhookEvent: VideoTransformationErrorWebhookEvent - ) = apply { - id = videoTransformationErrorWebhookEvent.id - createdAt = videoTransformationErrorWebhookEvent.createdAt - data = videoTransformationErrorWebhookEvent.data - request = videoTransformationErrorWebhookEvent.request - type = videoTransformationErrorWebhookEvent.type - additionalProperties = - videoTransformationErrorWebhookEvent.additionalProperties.toMutableMap() + 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. */ @@ -237,7 +234,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationErrorWebhookEvent]. + * Returns an immutable instance of [VideoTransformationErrorEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -251,8 +248,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationErrorWebhookEvent = - VideoTransformationErrorWebhookEvent( + fun build(): VideoTransformationErrorEvent = + VideoTransformationErrorEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -264,7 +261,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationErrorWebhookEvent = apply { + fun validate(): VideoTransformationErrorEvent = apply { if (validated) { return@apply } @@ -2545,7 +2542,7 @@ private constructor( return true } - return other is VideoTransformationErrorWebhookEvent && + return other is VideoTransformationErrorEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2561,5 +2558,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationErrorWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "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/VideoTransformationReadyWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt index 3a99ebb5..49d51e5b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationReadyWebhookEvent +class VideoTransformationReadyEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -140,7 +140,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationReadyWebhookEvent]. + * [VideoTransformationReadyEvent]. * * The following fields are required: * ```java @@ -153,7 +153,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationReadyWebhookEvent]. */ + /** A builder for [VideoTransformationReadyEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -165,17 +165,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - videoTransformationReadyWebhookEvent: VideoTransformationReadyWebhookEvent - ) = apply { - id = videoTransformationReadyWebhookEvent.id - createdAt = videoTransformationReadyWebhookEvent.createdAt - data = videoTransformationReadyWebhookEvent.data - request = videoTransformationReadyWebhookEvent.request - type = videoTransformationReadyWebhookEvent.type - timings = videoTransformationReadyWebhookEvent.timings - additionalProperties = - videoTransformationReadyWebhookEvent.additionalProperties.toMutableMap() + 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. */ @@ -264,7 +261,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationReadyWebhookEvent]. + * Returns an immutable instance of [VideoTransformationReadyEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -278,8 +275,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationReadyWebhookEvent = - VideoTransformationReadyWebhookEvent( + fun build(): VideoTransformationReadyEvent = + VideoTransformationReadyEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -292,7 +289,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationReadyWebhookEvent = apply { + fun validate(): VideoTransformationReadyEvent = apply { if (validated) { return@apply } @@ -2962,7 +2959,7 @@ private constructor( return true } - return other is VideoTransformationReadyWebhookEvent && + return other is VideoTransformationReadyEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2979,5 +2976,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationReadyWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, timings=$timings, additionalProperties=$additionalProperties}" + "VideoTransformationReadyEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, timings=$timings, additionalProperties=$additionalProperties}" } 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 4c4d677d..dfd0c0e4 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 @@ -18,53 +18,48 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationAccepted() { val videoTransformationAccepted = - VideoTransformationAcceptedWebhookEvent.builder() + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -76,7 +71,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -98,55 +93,48 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationAccepted( - VideoTransformationAcceptedWebhookEvent.builder() + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -158,7 +146,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -179,48 +167,48 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationReady() { val videoTransformationReady = - VideoTransformationReadyWebhookEvent.builder() + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -228,12 +216,11 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -249,14 +236,14 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -277,54 +264,48 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationReady( - VideoTransformationReadyWebhookEvent.builder() + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -332,13 +313,11 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Output .VideoMetadata .builder() @@ -355,14 +334,14 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -382,59 +361,58 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationError() { val videoTransformationError = - VideoTransformationErrorWebhookEvent.builder() + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -446,7 +424,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -468,30 +446,27 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationError( - VideoTransformationErrorWebhookEvent.builder() + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Error .Reason .ENCODING_FAILED @@ -499,36 +474,31 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -540,7 +510,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") 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 4b31cdb6..1af001c6 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 @@ -18,53 +18,48 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationAccepted() { val videoTransformationAccepted = - VideoTransformationAcceptedWebhookEvent.builder() + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -76,7 +71,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -98,55 +93,48 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationAccepted( - VideoTransformationAcceptedWebhookEvent.builder() + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -158,7 +146,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -179,48 +167,48 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationReady() { val videoTransformationReady = - VideoTransformationReadyWebhookEvent.builder() + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -228,12 +216,11 @@ internal class UnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -249,14 +236,14 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -276,54 +263,48 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationReady( - VideoTransformationReadyWebhookEvent.builder() + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -331,13 +312,11 @@ internal class UnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Output .VideoMetadata .builder() @@ -354,14 +333,14 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -381,59 +360,58 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationError() { val videoTransformationError = - VideoTransformationErrorWebhookEvent.builder() + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -445,7 +423,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -466,30 +444,27 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationError( - VideoTransformationErrorWebhookEvent.builder() + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Error .Reason .ENCODING_FAILED @@ -497,36 +472,31 @@ internal class UnwrapWebhookEventTest { .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -538,7 +508,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt similarity index 67% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt index bc1840af..e3c95329 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt @@ -8,58 +8,53 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationAcceptedWebhookEventTest { +internal class VideoTransformationAcceptedEventTest { @Test fun create() { - val videoTransformationAcceptedWebhookEvent = - VideoTransformationAcceptedWebhookEvent.builder() + val videoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -71,7 +66,7 @@ internal class VideoTransformationAcceptedWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -79,50 +74,46 @@ internal class VideoTransformationAcceptedWebhookEventTest { ) .build() - assertThat(videoTransformationAcceptedWebhookEvent.id()).isEqualTo("id") - assertThat(videoTransformationAcceptedWebhookEvent.createdAt()) + assertThat(videoTransformationAcceptedEvent.id()).isEqualTo("id") + assertThat(videoTransformationAcceptedEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationAcceptedWebhookEvent.data()) + assertThat(videoTransformationAcceptedEvent.data()) .isEqualTo( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .VideoCodec .H264 ) @@ -132,9 +123,9 @@ internal class VideoTransformationAcceptedWebhookEventTest { ) .build() ) - assertThat(videoTransformationAcceptedWebhookEvent.request()) + assertThat(videoTransformationAcceptedEvent.request()) .isEqualTo( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -145,54 +136,49 @@ internal class VideoTransformationAcceptedWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationAcceptedWebhookEvent = - VideoTransformationAcceptedWebhookEvent.builder() + val videoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -204,7 +190,7 @@ internal class VideoTransformationAcceptedWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -212,13 +198,13 @@ internal class VideoTransformationAcceptedWebhookEventTest { ) .build() - val roundtrippedVideoTransformationAcceptedWebhookEvent = + val roundtrippedVideoTransformationAcceptedEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationAcceptedWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationAcceptedEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationAcceptedWebhookEvent) - .isEqualTo(videoTransformationAcceptedWebhookEvent) + assertThat(roundtrippedVideoTransformationAcceptedEvent) + .isEqualTo(videoTransformationAcceptedEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt similarity index 70% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt index 5cf7bfe7..4d2b3f63 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt @@ -8,64 +8,63 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationErrorWebhookEventTest { +internal class VideoTransformationErrorEventTest { @Test fun create() { - val videoTransformationErrorWebhookEvent = - VideoTransformationErrorWebhookEvent.builder() + val videoTransformationErrorEvent = + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -77,7 +76,7 @@ internal class VideoTransformationErrorWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -85,61 +84,54 @@ internal class VideoTransformationErrorWebhookEventTest { ) .build() - assertThat(videoTransformationErrorWebhookEvent.id()).isEqualTo("id") - assertThat(videoTransformationErrorWebhookEvent.createdAt()) + assertThat(videoTransformationErrorEvent.id()).isEqualTo("id") + assertThat(videoTransformationErrorEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationErrorWebhookEvent.data()) + assertThat(videoTransformationErrorEvent.data()) .isEqualTo( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error - .builder() + VideoTransformationErrorEvent.Data.Transformation.Error.builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options - .builder() + VideoTransformationErrorEvent.Data.Transformation.Options.builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .VideoCodec .H264 ) @@ -149,9 +141,9 @@ internal class VideoTransformationErrorWebhookEventTest { ) .build() ) - assertThat(videoTransformationErrorWebhookEvent.request()) + assertThat(videoTransformationErrorEvent.request()) .isEqualTo( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -162,60 +154,59 @@ internal class VideoTransformationErrorWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationErrorWebhookEvent = - VideoTransformationErrorWebhookEvent.builder() + val videoTransformationErrorEvent = + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -227,7 +218,7 @@ internal class VideoTransformationErrorWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -235,13 +226,13 @@ internal class VideoTransformationErrorWebhookEventTest { ) .build() - val roundtrippedVideoTransformationErrorWebhookEvent = + val roundtrippedVideoTransformationErrorEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationErrorWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationErrorEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationErrorWebhookEvent) - .isEqualTo(videoTransformationErrorWebhookEvent) + assertThat(roundtrippedVideoTransformationErrorEvent) + .isEqualTo(videoTransformationErrorEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt similarity index 72% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt index c9ad1646..2c9c0127 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt @@ -8,53 +8,53 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationReadyWebhookEventTest { +internal class VideoTransformationReadyEventTest { @Test fun create() { - val videoTransformationReadyWebhookEvent = - VideoTransformationReadyWebhookEvent.builder() + val videoTransformationReadyEvent = + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -62,12 +62,11 @@ internal class VideoTransformationReadyWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -83,76 +82,69 @@ internal class VideoTransformationReadyWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() ) .build() - assertThat(videoTransformationReadyWebhookEvent.id()).isEqualTo("id") - assertThat(videoTransformationReadyWebhookEvent.createdAt()) + assertThat(videoTransformationReadyEvent.id()).isEqualTo("id") + assertThat(videoTransformationReadyEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationReadyWebhookEvent.data()) + assertThat(videoTransformationReadyEvent.data()) .isEqualTo( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options - .builder() + VideoTransformationReadyEvent.Data.Transformation.Options.builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .VideoCodec .H264 ) .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output - .builder() + VideoTransformationReadyEvent.Data.Transformation.Output.builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -167,17 +159,17 @@ internal class VideoTransformationReadyWebhookEventTest { ) .build() ) - assertThat(videoTransformationReadyWebhookEvent.request()) + assertThat(videoTransformationReadyEvent.request()) .isEqualTo( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) - assertThat(videoTransformationReadyWebhookEvent.timings()) + assertThat(videoTransformationReadyEvent.timings()) .contains( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -187,49 +179,49 @@ internal class VideoTransformationReadyWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationReadyWebhookEvent = - VideoTransformationReadyWebhookEvent.builder() + val videoTransformationReadyEvent = + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -237,12 +229,11 @@ internal class VideoTransformationReadyWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -258,27 +249,27 @@ internal class VideoTransformationReadyWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() ) .build() - val roundtrippedVideoTransformationReadyWebhookEvent = + val roundtrippedVideoTransformationReadyEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationReadyWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationReadyEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationReadyWebhookEvent) - .isEqualTo(videoTransformationReadyWebhookEvent) + assertThat(roundtrippedVideoTransformationReadyEvent) + .isEqualTo(videoTransformationReadyEvent) } } From 8c06d1e6bdf6e476e6e0320d7bc23adb50227bcd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 04:55:55 +0000 Subject: [PATCH 069/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index aa083b75..211c2820 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-e798e75f763868cfd2babe250a0d880a651b19f9e1b9a3b567d629eea9893147.yml openapi_spec_hash: 45341845beb1363b7dcb4050934b9cf0 -config_hash: 128de0925828937e2ae36770e7f6029a +config_hash: 62e43a8e96bb82f754e37a0e0c264f1e From e996c2d9b237f808d04871ee4bb61f89421781a7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 05:10:20 +0000 Subject: [PATCH 070/125] feat(api): manual updates --- .stats.yml | 6 +- .../api/models/files/FileUploadParams.kt | 2 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 73 ++++--- .../api/models/webhooks/UnwrapWebhookEvent.kt | 67 ++++--- ...ideoTransformationAcceptedWebhookEvent.kt} | 39 ++-- ...> VideoTransformationErrorWebhookEvent.kt} | 35 ++-- ...> VideoTransformationReadyWebhookEvent.kt} | 37 ++-- .../api/services/async/FileServiceAsync.kt | 4 +- .../api/services/blocking/FileService.kt | 4 +- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 182 ++++++++++-------- .../models/webhooks/UnwrapWebhookEventTest.kt | 182 ++++++++++-------- ...TransformationAcceptedWebhookEventTest.kt} | 102 +++++----- ...deoTransformationErrorWebhookEventTest.kt} | 109 ++++++----- ...deoTransformationReadyWebhookEventTest.kt} | 117 +++++------ 14 files changed, 539 insertions(+), 420 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationAcceptedEvent.kt => VideoTransformationAcceptedWebhookEvent.kt} (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationErrorEvent.kt => VideoTransformationErrorWebhookEvent.kt} (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationReadyEvent.kt => VideoTransformationReadyWebhookEvent.kt} (98%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationAcceptedEventTest.kt => VideoTransformationAcceptedWebhookEventTest.kt} (67%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationErrorEventTest.kt => VideoTransformationErrorWebhookEventTest.kt} (70%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationReadyEventTest.kt => VideoTransformationReadyWebhookEventTest.kt} (72%) diff --git a/.stats.yml b/.stats.yml index 211c2820..2ec886b7 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-e798e75f763868cfd2babe250a0d880a651b19f9e1b9a3b567d629eea9893147.yml -openapi_spec_hash: 45341845beb1363b7dcb4050934b9cf0 -config_hash: 62e43a8e96bb82f754e37a0e0c264f1e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-863564701f791fdf016f7321fce445de5e368c474b06b135aaac16214f4f6416.yml +openapi_spec_hash: e3bb05601081de07084edf79cf3a2d63 +config_hash: 4947aef92e0f986b21a473329de4a647 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 8127f2aa..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 @@ -40,7 +40,7 @@ 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 `expiration` from your secure backend using private API. + * 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. * 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 49d16f6d..3d9637ee 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 @@ -22,19 +22,19 @@ import java.util.Optional @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 videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent? = null, + private val videoTransformationReady: VideoTransformationReadyWebhookEvent? = null, + private val videoTransformationError: VideoTransformationErrorWebhookEvent? = null, private val _json: JsonValue? = null, ) { - fun videoTransformationAccepted(): Optional = + fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) - fun videoTransformationReady(): Optional = + fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) - fun videoTransformationError(): Optional = + fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -43,13 +43,13 @@ private constructor( fun isVideoTransformationError(): Boolean = videoTransformationError != null - fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = + fun asVideoTransformationAccepted(): VideoTransformationAcceptedWebhookEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") - fun asVideoTransformationReady(): VideoTransformationReadyEvent = + fun asVideoTransformationReady(): VideoTransformationReadyWebhookEvent = videoTransformationReady.getOrThrow("videoTransformationReady") - fun asVideoTransformationError(): VideoTransformationErrorEvent = + fun asVideoTransformationError(): VideoTransformationErrorWebhookEvent = videoTransformationError.getOrThrow("videoTransformationError") fun _json(): Optional = Optional.ofNullable(_json) @@ -75,19 +75,19 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedEvent + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent ) { videoTransformationAccepted.validate() } override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyEvent + videoTransformationReady: VideoTransformationReadyWebhookEvent ) { videoTransformationReady.validate() } override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorEvent + videoTransformationError: VideoTransformationErrorWebhookEvent ) { videoTransformationError.validate() } @@ -114,15 +114,15 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedEvent + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent ) = videoTransformationAccepted.validity() override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyEvent + videoTransformationReady: VideoTransformationReadyWebhookEvent ) = videoTransformationReady.validity() override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorEvent + videoTransformationError: VideoTransformationErrorWebhookEvent ) = videoTransformationError.validity() override fun unknown(json: JsonValue?) = 0 @@ -163,16 +163,18 @@ private constructor( @JvmStatic fun ofVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedEvent + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent ) = UnsafeUnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) @JvmStatic - fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = - UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + fun ofVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ) = UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) @JvmStatic - fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = - UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) + fun ofVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ) = UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) } /** @@ -182,15 +184,15 @@ private constructor( interface Visitor { fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedEvent + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent ): T fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyEvent + videoTransformationReady: VideoTransformationReadyWebhookEvent ): T fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorEvent + videoTransformationError: VideoTransformationErrorWebhookEvent ): T /** @@ -216,19 +218,30 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef()) + 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( + videoTransformationReady = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnsafeUnwrapWebhookEvent( + videoTransformationError = it, + _json = json, + ) + }, ) .filterNotNull() .allMaxBy { it.validity() } 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 14560566..20867724 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 @@ -22,19 +22,19 @@ import java.util.Optional @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 videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent? = null, + private val videoTransformationReady: VideoTransformationReadyWebhookEvent? = null, + private val videoTransformationError: VideoTransformationErrorWebhookEvent? = null, private val _json: JsonValue? = null, ) { - fun videoTransformationAccepted(): Optional = + fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) - fun videoTransformationReady(): Optional = + fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) - fun videoTransformationError(): Optional = + fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -43,13 +43,13 @@ private constructor( fun isVideoTransformationError(): Boolean = videoTransformationError != null - fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = + fun asVideoTransformationAccepted(): VideoTransformationAcceptedWebhookEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") - fun asVideoTransformationReady(): VideoTransformationReadyEvent = + fun asVideoTransformationReady(): VideoTransformationReadyWebhookEvent = videoTransformationReady.getOrThrow("videoTransformationReady") - fun asVideoTransformationError(): VideoTransformationErrorEvent = + fun asVideoTransformationError(): VideoTransformationErrorWebhookEvent = videoTransformationError.getOrThrow("videoTransformationError") fun _json(): Optional = Optional.ofNullable(_json) @@ -75,19 +75,19 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedEvent + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent ) { videoTransformationAccepted.validate() } override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyEvent + videoTransformationReady: VideoTransformationReadyWebhookEvent ) { videoTransformationReady.validate() } override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorEvent + videoTransformationError: VideoTransformationErrorWebhookEvent ) { videoTransformationError.validate() } @@ -114,15 +114,15 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedEvent + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent ) = videoTransformationAccepted.validity() override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyEvent + videoTransformationReady: VideoTransformationReadyWebhookEvent ) = videoTransformationReady.validity() override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorEvent + videoTransformationError: VideoTransformationErrorWebhookEvent ) = videoTransformationError.validity() override fun unknown(json: JsonValue?) = 0 @@ -163,16 +163,18 @@ private constructor( @JvmStatic fun ofVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedEvent + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent ) = UnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) @JvmStatic - fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = - UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + fun ofVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyWebhookEvent + ) = UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) @JvmStatic - fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = - UnwrapWebhookEvent(videoTransformationError = videoTransformationError) + fun ofVideoTransformationError( + videoTransformationError: VideoTransformationErrorWebhookEvent + ) = UnwrapWebhookEvent(videoTransformationError = videoTransformationError) } /** @@ -182,15 +184,15 @@ private constructor( interface Visitor { fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedEvent + videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent ): T fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyEvent + videoTransformationReady: VideoTransformationReadyWebhookEvent ): T fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorEvent + videoTransformationError: VideoTransformationErrorWebhookEvent ): T /** @@ -215,16 +217,21 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef()) + 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(videoTransformationReady = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnwrapWebhookEvent(videoTransformationError = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } 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/VideoTransformationAcceptedWebhookEvent.kt similarity index 98% 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/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt index 99f84cc8..60f51bed 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/VideoTransformationAcceptedWebhookEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationAcceptedEvent +class VideoTransformationAcceptedWebhookEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -125,7 +125,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationAcceptedEvent]. + * [VideoTransformationAcceptedWebhookEvent]. * * The following fields are required: * ```java @@ -138,7 +138,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationAcceptedEvent]. */ + /** A builder for [VideoTransformationAcceptedWebhookEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -149,16 +149,17 @@ private constructor( 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() - } + internal fun from( + videoTransformationAcceptedWebhookEvent: VideoTransformationAcceptedWebhookEvent + ) = apply { + id = videoTransformationAcceptedWebhookEvent.id + createdAt = videoTransformationAcceptedWebhookEvent.createdAt + data = videoTransformationAcceptedWebhookEvent.data + request = videoTransformationAcceptedWebhookEvent.request + type = videoTransformationAcceptedWebhookEvent.type + additionalProperties = + videoTransformationAcceptedWebhookEvent.additionalProperties.toMutableMap() + } /** Unique identifier for the event. */ fun id(id: String) = id(JsonField.of(id)) @@ -236,7 +237,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationAcceptedEvent]. + * Returns an immutable instance of [VideoTransformationAcceptedWebhookEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -250,8 +251,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationAcceptedEvent = - VideoTransformationAcceptedEvent( + fun build(): VideoTransformationAcceptedWebhookEvent = + VideoTransformationAcceptedWebhookEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -263,7 +264,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationAcceptedEvent = apply { + fun validate(): VideoTransformationAcceptedWebhookEvent = apply { if (validated) { return@apply } @@ -2210,7 +2211,7 @@ private constructor( return true } - return other is VideoTransformationAcceptedEvent && + return other is VideoTransformationAcceptedWebhookEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2226,5 +2227,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationAcceptedEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "VideoTransformationAcceptedWebhookEvent{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/VideoTransformationErrorWebhookEvent.kt similarity index 98% 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/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt index 009db96d..4e8911b5 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/VideoTransformationErrorWebhookEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationErrorEvent +class VideoTransformationErrorWebhookEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -125,7 +125,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationErrorEvent]. + * [VideoTransformationErrorWebhookEvent]. * * The following fields are required: * ```java @@ -138,7 +138,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationErrorEvent]. */ + /** A builder for [VideoTransformationErrorWebhookEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -149,13 +149,16 @@ private constructor( 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() + internal fun from( + videoTransformationErrorWebhookEvent: VideoTransformationErrorWebhookEvent + ) = apply { + id = videoTransformationErrorWebhookEvent.id + createdAt = videoTransformationErrorWebhookEvent.createdAt + data = videoTransformationErrorWebhookEvent.data + request = videoTransformationErrorWebhookEvent.request + type = videoTransformationErrorWebhookEvent.type + additionalProperties = + videoTransformationErrorWebhookEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -234,7 +237,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationErrorEvent]. + * Returns an immutable instance of [VideoTransformationErrorWebhookEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -248,8 +251,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationErrorEvent = - VideoTransformationErrorEvent( + fun build(): VideoTransformationErrorWebhookEvent = + VideoTransformationErrorWebhookEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -261,7 +264,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationErrorEvent = apply { + fun validate(): VideoTransformationErrorWebhookEvent = apply { if (validated) { return@apply } @@ -2542,7 +2545,7 @@ private constructor( return true } - return other is VideoTransformationErrorEvent && + return other is VideoTransformationErrorWebhookEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2558,5 +2561,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationErrorEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "VideoTransformationErrorWebhookEvent{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/VideoTransformationReadyWebhookEvent.kt similarity index 98% 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/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt index 49d51e5b..3a99ebb5 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/VideoTransformationReadyWebhookEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationReadyEvent +class VideoTransformationReadyWebhookEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -140,7 +140,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationReadyEvent]. + * [VideoTransformationReadyWebhookEvent]. * * The following fields are required: * ```java @@ -153,7 +153,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationReadyEvent]. */ + /** A builder for [VideoTransformationReadyWebhookEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -165,14 +165,17 @@ private constructor( 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() + internal fun from( + videoTransformationReadyWebhookEvent: VideoTransformationReadyWebhookEvent + ) = apply { + id = videoTransformationReadyWebhookEvent.id + createdAt = videoTransformationReadyWebhookEvent.createdAt + data = videoTransformationReadyWebhookEvent.data + request = videoTransformationReadyWebhookEvent.request + type = videoTransformationReadyWebhookEvent.type + timings = videoTransformationReadyWebhookEvent.timings + additionalProperties = + videoTransformationReadyWebhookEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -261,7 +264,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationReadyEvent]. + * Returns an immutable instance of [VideoTransformationReadyWebhookEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -275,8 +278,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationReadyEvent = - VideoTransformationReadyEvent( + fun build(): VideoTransformationReadyWebhookEvent = + VideoTransformationReadyWebhookEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -289,7 +292,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationReadyEvent = apply { + fun validate(): VideoTransformationReadyWebhookEvent = apply { if (validated) { return@apply } @@ -2959,7 +2962,7 @@ private constructor( return true } - return other is VideoTransformationReadyEvent && + return other is VideoTransformationReadyWebhookEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2976,5 +2979,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationReadyEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, timings=$timings, additionalProperties=$additionalProperties}" + "VideoTransformationReadyWebhookEvent{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/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index 3695f29f..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 @@ -199,8 +199,8 @@ interface FileServiceAsync { /** * 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 `expiration` from your secure backend using - * private API. + * 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. * 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 0aba8894..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 @@ -181,8 +181,8 @@ interface FileService { /** * 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 `expiration` from your secure backend using - * private API. + * 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. * 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 dfd0c0e4..4c4d677d 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 @@ -18,48 +18,53 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationAccepted() { val videoTransformationAccepted = - VideoTransformationAcceptedEvent.builder() + VideoTransformationAcceptedWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedEvent.Data.builder() + VideoTransformationAcceptedWebhookEvent.Data.builder() .asset( - VideoTransformationAcceptedEvent.Data.Asset.builder() + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedEvent.Data.Transformation.builder() + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedEvent.Data.Transformation.Type + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -71,7 +76,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedEvent.Request.builder() + VideoTransformationAcceptedWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -93,48 +98,55 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationAccepted( - VideoTransformationAcceptedEvent.builder() + VideoTransformationAcceptedWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedEvent.Data.builder() + VideoTransformationAcceptedWebhookEvent.Data.builder() .asset( - VideoTransformationAcceptedEvent.Data.Asset.builder() + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedEvent.Data.Transformation.builder() + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .builder() .type( - VideoTransformationAcceptedEvent.Data.Transformation.Type + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -146,7 +158,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedEvent.Request.builder() + VideoTransformationAcceptedWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -167,48 +179,48 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationReady() { val videoTransformationReady = - VideoTransformationReadyEvent.builder() + VideoTransformationReadyWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyEvent.Data.builder() + VideoTransformationReadyWebhookEvent.Data.builder() .asset( - VideoTransformationReadyEvent.Data.Asset.builder() + VideoTransformationReadyWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyEvent.Data.Transformation.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationReadyEvent.Data.Transformation.Type + VideoTransformationReadyWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .VideoCodec .H264 @@ -216,11 +228,12 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output .VideoMetadata .builder() .bitrate(0L) @@ -236,14 +249,14 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyEvent.Request.builder() + VideoTransformationReadyWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyEvent.Timings.builder() + VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -264,48 +277,54 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationReady( - VideoTransformationReadyEvent.builder() + VideoTransformationReadyWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyEvent.Data.builder() + VideoTransformationReadyWebhookEvent.Data.builder() .asset( - VideoTransformationReadyEvent.Data.Asset.builder() + VideoTransformationReadyWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyEvent.Data.Transformation.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationReadyEvent.Data.Transformation.Type + VideoTransformationReadyWebhookEvent.Data.Transformation + .Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -313,11 +332,13 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Output .VideoMetadata .builder() @@ -334,14 +355,14 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyEvent.Request.builder() + VideoTransformationReadyWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyEvent.Timings.builder() + VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -361,58 +382,59 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationError() { val videoTransformationError = - VideoTransformationErrorEvent.builder() + VideoTransformationErrorWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorEvent.Data.builder() + VideoTransformationErrorWebhookEvent.Data.builder() .asset( - VideoTransformationErrorEvent.Data.Asset.builder() + VideoTransformationErrorWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorEvent.Data.Transformation.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationErrorEvent.Data.Transformation.Type + VideoTransformationErrorWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .VideoCodec .H264 @@ -424,7 +446,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorEvent.Request.builder() + VideoTransformationErrorWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -446,27 +468,30 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationError( - VideoTransformationErrorEvent.builder() + VideoTransformationErrorWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorEvent.Data.builder() + VideoTransformationErrorWebhookEvent.Data.builder() .asset( - VideoTransformationErrorEvent.Data.Asset.builder() + VideoTransformationErrorWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorEvent.Data.Transformation.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationErrorEvent.Data.Transformation.Type + VideoTransformationErrorWebhookEvent.Data.Transformation + .Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error .builder() .reason( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Error .Reason .ENCODING_FAILED @@ -474,31 +499,36 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .options( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -510,7 +540,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorEvent.Request.builder() + VideoTransformationErrorWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") 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 1af001c6..4b31cdb6 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 @@ -18,48 +18,53 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationAccepted() { val videoTransformationAccepted = - VideoTransformationAcceptedEvent.builder() + VideoTransformationAcceptedWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedEvent.Data.builder() + VideoTransformationAcceptedWebhookEvent.Data.builder() .asset( - VideoTransformationAcceptedEvent.Data.Asset.builder() + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedEvent.Data.Transformation.builder() + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedEvent.Data.Transformation.Type + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -71,7 +76,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedEvent.Request.builder() + VideoTransformationAcceptedWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -93,48 +98,55 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationAccepted( - VideoTransformationAcceptedEvent.builder() + VideoTransformationAcceptedWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedEvent.Data.builder() + VideoTransformationAcceptedWebhookEvent.Data.builder() .asset( - VideoTransformationAcceptedEvent.Data.Asset.builder() + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedEvent.Data.Transformation.builder() + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .builder() .type( - VideoTransformationAcceptedEvent.Data.Transformation.Type + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -146,7 +158,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedEvent.Request.builder() + VideoTransformationAcceptedWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -167,48 +179,48 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationReady() { val videoTransformationReady = - VideoTransformationReadyEvent.builder() + VideoTransformationReadyWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyEvent.Data.builder() + VideoTransformationReadyWebhookEvent.Data.builder() .asset( - VideoTransformationReadyEvent.Data.Asset.builder() + VideoTransformationReadyWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyEvent.Data.Transformation.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationReadyEvent.Data.Transformation.Type + VideoTransformationReadyWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .VideoCodec .H264 @@ -216,11 +228,12 @@ internal class UnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output .VideoMetadata .builder() .bitrate(0L) @@ -236,14 +249,14 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyEvent.Request.builder() + VideoTransformationReadyWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyEvent.Timings.builder() + VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -263,48 +276,54 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationReady( - VideoTransformationReadyEvent.builder() + VideoTransformationReadyWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyEvent.Data.builder() + VideoTransformationReadyWebhookEvent.Data.builder() .asset( - VideoTransformationReadyEvent.Data.Asset.builder() + VideoTransformationReadyWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyEvent.Data.Transformation.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationReadyEvent.Data.Transformation.Type + VideoTransformationReadyWebhookEvent.Data.Transformation + .Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -312,11 +331,13 @@ internal class UnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data + .Transformation .Output .VideoMetadata .builder() @@ -333,14 +354,14 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyEvent.Request.builder() + VideoTransformationReadyWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyEvent.Timings.builder() + VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -360,58 +381,59 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationError() { val videoTransformationError = - VideoTransformationErrorEvent.builder() + VideoTransformationErrorWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorEvent.Data.builder() + VideoTransformationErrorWebhookEvent.Data.builder() .asset( - VideoTransformationErrorEvent.Data.Asset.builder() + VideoTransformationErrorWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorEvent.Data.Transformation.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationErrorEvent.Data.Transformation.Type + VideoTransformationErrorWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .VideoCodec .H264 @@ -423,7 +445,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorEvent.Request.builder() + VideoTransformationErrorWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -444,27 +466,30 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationError( - VideoTransformationErrorEvent.builder() + VideoTransformationErrorWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorEvent.Data.builder() + VideoTransformationErrorWebhookEvent.Data.builder() .asset( - VideoTransformationErrorEvent.Data.Asset.builder() + VideoTransformationErrorWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorEvent.Data.Transformation.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationErrorEvent.Data.Transformation.Type + VideoTransformationErrorWebhookEvent.Data.Transformation + .Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error .builder() .reason( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Error .Reason .ENCODING_FAILED @@ -472,31 +497,36 @@ internal class UnwrapWebhookEventTest { .build() ) .options( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -508,7 +538,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorEvent.Request.builder() + VideoTransformationErrorWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") 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/VideoTransformationAcceptedWebhookEventTest.kt similarity index 67% 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/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt index e3c95329..bc1840af 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/VideoTransformationAcceptedWebhookEventTest.kt @@ -8,53 +8,58 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationAcceptedEventTest { +internal class VideoTransformationAcceptedWebhookEventTest { @Test fun create() { - val videoTransformationAcceptedEvent = - VideoTransformationAcceptedEvent.builder() + val videoTransformationAcceptedWebhookEvent = + VideoTransformationAcceptedWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedEvent.Data.builder() + VideoTransformationAcceptedWebhookEvent.Data.builder() .asset( - VideoTransformationAcceptedEvent.Data.Asset.builder() + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedEvent.Data.Transformation.builder() + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedEvent.Data.Transformation.Type + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -66,7 +71,7 @@ internal class VideoTransformationAcceptedEventTest { .build() ) .request( - VideoTransformationAcceptedEvent.Request.builder() + VideoTransformationAcceptedWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -74,46 +79,50 @@ internal class VideoTransformationAcceptedEventTest { ) .build() - assertThat(videoTransformationAcceptedEvent.id()).isEqualTo("id") - assertThat(videoTransformationAcceptedEvent.createdAt()) + assertThat(videoTransformationAcceptedWebhookEvent.id()).isEqualTo("id") + assertThat(videoTransformationAcceptedWebhookEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationAcceptedEvent.data()) + assertThat(videoTransformationAcceptedWebhookEvent.data()) .isEqualTo( - VideoTransformationAcceptedEvent.Data.builder() + VideoTransformationAcceptedWebhookEvent.Data.builder() .asset( - VideoTransformationAcceptedEvent.Data.Asset.builder() + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedEvent.Data.Transformation.builder() + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedEvent.Data.Transformation.Type + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .VideoCodec .H264 ) @@ -123,9 +132,9 @@ internal class VideoTransformationAcceptedEventTest { ) .build() ) - assertThat(videoTransformationAcceptedEvent.request()) + assertThat(videoTransformationAcceptedWebhookEvent.request()) .isEqualTo( - VideoTransformationAcceptedEvent.Request.builder() + VideoTransformationAcceptedWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -136,49 +145,54 @@ internal class VideoTransformationAcceptedEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationAcceptedEvent = - VideoTransformationAcceptedEvent.builder() + val videoTransformationAcceptedWebhookEvent = + VideoTransformationAcceptedWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedEvent.Data.builder() + VideoTransformationAcceptedWebhookEvent.Data.builder() .asset( - VideoTransformationAcceptedEvent.Data.Asset.builder() + VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedEvent.Data.Transformation.builder() + VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedEvent.Data.Transformation.Type + VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedEvent.Data.Transformation.Options + VideoTransformationAcceptedWebhookEvent.Data.Transformation + .Options .builder() .audioCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedEvent.Data.Transformation + VideoTransformationAcceptedWebhookEvent.Data + .Transformation .Options .VideoCodec .H264 @@ -190,7 +204,7 @@ internal class VideoTransformationAcceptedEventTest { .build() ) .request( - VideoTransformationAcceptedEvent.Request.builder() + VideoTransformationAcceptedWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -198,13 +212,13 @@ internal class VideoTransformationAcceptedEventTest { ) .build() - val roundtrippedVideoTransformationAcceptedEvent = + val roundtrippedVideoTransformationAcceptedWebhookEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationAcceptedEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationAcceptedWebhookEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationAcceptedEvent) - .isEqualTo(videoTransformationAcceptedEvent) + assertThat(roundtrippedVideoTransformationAcceptedWebhookEvent) + .isEqualTo(videoTransformationAcceptedWebhookEvent) } } 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/VideoTransformationErrorWebhookEventTest.kt similarity index 70% 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/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt index 4d2b3f63..5cf7bfe7 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/VideoTransformationErrorWebhookEventTest.kt @@ -8,63 +8,64 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationErrorEventTest { +internal class VideoTransformationErrorWebhookEventTest { @Test fun create() { - val videoTransformationErrorEvent = - VideoTransformationErrorEvent.builder() + val videoTransformationErrorWebhookEvent = + VideoTransformationErrorWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorEvent.Data.builder() + VideoTransformationErrorWebhookEvent.Data.builder() .asset( - VideoTransformationErrorEvent.Data.Asset.builder() + VideoTransformationErrorWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorEvent.Data.Transformation.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationErrorEvent.Data.Transformation.Type + VideoTransformationErrorWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .VideoCodec .H264 @@ -76,7 +77,7 @@ internal class VideoTransformationErrorEventTest { .build() ) .request( - VideoTransformationErrorEvent.Request.builder() + VideoTransformationErrorWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -84,54 +85,61 @@ internal class VideoTransformationErrorEventTest { ) .build() - assertThat(videoTransformationErrorEvent.id()).isEqualTo("id") - assertThat(videoTransformationErrorEvent.createdAt()) + assertThat(videoTransformationErrorWebhookEvent.id()).isEqualTo("id") + assertThat(videoTransformationErrorWebhookEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationErrorEvent.data()) + assertThat(videoTransformationErrorWebhookEvent.data()) .isEqualTo( - VideoTransformationErrorEvent.Data.builder() + VideoTransformationErrorWebhookEvent.Data.builder() .asset( - VideoTransformationErrorEvent.Data.Asset.builder() + VideoTransformationErrorWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorEvent.Data.Transformation.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationErrorEvent.Data.Transformation.Type + VideoTransformationErrorWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorEvent.Data.Transformation.Error.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.Error + .builder() .reason( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorEvent.Data.Transformation.Options.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.Options + .builder() .audioCodec( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation + .Options .VideoCodec .H264 ) @@ -141,9 +149,9 @@ internal class VideoTransformationErrorEventTest { ) .build() ) - assertThat(videoTransformationErrorEvent.request()) + assertThat(videoTransformationErrorWebhookEvent.request()) .isEqualTo( - VideoTransformationErrorEvent.Request.builder() + VideoTransformationErrorWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -154,59 +162,60 @@ internal class VideoTransformationErrorEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationErrorEvent = - VideoTransformationErrorEvent.builder() + val videoTransformationErrorWebhookEvent = + VideoTransformationErrorWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorEvent.Data.builder() + VideoTransformationErrorWebhookEvent.Data.builder() .asset( - VideoTransformationErrorEvent.Data.Asset.builder() + VideoTransformationErrorWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorEvent.Data.Transformation.builder() + VideoTransformationErrorWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationErrorEvent.Data.Transformation.Type + VideoTransformationErrorWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorEvent.Data.Transformation.Error + VideoTransformationErrorWebhookEvent.Data.Transformation + .Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorEvent.Data.Transformation.Options + VideoTransformationErrorWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorEvent.Data.Transformation + VideoTransformationErrorWebhookEvent.Data.Transformation .Options .VideoCodec .H264 @@ -218,7 +227,7 @@ internal class VideoTransformationErrorEventTest { .build() ) .request( - VideoTransformationErrorEvent.Request.builder() + VideoTransformationErrorWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -226,13 +235,13 @@ internal class VideoTransformationErrorEventTest { ) .build() - val roundtrippedVideoTransformationErrorEvent = + val roundtrippedVideoTransformationErrorWebhookEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationErrorEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationErrorWebhookEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationErrorEvent) - .isEqualTo(videoTransformationErrorEvent) + assertThat(roundtrippedVideoTransformationErrorWebhookEvent) + .isEqualTo(videoTransformationErrorWebhookEvent) } } 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/VideoTransformationReadyWebhookEventTest.kt similarity index 72% 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/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt index 2c9c0127..c9ad1646 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/VideoTransformationReadyWebhookEventTest.kt @@ -8,53 +8,53 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationReadyEventTest { +internal class VideoTransformationReadyWebhookEventTest { @Test fun create() { - val videoTransformationReadyEvent = - VideoTransformationReadyEvent.builder() + val videoTransformationReadyWebhookEvent = + VideoTransformationReadyWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyEvent.Data.builder() + VideoTransformationReadyWebhookEvent.Data.builder() .asset( - VideoTransformationReadyEvent.Data.Asset.builder() + VideoTransformationReadyWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyEvent.Data.Transformation.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationReadyEvent.Data.Transformation.Type + VideoTransformationReadyWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .VideoCodec .H264 @@ -62,11 +62,12 @@ internal class VideoTransformationReadyEventTest { .build() ) .output( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output .VideoMetadata .builder() .bitrate(0L) @@ -82,69 +83,76 @@ internal class VideoTransformationReadyEventTest { .build() ) .request( - VideoTransformationReadyEvent.Request.builder() + VideoTransformationReadyWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyEvent.Timings.builder() + VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() ) .build() - assertThat(videoTransformationReadyEvent.id()).isEqualTo("id") - assertThat(videoTransformationReadyEvent.createdAt()) + assertThat(videoTransformationReadyWebhookEvent.id()).isEqualTo("id") + assertThat(videoTransformationReadyWebhookEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationReadyEvent.data()) + assertThat(videoTransformationReadyWebhookEvent.data()) .isEqualTo( - VideoTransformationReadyEvent.Data.builder() + VideoTransformationReadyWebhookEvent.Data.builder() .asset( - VideoTransformationReadyEvent.Data.Asset.builder() + VideoTransformationReadyWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyEvent.Data.Transformation.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationReadyEvent.Data.Transformation.Type + VideoTransformationReadyWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyEvent.Data.Transformation.Options.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.Options + .builder() .audioCodec( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation + .Options .VideoCodec .H264 ) .build() ) .output( - VideoTransformationReadyEvent.Data.Transformation.Output.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.Output + .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output .VideoMetadata .builder() .bitrate(0L) @@ -159,17 +167,17 @@ internal class VideoTransformationReadyEventTest { ) .build() ) - assertThat(videoTransformationReadyEvent.request()) + assertThat(videoTransformationReadyWebhookEvent.request()) .isEqualTo( - VideoTransformationReadyEvent.Request.builder() + VideoTransformationReadyWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) - assertThat(videoTransformationReadyEvent.timings()) + assertThat(videoTransformationReadyWebhookEvent.timings()) .contains( - VideoTransformationReadyEvent.Timings.builder() + VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -179,49 +187,49 @@ internal class VideoTransformationReadyEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationReadyEvent = - VideoTransformationReadyEvent.builder() + val videoTransformationReadyWebhookEvent = + VideoTransformationReadyWebhookEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyEvent.Data.builder() + VideoTransformationReadyWebhookEvent.Data.builder() .asset( - VideoTransformationReadyEvent.Data.Asset.builder() + VideoTransformationReadyWebhookEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyEvent.Data.Transformation.builder() + VideoTransformationReadyWebhookEvent.Data.Transformation.builder() .type( - VideoTransformationReadyEvent.Data.Transformation.Type + VideoTransformationReadyWebhookEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyEvent.Data.Transformation.Options + VideoTransformationReadyWebhookEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyEvent.Data.Transformation + VideoTransformationReadyWebhookEvent.Data.Transformation .Options .VideoCodec .H264 @@ -229,11 +237,12 @@ internal class VideoTransformationReadyEventTest { .build() ) .output( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyEvent.Data.Transformation.Output + VideoTransformationReadyWebhookEvent.Data.Transformation + .Output .VideoMetadata .builder() .bitrate(0L) @@ -249,27 +258,27 @@ internal class VideoTransformationReadyEventTest { .build() ) .request( - VideoTransformationReadyEvent.Request.builder() + VideoTransformationReadyWebhookEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyEvent.Timings.builder() + VideoTransformationReadyWebhookEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() ) .build() - val roundtrippedVideoTransformationReadyEvent = + val roundtrippedVideoTransformationReadyWebhookEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationReadyEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationReadyWebhookEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationReadyEvent) - .isEqualTo(videoTransformationReadyEvent) + assertThat(roundtrippedVideoTransformationReadyWebhookEvent) + .isEqualTo(videoTransformationReadyWebhookEvent) } } From 434e0e2a8c5e3157ede29ecb1aff5f55cf3b723c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 05:12:41 +0000 Subject: [PATCH 071/125] feat(api): manual updates --- .stats.yml | 2 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 73 +++---- .../api/models/webhooks/UnwrapWebhookEvent.kt | 67 +++---- ...kt => VideoTransformationAcceptedEvent.kt} | 39 ++-- ...nt.kt => VideoTransformationErrorEvent.kt} | 35 ++-- ...nt.kt => VideoTransformationReadyEvent.kt} | 37 ++-- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 182 ++++++++---------- .../models/webhooks/UnwrapWebhookEventTest.kt | 182 ++++++++---------- ...> VideoTransformationAcceptedEventTest.kt} | 102 +++++----- ...t => VideoTransformationErrorEventTest.kt} | 109 +++++------ ...t => VideoTransformationReadyEventTest.kt} | 117 ++++++----- 11 files changed, 413 insertions(+), 532 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationAcceptedWebhookEvent.kt => VideoTransformationAcceptedEvent.kt} (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationErrorWebhookEvent.kt => VideoTransformationErrorEvent.kt} (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationReadyWebhookEvent.kt => VideoTransformationReadyEvent.kt} (98%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationAcceptedWebhookEventTest.kt => VideoTransformationAcceptedEventTest.kt} (67%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationErrorWebhookEventTest.kt => VideoTransformationErrorEventTest.kt} (70%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{VideoTransformationReadyWebhookEventTest.kt => VideoTransformationReadyEventTest.kt} (72%) diff --git a/.stats.yml b/.stats.yml index 2ec886b7..f8ab83a1 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-863564701f791fdf016f7321fce445de5e368c474b06b135aaac16214f4f6416.yml openapi_spec_hash: e3bb05601081de07084edf79cf3a2d63 -config_hash: 4947aef92e0f986b21a473329de4a647 +config_hash: d6fc50026fa9ef4b444d43c07c2c70a6 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 3d9637ee..49d16f6d 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 @@ -22,19 +22,19 @@ import java.util.Optional @JsonSerialize(using = UnsafeUnwrapWebhookEvent.Serializer::class) class UnsafeUnwrapWebhookEvent private constructor( - private val videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent? = null, - private val videoTransformationReady: VideoTransformationReadyWebhookEvent? = null, - private val videoTransformationError: VideoTransformationErrorWebhookEvent? = null, + private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, + private val videoTransformationReady: VideoTransformationReadyEvent? = null, + private val videoTransformationError: VideoTransformationErrorEvent? = null, private val _json: JsonValue? = null, ) { - fun videoTransformationAccepted(): Optional = + fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) - fun videoTransformationReady(): Optional = + fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) - fun videoTransformationError(): Optional = + fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -43,13 +43,13 @@ private constructor( fun isVideoTransformationError(): Boolean = videoTransformationError != null - fun asVideoTransformationAccepted(): VideoTransformationAcceptedWebhookEvent = + fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") - fun asVideoTransformationReady(): VideoTransformationReadyWebhookEvent = + fun asVideoTransformationReady(): VideoTransformationReadyEvent = videoTransformationReady.getOrThrow("videoTransformationReady") - fun asVideoTransformationError(): VideoTransformationErrorWebhookEvent = + fun asVideoTransformationError(): VideoTransformationErrorEvent = videoTransformationError.getOrThrow("videoTransformationError") fun _json(): Optional = Optional.ofNullable(_json) @@ -75,19 +75,19 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) { videoTransformationAccepted.validate() } override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ) { videoTransformationReady.validate() } override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ) { videoTransformationError.validate() } @@ -114,15 +114,15 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) = videoTransformationAccepted.validity() override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ) = videoTransformationReady.validity() override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ) = videoTransformationError.validity() override fun unknown(json: JsonValue?) = 0 @@ -163,18 +163,16 @@ private constructor( @JvmStatic fun ofVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) = UnsafeUnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) @JvmStatic - fun ofVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent - ) = UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = + UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) @JvmStatic - fun ofVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent - ) = UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) + fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = + UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) } /** @@ -184,15 +182,15 @@ private constructor( interface Visitor { fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ): T fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ): T fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ): T /** @@ -218,30 +216,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) + 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(videoTransformationReady = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(videoTransformationError = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } 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 20867724..14560566 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 @@ -22,19 +22,19 @@ import java.util.Optional @JsonSerialize(using = UnwrapWebhookEvent.Serializer::class) class UnwrapWebhookEvent private constructor( - private val videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent? = null, - private val videoTransformationReady: VideoTransformationReadyWebhookEvent? = null, - private val videoTransformationError: VideoTransformationErrorWebhookEvent? = null, + private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, + private val videoTransformationReady: VideoTransformationReadyEvent? = null, + private val videoTransformationError: VideoTransformationErrorEvent? = null, private val _json: JsonValue? = null, ) { - fun videoTransformationAccepted(): Optional = + fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) - fun videoTransformationReady(): Optional = + fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) - fun videoTransformationError(): Optional = + fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -43,13 +43,13 @@ private constructor( fun isVideoTransformationError(): Boolean = videoTransformationError != null - fun asVideoTransformationAccepted(): VideoTransformationAcceptedWebhookEvent = + fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") - fun asVideoTransformationReady(): VideoTransformationReadyWebhookEvent = + fun asVideoTransformationReady(): VideoTransformationReadyEvent = videoTransformationReady.getOrThrow("videoTransformationReady") - fun asVideoTransformationError(): VideoTransformationErrorWebhookEvent = + fun asVideoTransformationError(): VideoTransformationErrorEvent = videoTransformationError.getOrThrow("videoTransformationError") fun _json(): Optional = Optional.ofNullable(_json) @@ -75,19 +75,19 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) { videoTransformationAccepted.validate() } override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ) { videoTransformationReady.validate() } override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ) { videoTransformationError.validate() } @@ -114,15 +114,15 @@ private constructor( accept( object : Visitor { override fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) = videoTransformationAccepted.validity() override fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ) = videoTransformationReady.validity() override fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ) = videoTransformationError.validity() override fun unknown(json: JsonValue?) = 0 @@ -163,18 +163,16 @@ private constructor( @JvmStatic fun ofVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ) = UnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) @JvmStatic - fun ofVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent - ) = UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = + UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) @JvmStatic - fun ofVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent - ) = UnwrapWebhookEvent(videoTransformationError = videoTransformationError) + fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = + UnwrapWebhookEvent(videoTransformationError = videoTransformationError) } /** @@ -184,15 +182,15 @@ private constructor( interface Visitor { fun visitVideoTransformationAccepted( - videoTransformationAccepted: VideoTransformationAcceptedWebhookEvent + videoTransformationAccepted: VideoTransformationAcceptedEvent ): T fun visitVideoTransformationReady( - videoTransformationReady: VideoTransformationReadyWebhookEvent + videoTransformationReady: VideoTransformationReadyEvent ): T fun visitVideoTransformationError( - videoTransformationError: VideoTransformationErrorWebhookEvent + videoTransformationError: VideoTransformationErrorEvent ): T /** @@ -217,21 +215,16 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) + 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(videoTransformationReady = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(videoTransformationError = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt index 60f51bed..99f84cc8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationAcceptedWebhookEvent +class VideoTransformationAcceptedEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -125,7 +125,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationAcceptedWebhookEvent]. + * [VideoTransformationAcceptedEvent]. * * The following fields are required: * ```java @@ -138,7 +138,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationAcceptedWebhookEvent]. */ + /** A builder for [VideoTransformationAcceptedEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -149,17 +149,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - videoTransformationAcceptedWebhookEvent: VideoTransformationAcceptedWebhookEvent - ) = apply { - id = videoTransformationAcceptedWebhookEvent.id - createdAt = videoTransformationAcceptedWebhookEvent.createdAt - data = videoTransformationAcceptedWebhookEvent.data - request = videoTransformationAcceptedWebhookEvent.request - type = videoTransformationAcceptedWebhookEvent.type - additionalProperties = - videoTransformationAcceptedWebhookEvent.additionalProperties.toMutableMap() - } + 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)) @@ -237,7 +236,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationAcceptedWebhookEvent]. + * Returns an immutable instance of [VideoTransformationAcceptedEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -251,8 +250,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationAcceptedWebhookEvent = - VideoTransformationAcceptedWebhookEvent( + fun build(): VideoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -264,7 +263,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationAcceptedWebhookEvent = apply { + fun validate(): VideoTransformationAcceptedEvent = apply { if (validated) { return@apply } @@ -2211,7 +2210,7 @@ private constructor( return true } - return other is VideoTransformationAcceptedWebhookEvent && + return other is VideoTransformationAcceptedEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2227,5 +2226,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationAcceptedWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "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/VideoTransformationErrorWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt index 4e8911b5..009db96d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationErrorWebhookEvent +class VideoTransformationErrorEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -125,7 +125,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationErrorWebhookEvent]. + * [VideoTransformationErrorEvent]. * * The following fields are required: * ```java @@ -138,7 +138,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationErrorWebhookEvent]. */ + /** A builder for [VideoTransformationErrorEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -149,16 +149,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - videoTransformationErrorWebhookEvent: VideoTransformationErrorWebhookEvent - ) = apply { - id = videoTransformationErrorWebhookEvent.id - createdAt = videoTransformationErrorWebhookEvent.createdAt - data = videoTransformationErrorWebhookEvent.data - request = videoTransformationErrorWebhookEvent.request - type = videoTransformationErrorWebhookEvent.type - additionalProperties = - videoTransformationErrorWebhookEvent.additionalProperties.toMutableMap() + 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. */ @@ -237,7 +234,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationErrorWebhookEvent]. + * Returns an immutable instance of [VideoTransformationErrorEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -251,8 +248,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationErrorWebhookEvent = - VideoTransformationErrorWebhookEvent( + fun build(): VideoTransformationErrorEvent = + VideoTransformationErrorEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -264,7 +261,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationErrorWebhookEvent = apply { + fun validate(): VideoTransformationErrorEvent = apply { if (validated) { return@apply } @@ -2545,7 +2542,7 @@ private constructor( return true } - return other is VideoTransformationErrorWebhookEvent && + return other is VideoTransformationErrorEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2561,5 +2558,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationErrorWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "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/VideoTransformationReadyWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt index 3a99ebb5..49d51e5b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class VideoTransformationReadyWebhookEvent +class VideoTransformationReadyEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -140,7 +140,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [VideoTransformationReadyWebhookEvent]. + * [VideoTransformationReadyEvent]. * * The following fields are required: * ```java @@ -153,7 +153,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VideoTransformationReadyWebhookEvent]. */ + /** A builder for [VideoTransformationReadyEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -165,17 +165,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - videoTransformationReadyWebhookEvent: VideoTransformationReadyWebhookEvent - ) = apply { - id = videoTransformationReadyWebhookEvent.id - createdAt = videoTransformationReadyWebhookEvent.createdAt - data = videoTransformationReadyWebhookEvent.data - request = videoTransformationReadyWebhookEvent.request - type = videoTransformationReadyWebhookEvent.type - timings = videoTransformationReadyWebhookEvent.timings - additionalProperties = - videoTransformationReadyWebhookEvent.additionalProperties.toMutableMap() + 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. */ @@ -264,7 +261,7 @@ private constructor( } /** - * Returns an immutable instance of [VideoTransformationReadyWebhookEvent]. + * Returns an immutable instance of [VideoTransformationReadyEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -278,8 +275,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VideoTransformationReadyWebhookEvent = - VideoTransformationReadyWebhookEvent( + fun build(): VideoTransformationReadyEvent = + VideoTransformationReadyEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -292,7 +289,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VideoTransformationReadyWebhookEvent = apply { + fun validate(): VideoTransformationReadyEvent = apply { if (validated) { return@apply } @@ -2962,7 +2959,7 @@ private constructor( return true } - return other is VideoTransformationReadyWebhookEvent && + return other is VideoTransformationReadyEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -2979,5 +2976,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationReadyWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, timings=$timings, additionalProperties=$additionalProperties}" + "VideoTransformationReadyEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, timings=$timings, additionalProperties=$additionalProperties}" } 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 4c4d677d..dfd0c0e4 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 @@ -18,53 +18,48 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationAccepted() { val videoTransformationAccepted = - VideoTransformationAcceptedWebhookEvent.builder() + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -76,7 +71,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -98,55 +93,48 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationAccepted( - VideoTransformationAcceptedWebhookEvent.builder() + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -158,7 +146,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -179,48 +167,48 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationReady() { val videoTransformationReady = - VideoTransformationReadyWebhookEvent.builder() + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -228,12 +216,11 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -249,14 +236,14 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -277,54 +264,48 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationReady( - VideoTransformationReadyWebhookEvent.builder() + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -332,13 +313,11 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Output .VideoMetadata .builder() @@ -355,14 +334,14 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -382,59 +361,58 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofVideoTransformationError() { val videoTransformationError = - VideoTransformationErrorWebhookEvent.builder() + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -446,7 +424,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -468,30 +446,27 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofVideoTransformationError( - VideoTransformationErrorWebhookEvent.builder() + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Error .Reason .ENCODING_FAILED @@ -499,36 +474,31 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -540,7 +510,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") 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 4b31cdb6..1af001c6 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 @@ -18,53 +18,48 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationAccepted() { val videoTransformationAccepted = - VideoTransformationAcceptedWebhookEvent.builder() + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -76,7 +71,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -98,55 +93,48 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationAccepted( - VideoTransformationAcceptedWebhookEvent.builder() + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -158,7 +146,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -179,48 +167,48 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationReady() { val videoTransformationReady = - VideoTransformationReadyWebhookEvent.builder() + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -228,12 +216,11 @@ internal class UnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -249,14 +236,14 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -276,54 +263,48 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationReady( - VideoTransformationReadyWebhookEvent.builder() + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -331,13 +312,11 @@ internal class UnwrapWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data - .Transformation + VideoTransformationReadyEvent.Data.Transformation .Output .VideoMetadata .builder() @@ -354,14 +333,14 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -381,59 +360,58 @@ internal class UnwrapWebhookEventTest { @Test fun ofVideoTransformationError() { val videoTransformationError = - VideoTransformationErrorWebhookEvent.builder() + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -445,7 +423,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -466,30 +444,27 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofVideoTransformationError( - VideoTransformationErrorWebhookEvent.builder() + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Error .Reason .ENCODING_FAILED @@ -497,36 +472,31 @@ internal class UnwrapWebhookEventTest { .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data - .Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -538,7 +508,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt similarity index 67% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt index bc1840af..e3c95329 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt @@ -8,58 +8,53 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationAcceptedWebhookEventTest { +internal class VideoTransformationAcceptedEventTest { @Test fun create() { - val videoTransformationAcceptedWebhookEvent = - VideoTransformationAcceptedWebhookEvent.builder() + val videoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -71,7 +66,7 @@ internal class VideoTransformationAcceptedWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -79,50 +74,46 @@ internal class VideoTransformationAcceptedWebhookEventTest { ) .build() - assertThat(videoTransformationAcceptedWebhookEvent.id()).isEqualTo("id") - assertThat(videoTransformationAcceptedWebhookEvent.createdAt()) + assertThat(videoTransformationAcceptedEvent.id()).isEqualTo("id") + assertThat(videoTransformationAcceptedEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationAcceptedWebhookEvent.data()) + assertThat(videoTransformationAcceptedEvent.data()) .isEqualTo( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .VideoCodec .H264 ) @@ -132,9 +123,9 @@ internal class VideoTransformationAcceptedWebhookEventTest { ) .build() ) - assertThat(videoTransformationAcceptedWebhookEvent.request()) + assertThat(videoTransformationAcceptedEvent.request()) .isEqualTo( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -145,54 +136,49 @@ internal class VideoTransformationAcceptedWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationAcceptedWebhookEvent = - VideoTransformationAcceptedWebhookEvent.builder() + val videoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationAcceptedWebhookEvent.Data.builder() + VideoTransformationAcceptedEvent.Data.builder() .asset( - VideoTransformationAcceptedWebhookEvent.Data.Asset.builder() + VideoTransformationAcceptedEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.builder() + VideoTransformationAcceptedEvent.Data.Transformation.builder() .type( - VideoTransformationAcceptedWebhookEvent.Data.Transformation.Type + VideoTransformationAcceptedEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationAcceptedWebhookEvent.Data.Transformation - .Options + VideoTransformationAcceptedEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationAcceptedWebhookEvent.Data - .Transformation + VideoTransformationAcceptedEvent.Data.Transformation .Options .VideoCodec .H264 @@ -204,7 +190,7 @@ internal class VideoTransformationAcceptedWebhookEventTest { .build() ) .request( - VideoTransformationAcceptedWebhookEvent.Request.builder() + VideoTransformationAcceptedEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -212,13 +198,13 @@ internal class VideoTransformationAcceptedWebhookEventTest { ) .build() - val roundtrippedVideoTransformationAcceptedWebhookEvent = + val roundtrippedVideoTransformationAcceptedEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationAcceptedWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationAcceptedEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationAcceptedWebhookEvent) - .isEqualTo(videoTransformationAcceptedWebhookEvent) + assertThat(roundtrippedVideoTransformationAcceptedEvent) + .isEqualTo(videoTransformationAcceptedEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt similarity index 70% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt index 5cf7bfe7..4d2b3f63 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt @@ -8,64 +8,63 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationErrorWebhookEventTest { +internal class VideoTransformationErrorEventTest { @Test fun create() { - val videoTransformationErrorWebhookEvent = - VideoTransformationErrorWebhookEvent.builder() + val videoTransformationErrorEvent = + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -77,7 +76,7 @@ internal class VideoTransformationErrorWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -85,61 +84,54 @@ internal class VideoTransformationErrorWebhookEventTest { ) .build() - assertThat(videoTransformationErrorWebhookEvent.id()).isEqualTo("id") - assertThat(videoTransformationErrorWebhookEvent.createdAt()) + assertThat(videoTransformationErrorEvent.id()).isEqualTo("id") + assertThat(videoTransformationErrorEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationErrorWebhookEvent.data()) + assertThat(videoTransformationErrorEvent.data()) .isEqualTo( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error - .builder() + VideoTransformationErrorEvent.Data.Transformation.Error.builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options - .builder() + VideoTransformationErrorEvent.Data.Transformation.Options.builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Options + VideoTransformationErrorEvent.Data.Transformation.Options .VideoCodec .H264 ) @@ -149,9 +141,9 @@ internal class VideoTransformationErrorWebhookEventTest { ) .build() ) - assertThat(videoTransformationErrorWebhookEvent.request()) + assertThat(videoTransformationErrorEvent.request()) .isEqualTo( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -162,60 +154,59 @@ internal class VideoTransformationErrorWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationErrorWebhookEvent = - VideoTransformationErrorWebhookEvent.builder() + val videoTransformationErrorEvent = + VideoTransformationErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationErrorWebhookEvent.Data.builder() + VideoTransformationErrorEvent.Data.builder() .asset( - VideoTransformationErrorWebhookEvent.Data.Asset.builder() + VideoTransformationErrorEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationErrorWebhookEvent.Data.Transformation.builder() + VideoTransformationErrorEvent.Data.Transformation.builder() .type( - VideoTransformationErrorWebhookEvent.Data.Transformation.Type + VideoTransformationErrorEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .error( - VideoTransformationErrorWebhookEvent.Data.Transformation.Error + VideoTransformationErrorEvent.Data.Transformation.Error .builder() .reason( - VideoTransformationErrorWebhookEvent.Data.Transformation - .Error + VideoTransformationErrorEvent.Data.Transformation.Error .Reason .ENCODING_FAILED ) .build() ) .options( - VideoTransformationErrorWebhookEvent.Data.Transformation.Options + VideoTransformationErrorEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationErrorWebhookEvent.Data.Transformation + VideoTransformationErrorEvent.Data.Transformation .Options .VideoCodec .H264 @@ -227,7 +218,7 @@ internal class VideoTransformationErrorWebhookEventTest { .build() ) .request( - VideoTransformationErrorWebhookEvent.Request.builder() + VideoTransformationErrorEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") @@ -235,13 +226,13 @@ internal class VideoTransformationErrorWebhookEventTest { ) .build() - val roundtrippedVideoTransformationErrorWebhookEvent = + val roundtrippedVideoTransformationErrorEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationErrorWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationErrorEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationErrorWebhookEvent) - .isEqualTo(videoTransformationErrorWebhookEvent) + assertThat(roundtrippedVideoTransformationErrorEvent) + .isEqualTo(videoTransformationErrorEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt similarity index 72% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt index c9ad1646..2c9c0127 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt @@ -8,53 +8,53 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class VideoTransformationReadyWebhookEventTest { +internal class VideoTransformationReadyEventTest { @Test fun create() { - val videoTransformationReadyWebhookEvent = - VideoTransformationReadyWebhookEvent.builder() + val videoTransformationReadyEvent = + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -62,12 +62,11 @@ internal class VideoTransformationReadyWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -83,76 +82,69 @@ internal class VideoTransformationReadyWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() ) .build() - assertThat(videoTransformationReadyWebhookEvent.id()).isEqualTo("id") - assertThat(videoTransformationReadyWebhookEvent.createdAt()) + assertThat(videoTransformationReadyEvent.id()).isEqualTo("id") + assertThat(videoTransformationReadyEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(videoTransformationReadyWebhookEvent.data()) + assertThat(videoTransformationReadyEvent.data()) .isEqualTo( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options - .builder() + VideoTransformationReadyEvent.Data.Transformation.Options.builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Options + VideoTransformationReadyEvent.Data.Transformation.Options .VideoCodec .H264 ) .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output - .builder() + VideoTransformationReadyEvent.Data.Transformation.Output.builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -167,17 +159,17 @@ internal class VideoTransformationReadyWebhookEventTest { ) .build() ) - assertThat(videoTransformationReadyWebhookEvent.request()) + assertThat(videoTransformationReadyEvent.request()) .isEqualTo( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) - assertThat(videoTransformationReadyWebhookEvent.timings()) + assertThat(videoTransformationReadyEvent.timings()) .contains( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() @@ -187,49 +179,49 @@ internal class VideoTransformationReadyWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val videoTransformationReadyWebhookEvent = - VideoTransformationReadyWebhookEvent.builder() + val videoTransformationReadyEvent = + VideoTransformationReadyEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - VideoTransformationReadyWebhookEvent.Data.builder() + VideoTransformationReadyEvent.Data.builder() .asset( - VideoTransformationReadyWebhookEvent.Data.Asset.builder() + VideoTransformationReadyEvent.Data.Asset.builder() .url("https://example.com") .build() ) .transformation( - VideoTransformationReadyWebhookEvent.Data.Transformation.builder() + VideoTransformationReadyEvent.Data.Transformation.builder() .type( - VideoTransformationReadyWebhookEvent.Data.Transformation.Type + VideoTransformationReadyEvent.Data.Transformation.Type .VIDEO_TRANSFORMATION ) .options( - VideoTransformationReadyWebhookEvent.Data.Transformation.Options + VideoTransformationReadyEvent.Data.Transformation.Options .builder() .audioCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .AudioCodec .AAC ) .autoRotate(true) .format( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .Format .MP4 ) .quality(0L) .streamProtocol( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .StreamProtocol .HLS ) .addVariant("string") .videoCodec( - VideoTransformationReadyWebhookEvent.Data.Transformation + VideoTransformationReadyEvent.Data.Transformation .Options .VideoCodec .H264 @@ -237,12 +229,11 @@ internal class VideoTransformationReadyWebhookEventTest { .build() ) .output( - VideoTransformationReadyWebhookEvent.Data.Transformation.Output + VideoTransformationReadyEvent.Data.Transformation.Output .builder() .url("https://example.com") .videoMetadata( - VideoTransformationReadyWebhookEvent.Data.Transformation - .Output + VideoTransformationReadyEvent.Data.Transformation.Output .VideoMetadata .builder() .bitrate(0L) @@ -258,27 +249,27 @@ internal class VideoTransformationReadyWebhookEventTest { .build() ) .request( - VideoTransformationReadyWebhookEvent.Request.builder() + VideoTransformationReadyEvent.Request.builder() .url("https://example.com") .xRequestId("x_request_id") .userAgent("user_agent") .build() ) .timings( - VideoTransformationReadyWebhookEvent.Timings.builder() + VideoTransformationReadyEvent.Timings.builder() .downloadDuration(0L) .encodingDuration(0L) .build() ) .build() - val roundtrippedVideoTransformationReadyWebhookEvent = + val roundtrippedVideoTransformationReadyEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(videoTransformationReadyWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(videoTransformationReadyEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedVideoTransformationReadyWebhookEvent) - .isEqualTo(videoTransformationReadyWebhookEvent) + assertThat(roundtrippedVideoTransformationReadyEvent) + .isEqualTo(videoTransformationReadyEvent) } } From 844efbb517d8e20403121395886aac739a014e6f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 10:35:24 +0000 Subject: [PATCH 072/125] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index f8ab83a1..5d987049 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-863564701f791fdf016f7321fce445de5e368c474b06b135aaac16214f4f6416.yml -openapi_spec_hash: e3bb05601081de07084edf79cf3a2d63 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-5b571c1f83e65c8209d9e4d82e89f62e958a852d1f3ccdb9e8137292079bb18f.yml +openapi_spec_hash: e67360f0b45cace9f1cbfa280982b56c config_hash: d6fc50026fa9ef4b444d43c07c2c70a6 From e28f4918e5a69de4fd532dd03a5f2fbe9c3d2135 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 10:43:40 +0000 Subject: [PATCH 073/125] feat(api): manual updates --- .stats.yml | 6 +- .../com/imagekit/api/models/BaseOverlay.kt | 189 + .../com/imagekit/api/models/ImageOverlay.kt | 645 ++ .../kotlin/com/imagekit/api/models/Overlay.kt | 266 + .../imagekit/api/models/OverlayPosition.kt | 779 ++ .../com/imagekit/api/models/OverlayTiming.kt | 801 ++ .../imagekit/api/models/SolidColorOverlay.kt | 471 + .../models/SolidColorOverlayTransformation.kt | 1308 +++ .../com/imagekit/api/models/SrcOptions.kt | 508 + .../api/models/StreamingResolution.kt | 165 + .../imagekit/api/models/SubtitleOverlay.kt | 641 ++ .../models/SubtitleOverlayTransformation.kt | 730 ++ .../com/imagekit/api/models/TextOverlay.kt | 645 ++ .../api/models/TextOverlayTransformation.kt | 2299 +++++ .../com/imagekit/api/models/Transformation.kt | 8430 +++++++++++++++++ .../api/models/TransformationPosition.kt | 140 + .../com/imagekit/api/models/VideoOverlay.kt | 645 ++ .../imagekit/api/models/BaseOverlayTest.kt | 57 + .../imagekit/api/models/ImageOverlayTest.kt | 70 + .../api/models/OverlayPositionTest.kt | 36 + .../com/imagekit/api/models/OverlayTest.kt | 371 + .../imagekit/api/models/OverlayTimingTest.kt | 34 + .../api/models/SolidColorOverlayTest.kt | 95 + .../SolidColorOverlayTransformationTest.kt | 62 + .../com/imagekit/api/models/SrcOptionsTest.kt | 225 + .../api/models/SubtitleOverlayTest.kt | 101 + .../SubtitleOverlayTransformationTest.kt | 59 + .../imagekit/api/models/TextOverlayTest.kt | 119 + .../models/TextOverlayTransformationTest.kt | 82 + .../imagekit/api/models/TransformationTest.kt | 208 + .../imagekit/api/models/VideoOverlayTest.kt | 70 + .../api/proguard/ProGuardCompatibilityTest.kt | 84 +- 32 files changed, 20304 insertions(+), 37 deletions(-) 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/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 diff --git a/.stats.yml b/.stats.yml index 5d987049..64418ba8 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-5b571c1f83e65c8209d9e4d82e89f62e958a852d1f3ccdb9e8137292079bb18f.yml -openapi_spec_hash: e67360f0b45cace9f1cbfa280982b56c -config_hash: d6fc50026fa9ef4b444d43c07c2c70a6 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f3bff3868f6fb17535ab409692a079b9187de5922d7f04578082ea44680d28db.yml +openapi_spec_hash: 00e12ee294dedaf7afab030d42178bf2 +config_hash: 1dd1a96eff228aa2567b9973c36f5593 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..caed3c95 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt @@ -0,0 +1,645 @@ +// 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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 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. + * + * @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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 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. + */ + 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ImageOverlay = + ImageOverlay( + position, + timing, + checkRequired("input", input), + checkRequired("type", 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().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (encoding.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + 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 IMAGE = of("image") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMAGE + } + + /** + * 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 { + IMAGE, + /** 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) { + IMAGE -> Value.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) { + IMAGE -> Known.IMAGE + 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 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..7f333a9c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt @@ -0,0 +1,266 @@ +// 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. + */ +@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..188bd09c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt @@ -0,0 +1,779 @@ +// 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. + * + * @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. + * + * @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. + */ + 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. + */ + 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. + */ + @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. + */ + @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..04d5cb24 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt @@ -0,0 +1,471 @@ +// 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 SolidColorOverlay +private constructor( + private val position: JsonField, + private val timing: JsonField, + private val color: JsonField, + private val type: 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("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * Control width and height of the solid color overlay. Supported transformations depend on the + * base/parent asset. + * + * @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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** + * Control width and height of the solid color overlay. Supported transformations depend on + * the base/parent asset. + */ + 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SolidColorOverlay = + SolidColorOverlay( + position, + timing, + checkRequired("color", color), + checkRequired("type", 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().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 (color.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + 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 SOLID_COLOR = of("solidColor") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SOLID_COLOR + } + + /** + * 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 { + SOLID_COLOR, + /** 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) { + SOLID_COLOR -> Value.SOLID_COLOR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + SOLID_COLOR -> Known.SOLID_COLOR + 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 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..fa15ed77 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt @@ -0,0 +1,1308 @@ +// 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 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()) + + /** + * Alpha transparency level + * + * @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") + + /** + * Background color + * + * @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") + + /** + * Gradient effect for the overlay + * + * @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") + + /** + * Height of the solid color overlay + * + * @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") + + /** + * Corner radius of the solid color overlay + * + * @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") + + /** + * Width of the solid color overlay + * + * @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() + } + + /** Alpha transparency level */ + 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 } + + /** Background color */ + 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 } + + /** Gradient effect for the overlay */ + 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.ofUnionMember0(unionMember0)`. */ + fun gradient(unionMember0: Gradient.UnionMember0) = + gradient(Gradient.ofUnionMember0(unionMember0)) + + /** Alias for calling [gradient] with `Gradient.ofString(string)`. */ + fun gradient(string: String) = gradient(Gradient.ofString(string)) + + /** Height of the solid color overlay */ + 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)) + + /** Corner radius of the solid color overlay */ + 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.ofUnionMember1(unionMember1)`. */ + fun radius(unionMember1: Radius.UnionMember1) = radius(Radius.ofUnionMember1(unionMember1)) + + /** Width of the solid color overlay */ + 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) + + /** Gradient effect for the overlay */ + @JsonDeserialize(using = Gradient.Deserializer::class) + @JsonSerialize(using = Gradient.Serializer::class) + class Gradient + private constructor( + private val unionMember0: UnionMember0? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun string(): Optional = Optional.ofNullable(string) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isString(): Boolean = string != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + 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 visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + 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 visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + 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 && unionMember0 == other.unionMember0 && string == other.string + } + + override fun hashCode(): Int = Objects.hash(unionMember0, string) + + override fun toString(): String = + when { + unionMember0 != null -> "Gradient{unionMember0=$unionMember0}" + string != null -> "Gradient{string=$string}" + _json != null -> "Gradient{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Gradient") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Gradient(unionMember0 = unionMember0) + + @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 visitUnionMember0(unionMember0: UnionMember0): 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(unionMember0 = it, _json = json) + }, + 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.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Gradient") + } + } + } + + class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) + } + + /** An enum containing [UnionMember0]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** Height of the solid color overlay */ + @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") + } + } + } + } + + /** Corner radius of the solid color overlay */ + @JsonDeserialize(using = Radius.Deserializer::class) + @JsonSerialize(using = Radius.Serializer::class) + class Radius + private constructor( + private val number: Double? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isNumber(): Boolean = number != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + 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 visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.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 visitNumber(number: Double) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Radius && number == other.number && unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(number, unionMember1) + + override fun toString(): String = + when { + number != null -> "Radius{number=$number}" + unionMember1 != null -> "Radius{unionMember1=$unionMember1}" + _json != null -> "Radius{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Radius") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Radius(number = number) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = Radius(unionMember1 = unionMember1) + } + + /** 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 visitUnionMember1(unionMember1: UnionMember1): 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(unionMember1 = it, _json = json) + }, + 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.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Radius") + } + } + } + + class UnionMember1 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MAX = of("max") + + @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + } + + /** An enum containing [UnionMember1]'s known values. */ + enum class Known { + MAX + } + + /** + * An enum containing [UnionMember1]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember1] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAX, + /** + * An enum member indicating that [UnionMember1] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAX -> Value.MAX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + MAX -> Known.MAX + else -> throw ImageKitInvalidDataException("Unknown UnionMember1: $value") + } + + /** + * Returns this class 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(): UnionMember1 = 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 UnionMember1 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** Width of the solid color overlay */ + @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..d0fe7069 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt @@ -0,0 +1,508 @@ +// 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 */ +class SrcOptions +private constructor( + private val src: JsonField, + private val urlEndpoint: JsonField, + private val queryParameters: 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("queryParameters") + @ExcludeMissing + queryParameters: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField> = JsonMissing.of(), + @JsonProperty("transformationPosition") + @ExcludeMissing + transformationPosition: JsonField = JsonMissing.of(), + ) : this( + src, + urlEndpoint, + queryParameters, + 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") + + /** + * 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") + + /** + * 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. + * + * @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`. + * + * @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 [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 [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 queryParameters: 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 + queryParameters = srcOptions.queryParameters + 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 } + + /** + * 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 + } + + /** + * 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. + */ + 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`. + */ + 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), + queryParameters, + (transformation ?: JsonMissing.of()).map { it.toImmutable() }, + transformationPosition, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SrcOptions = apply { + if (validated) { + return@apply + } + + src() + urlEndpoint() + queryParameters().ifPresent { it.validate() } + 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) + + (queryParameters.asKnown().getOrNull()?.validity() ?: 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 && + queryParameters == other.queryParameters && + transformation == other.transformation && + transformationPosition == other.transformationPosition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + src, + urlEndpoint, + queryParameters, + transformation, + transformationPosition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SrcOptions{src=$src, urlEndpoint=$urlEndpoint, queryParameters=$queryParameters, 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..2413aa27 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/StreamingResolution.kt @@ -0,0 +1,165 @@ +// 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 */ +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..9f568e8c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt @@ -0,0 +1,641 @@ +// 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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 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. + * + * @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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 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. */ + 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubtitleOverlay = + SubtitleOverlay( + position, + timing, + checkRequired("input", input), + checkRequired("type", 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().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (encoding.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + 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 SUBTITLE = of("subtitle") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SUBTITLE + } + + /** + * 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 { + SUBTITLE, + /** 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) { + SUBTITLE -> Value.SUBTITLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + SUBTITLE -> Known.SUBTITLE + 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 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..5fef0b6a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt @@ -0,0 +1,730 @@ +// 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 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(), + ) + + /** + * Background color for subtitles + * + * @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") + + /** + * Text color for subtitles + * + * @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 + * + * @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") + + /** + * Font outline for subtitles + * + * @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") + + /** + * Font shadow for subtitles + * + * @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") + + /** + * Font size for subtitles + * + * @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") + + /** + * Typography style for subtitles + * + * @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() + } + + /** Background color for subtitles */ + 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 } + + /** Text color for subtitles */ + 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 */ + 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 } + + /** Font outline for subtitles */ + 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 } + + /** Font shadow for subtitles */ + 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 } + + /** Font size for subtitles */ + 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)) + + /** Typography style for subtitles */ + 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().ifPresent { it.validate() } + 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) + + (fontSize.asKnown().getOrNull()?.validity() ?: 0) + + (typography.asKnown().getOrNull()?.validity() ?: 0) + + /** Font size for subtitles */ + @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") + } + } + } + } + + /** Typography style for subtitles */ + 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..6d37116c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt @@ -0,0 +1,645 @@ +// 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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") + + /** + * 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. + * + * @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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 } + + /** + * 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. */ + 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TextOverlay = + TextOverlay( + position, + timing, + checkRequired("text", text), + checkRequired("type", 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().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (encoding.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + 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") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT + } + + /** + * 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, + /** 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 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 + 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() + } + + /** + * 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..c8438549 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt @@ -0,0 +1,2299 @@ +// 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. + * + * @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. + * + * @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: `b` for bold, `i` for italics, + * and `b_i` for bold with italics. + * + * @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`. + * + * @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. + */ + 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. */ + 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.ofUnionMember1(unionMember1)`. */ + fun radius(unionMember1: Radius.UnionMember1) = radius(Radius.ofUnionMember1(unionMember1)) + + /** + * 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: `b` for bold, `i` for + * italics, and `b_i` for bold with italics. + */ + 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 } + + /** + * 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`. + */ + 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().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) + + (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) + + (typography.asKnown().getOrNull()?.validity() ?: 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. */ + @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 unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isNumber(): Boolean = number != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + 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 visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.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 visitNumber(number: Double) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Radius && number == other.number && unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(number, unionMember1) + + override fun toString(): String = + when { + number != null -> "Radius{number=$number}" + unionMember1 != null -> "Radius{unionMember1=$unionMember1}" + _json != null -> "Radius{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Radius") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Radius(number = number) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = Radius(unionMember1 = unionMember1) + } + + /** 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 visitUnionMember1(unionMember1: UnionMember1): 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(unionMember1 = it, _json = json) + }, + 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.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Radius") + } + } + } + + class UnionMember1 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MAX = of("max") + + @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + } + + /** An enum containing [UnionMember1]'s known values. */ + enum class Known { + MAX + } + + /** + * An enum containing [UnionMember1]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember1] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAX, + /** + * An enum member indicating that [UnionMember1] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAX -> Value.MAX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + MAX -> Known.MAX + else -> throw ImageKitInvalidDataException("Unknown UnionMember1: $value") + } + + /** + * Returns this class 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(): UnionMember1 = 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 UnionMember1 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** + * 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 typography style of the text. Supported values: `b` for bold, `i` for italics, + * and `b_i` for bold with italics. + */ + 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() + } + + /** + * 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`. + */ + @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..ef2d67b6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt @@ -0,0 +1,8430 @@ +// 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. + */ +class Transformation +private constructor( + private val aiChangeBackground: JsonField, + private val aiDropShadow: 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("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, + 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. + * + * @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. + * + * @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") + + /** + * Applies ImageKit's in-house background removal. Supported inside overlay. + * + * @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. + * + * @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. + * + * @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. + * + * @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. + * + * @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`. + * + * @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`. + * + * @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`. + * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. + * - 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}]`. + * + * @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`. + * + * @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`. + * + * @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. + * + * @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). + * + * @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 + * + * @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 + * + * @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. + * + * @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. + * + * @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. + * + * @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. + * + * @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`. + * + * @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") + + /** + * This parameter can be used with pad resize, maintain ratio, or extract crop to modify the + * padding or cropping behavior. + * + * @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. + * + * @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. + * + * @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. + * + * @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`). + * + * @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. + * + * @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. + * + * @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 + * + * @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. + * + * @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. + * + * @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. + * + * @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). + * + * @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. + * + * @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. + * + * @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/oval shapes. + * + * @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. + * + * @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. + * + * @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. + * + * @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. + * + * @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`]. + * + * @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. + * + * @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. + * + * @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`. + * + * @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`). + * + * @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 + * + * @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 + * + * @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 + * + * @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 + * + * @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-. + * + * @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 [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 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 + 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. + */ + 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. + */ + 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.ofUnionMember0(unionMember0)`. */ + fun aiDropShadow(unionMember0: AiDropShadow.UnionMember0) = + aiDropShadow(AiDropShadow.ofUnionMember0(unionMember0)) + + /** Alias for calling [aiDropShadow] with `AiDropShadow.ofString(string)`. */ + fun aiDropShadow(string: String) = aiDropShadow(AiDropShadow.ofString(string)) + + /** Applies ImageKit's in-house background removal. Supported inside overlay. */ + 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. + */ + 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. + */ + 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. + */ + 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. + */ + 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`. + */ + 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`. */ + 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`. + * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. + * - 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}]`. + */ + 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`. + */ + 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`. + */ + 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. */ + 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). */ + 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 */ + 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 */ + 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. */ + 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. + */ + 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. + */ + 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. + */ + 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`. + */ + 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 } + + /** + * This parameter can be used with pad resize, maintain ratio, or extract crop to modify the + * padding or cropping behavior. + */ + 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. + */ + 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. + */ + 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.ofUnionMember0(unionMember0)`. */ + fun gradient(unionMember0: Gradient.UnionMember0) = + gradient(Gradient.ofUnionMember0(unionMember0)) + + /** Alias for calling [gradient] with `Gradient.ofString(string)`. */ + fun gradient(string: String) = gradient(Gradient.ofString(string)) + + /** Enables a grayscale effect for images. */ + 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`). + */ + 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. */ + 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. + */ + 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 */ + 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. */ + 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. */ + 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. + */ + 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() + * .type(TextOverlay.Type.TEXT) + * .text(text) + * .build() + * ``` + */ + fun textOverlay(text: String) = + overlay(TextOverlay.builder().type(TextOverlay.Type.TEXT).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() + * .type(ImageOverlay.Type.IMAGE) + * .input(input) + * .build() + * ``` + */ + fun imageOverlay(input: String) = + overlay(ImageOverlay.builder().type(ImageOverlay.Type.IMAGE).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() + * .type(VideoOverlay.Type.VIDEO) + * .input(input) + * .build() + * ``` + */ + fun videoOverlay(input: String) = + overlay(VideoOverlay.builder().type(VideoOverlay.Type.VIDEO).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() + * .type(SubtitleOverlay.Type.SUBTITLE) + * .input(input) + * .build() + * ``` + */ + fun subtitleOverlay(input: String) = + overlay( + SubtitleOverlay.builder().type(SubtitleOverlay.Type.SUBTITLE).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() + * .type(SolidColorOverlay.Type.SOLID_COLOR) + * .color(color) + * .build() + * ``` + */ + fun solidColorOverlay(color: String) = + overlay( + SolidColorOverlay.builder() + .type(SolidColorOverlay.Type.SOLID_COLOR) + .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). + */ + 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. + */ + 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. + */ + 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/oval + * shapes. + */ + 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.ofUnionMember1(unionMember1)`. */ + fun radius(unionMember1: Radius.UnionMember1) = radius(Radius.ofUnionMember1(unionMember1)) + + /** + * 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. + */ + 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. + */ + 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.ofUnionMember0(unionMember0)`. */ + fun shadow(unionMember0: Shadow.UnionMember0) = shadow(Shadow.ofUnionMember0(unionMember0)) + + /** 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. + */ + 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.ofUnionMember0(unionMember0)`. */ + fun sharpen(unionMember0: Sharpen.UnionMember0) = + sharpen(Sharpen.ofUnionMember0(unionMember0)) + + /** 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. + */ + 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`]. + */ + 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. + */ + 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.ofUnionMember0(unionMember0)`. */ + fun trim(unionMember0: Trim.UnionMember0) = trim(Trim.ofUnionMember0(unionMember0)) + + /** 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. + */ + 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.ofUnionMember0(unionMember0)`. */ + fun unsharpMask(unionMember0: UnsharpMask.UnionMember0) = + unsharpMask(UnsharpMask.ofUnionMember0(unionMember0)) + + /** 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`. */ + 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`). + */ + 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 */ + 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 */ + 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 */ + 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 */ + 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-. + */ + 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, + 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() } + 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) + + (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. + */ + @JsonDeserialize(using = AiDropShadow.Deserializer::class) + @JsonSerialize(using = AiDropShadow.Serializer::class) + class AiDropShadow + private constructor( + private val unionMember0: UnionMember0? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun string(): Optional = Optional.ofNullable(string) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isString(): Boolean = string != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + 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 visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + 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 visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + 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 && + unionMember0 == other.unionMember0 && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(unionMember0, string) + + override fun toString(): String = + when { + unionMember0 != null -> "AiDropShadow{unionMember0=$unionMember0}" + string != null -> "AiDropShadow{string=$string}" + _json != null -> "AiDropShadow{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AiDropShadow") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + AiDropShadow(unionMember0 = unionMember0) + + @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 visitUnionMember0(unionMember0: UnionMember0): 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(unionMember0 = it, _json = json) + }, + 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.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AiDropShadow") + } + } + } + + class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) + } + + /** An enum containing [UnionMember0]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** Applies ImageKit's in-house background removal. Supported inside overlay. */ + 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. + */ + 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. + */ + 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. */ + 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. + */ + 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`. + */ + @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`. */ + 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). */ + 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 */ + 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 */ + 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. + */ + @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. + */ + @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`. + */ + 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. + */ + 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. + */ + @JsonDeserialize(using = Gradient.Deserializer::class) + @JsonSerialize(using = Gradient.Serializer::class) + class Gradient + private constructor( + private val unionMember0: UnionMember0? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun string(): Optional = Optional.ofNullable(string) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isString(): Boolean = string != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + 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 visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + 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 visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + 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 && unionMember0 == other.unionMember0 && string == other.string + } + + override fun hashCode(): Int = Objects.hash(unionMember0, string) + + override fun toString(): String = + when { + unionMember0 != null -> "Gradient{unionMember0=$unionMember0}" + string != null -> "Gradient{string=$string}" + _json != null -> "Gradient{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Gradient") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Gradient(unionMember0 = unionMember0) + + @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 visitUnionMember0(unionMember0: UnionMember0): 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(unionMember0 = it, _json = json) + }, + 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.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Gradient") + } + } + } + + class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) + } + + /** An enum containing [UnionMember0]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** Enables a grayscale effect for images. */ + 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`). + */ + @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). + */ + @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/oval shapes. + */ + @JsonDeserialize(using = Radius.Deserializer::class) + @JsonSerialize(using = Radius.Serializer::class) + class Radius + private constructor( + private val number: Double? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isNumber(): Boolean = number != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + 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 visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.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 visitNumber(number: Double) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Radius && number == other.number && unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(number, unionMember1) + + override fun toString(): String = + when { + number != null -> "Radius{number=$number}" + unionMember1 != null -> "Radius{unionMember1=$unionMember1}" + _json != null -> "Radius{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Radius") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Radius(number = number) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = Radius(unionMember1 = unionMember1) + } + + /** 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 visitUnionMember1(unionMember1: UnionMember1): 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(unionMember1 = it, _json = json) + }, + 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.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Radius") + } + } + } + + class UnionMember1 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MAX = of("max") + + @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) + } + + /** An enum containing [UnionMember1]'s known values. */ + enum class Known { + MAX + } + + /** + * An enum containing [UnionMember1]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember1] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAX, + /** + * An enum member indicating that [UnionMember1] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAX -> Value.MAX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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) { + MAX -> Known.MAX + else -> throw ImageKitInvalidDataException("Unknown UnionMember1: $value") + } + + /** + * Returns this class 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(): UnionMember1 = 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 UnionMember1 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** + * 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. + */ + @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. + */ + @JsonDeserialize(using = Shadow.Deserializer::class) + @JsonSerialize(using = Shadow.Serializer::class) + class Shadow + private constructor( + private val unionMember0: UnionMember0? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun string(): Optional = Optional.ofNullable(string) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isString(): Boolean = string != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + 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 visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + 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 visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + 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 && unionMember0 == other.unionMember0 && string == other.string + } + + override fun hashCode(): Int = Objects.hash(unionMember0, string) + + override fun toString(): String = + when { + unionMember0 != null -> "Shadow{unionMember0=$unionMember0}" + string != null -> "Shadow{string=$string}" + _json != null -> "Shadow{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Shadow") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Shadow(unionMember0 = unionMember0) + + @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 visitUnionMember0(unionMember0: UnionMember0): 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(unionMember0 = it, _json = json) + }, + 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.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Shadow") + } + } + } + + class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) + } + + /** An enum containing [UnionMember0]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** + * Sharpens the input image, highlighting edges and finer details. Pass `true` for default + * sharpening, or provide a numeric value for custom sharpening. + */ + @JsonDeserialize(using = Sharpen.Deserializer::class) + @JsonSerialize(using = Sharpen.Serializer::class) + class Sharpen + private constructor( + private val unionMember0: UnionMember0? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun number(): Optional = Optional.ofNullable(number) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isNumber(): Boolean = number != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + 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 visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + 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 visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + 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 && unionMember0 == other.unionMember0 && number == other.number + } + + override fun hashCode(): Int = Objects.hash(unionMember0, number) + + override fun toString(): String = + when { + unionMember0 != null -> "Sharpen{unionMember0=$unionMember0}" + number != null -> "Sharpen{number=$number}" + _json != null -> "Sharpen{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Sharpen") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Sharpen(unionMember0 = unionMember0) + + @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 visitUnionMember0(unionMember0: UnionMember0): 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(unionMember0 = it, _json = json) + }, + 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.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Sharpen") + } + } + } + + class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) + } + + /** An enum containing [UnionMember0]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** + * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. Arithmetic + * expressions are also supported. + */ + @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. + */ + @JsonDeserialize(using = Trim.Deserializer::class) + @JsonSerialize(using = Trim.Serializer::class) + class Trim + private constructor( + private val unionMember0: UnionMember0? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun number(): Optional = Optional.ofNullable(number) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isNumber(): Boolean = number != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + 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 visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + 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 visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + 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 && unionMember0 == other.unionMember0 && number == other.number + } + + override fun hashCode(): Int = Objects.hash(unionMember0, number) + + override fun toString(): String = + when { + unionMember0 != null -> "Trim{unionMember0=$unionMember0}" + number != null -> "Trim{number=$number}" + _json != null -> "Trim{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Trim") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Trim(unionMember0 = unionMember0) + + @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 visitUnionMember0(unionMember0: UnionMember0): 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(unionMember0 = it, _json = json) + }, + 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.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Trim") + } + } + } + + class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) + } + + /** An enum containing [UnionMember0]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** + * Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a default + * unsharp mask, or provide a string for a custom unsharp mask. + */ + @JsonDeserialize(using = UnsharpMask.Deserializer::class) + @JsonSerialize(using = UnsharpMask.Serializer::class) + class UnsharpMask + private constructor( + private val unionMember0: UnionMember0? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun string(): Optional = Optional.ofNullable(string) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isString(): Boolean = string != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + 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 visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + 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 visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + 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 && + unionMember0 == other.unionMember0 && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(unionMember0, string) + + override fun toString(): String = + when { + unionMember0 != null -> "UnsharpMask{unionMember0=$unionMember0}" + string != null -> "UnsharpMask{string=$string}" + _json != null -> "UnsharpMask{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnsharpMask") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + UnsharpMask(unionMember0 = unionMember0) + + @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 visitUnionMember0(unionMember0: UnionMember0): 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(unionMember0 = it, _json = json) + }, + 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.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnsharpMask") + } + } + } + + class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) + } + + /** An enum containing [UnionMember0]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [UnionMember0] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + } + + /** Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. */ + 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`). + */ + @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 */ + @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 */ + @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 */ + @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 */ + @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 && + 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, + 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, 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..aca5d81a --- /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`. + */ +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..d40d2fe9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt @@ -0,0 +1,645 @@ +// 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: JsonField, + 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: JsonField = 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") + + /** + * @throws ImageKitInvalidDataException if 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 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. + * + * @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 [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 [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() + * .type() + * ``` + */ + @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: JsonField? = null + 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 } + + 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 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. + */ + 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() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoOverlay = + VideoOverlay( + position, + timing, + checkRequired("input", input), + checkRequired("type", 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().validate() + 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.asKnown().getOrNull()?.validity() ?: 0) + + (encoding.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + 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 = of("video") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VIDEO + } + + /** + * 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, + /** 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 -> Value.VIDEO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use 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 -> Known.VIDEO + 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 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/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..8c7650f5 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt @@ -0,0 +1,70 @@ +// 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") + .type(ImageOverlay.Type.IMAGE) + .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.type()).isEqualTo(ImageOverlay.Type.IMAGE) + 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") + .type(ImageOverlay.Type.IMAGE) + .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..f3225383 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt @@ -0,0 +1,371 @@ +// 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") + .type(TextOverlay.Type.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(TextOverlayTransformation.Typography.B) + .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") + .type(TextOverlay.Type.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(TextOverlayTransformation.Typography.B) + .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") + .type(ImageOverlay.Type.IMAGE) + .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") + .type(ImageOverlay.Type.IMAGE) + .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") + .type(VideoOverlay.Type.VIDEO) + .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") + .type(VideoOverlay.Type.VIDEO) + .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") + .type(SubtitleOverlay.Type.SUBTITLE) + .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") + .type(SubtitleOverlay.Type.SUBTITLE) + .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") + .type(SolidColorOverlay.Type.SOLID_COLOR) + .addTransformation( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .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") + .type(SolidColorOverlay.Type.SOLID_COLOR) + .addTransformation( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .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..81c5191b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt @@ -0,0 +1,95 @@ +// 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") + .type(SolidColorOverlay.Type.SOLID_COLOR) + .addTransformation( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .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.type()).isEqualTo(SolidColorOverlay.Type.SOLID_COLOR) + assertThat(solidColorOverlay.transformation().getOrNull()) + .containsExactly( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .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") + .type(SolidColorOverlay.Type.SOLID_COLOR) + .addTransformation( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .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..d2d418e7 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt @@ -0,0 +1,62 @@ +// 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") + .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .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.ofUnionMember0( + SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE + ) + ) + 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") + .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .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..9899d6f3 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt @@ -0,0 +1,225 @@ +// 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") + .queryParameters( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .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) + .gradient(Transformation.Gradient.UnionMember0.TRUE) + .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) + .shadow(Transformation.Shadow.UnionMember0.TRUE) + .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trim(Transformation.Trim.UnionMember0.TRUE) + .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .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.queryParameters()) + .contains( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(srcOptions.transformation().getOrNull()) + .containsExactly( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .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) + .gradient(Transformation.Gradient.UnionMember0.TRUE) + .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) + .shadow(Transformation.Shadow.UnionMember0.TRUE) + .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trim(Transformation.Trim.UnionMember0.TRUE) + .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .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") + .queryParameters( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .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) + .gradient(Transformation.Gradient.UnionMember0.TRUE) + .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) + .shadow(Transformation.Shadow.UnionMember0.TRUE) + .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trim(Transformation.Trim.UnionMember0.TRUE) + .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .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..f618c812 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt @@ -0,0 +1,101 @@ +// 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") + .type(SubtitleOverlay.Type.SUBTITLE) + .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.type()).isEqualTo(SubtitleOverlay.Type.SUBTITLE) + 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") + .type(SubtitleOverlay.Type.SUBTITLE) + .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..4cd570f8 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTransformationTest.kt @@ -0,0 +1,59 @@ +// 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(SubtitleOverlayTransformation.FontSize.ofNumber(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..a92907f2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt @@ -0,0 +1,119 @@ +// 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") + .type(TextOverlay.Type.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(TextOverlayTransformation.Typography.B) + .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.type()).isEqualTo(TextOverlay.Type.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(TextOverlayTransformation.Typography.B) + .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") + .type(TextOverlay.Type.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(TextOverlayTransformation.Typography.B) + .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..ed8edaea --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt @@ -0,0 +1,82 @@ +// 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(TextOverlayTransformation.Typography.B) + .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(TextOverlayTransformation.Typography.B) + 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(TextOverlayTransformation.Typography.B) + .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..87e44a66 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -0,0 +1,208 @@ +// 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") + .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .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) + .gradient(Transformation.Gradient.UnionMember0.TRUE) + .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) + .shadow(Transformation.Shadow.UnionMember0.TRUE) + .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trim(Transformation.Trim.UnionMember0.TRUE) + .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .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.ofUnionMember0( + Transformation.AiDropShadow.UnionMember0.TRUE + ) + ) + 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.ofUnionMember0(Transformation.Gradient.UnionMember0.TRUE) + ) + 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.ofUnionMember0(Transformation.Shadow.UnionMember0.TRUE)) + assertThat(transformation.sharpen()) + .contains( + Transformation.Sharpen.ofUnionMember0(Transformation.Sharpen.UnionMember0.TRUE) + ) + assertThat(transformation.startOffset()).contains(Transformation.StartOffset.ofNumber(0.0)) + assertThat(transformation.streamingResolutions().getOrNull()) + .containsExactly(StreamingResolution._240) + assertThat(transformation.trim()) + .contains(Transformation.Trim.ofUnionMember0(Transformation.Trim.UnionMember0.TRUE)) + assertThat(transformation.unsharpMask()) + .contains( + Transformation.UnsharpMask.ofUnionMember0( + Transformation.UnsharpMask.UnionMember0.TRUE + ) + ) + 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") + .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .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) + .gradient(Transformation.Gradient.UnionMember0.TRUE) + .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) + .shadow(Transformation.Shadow.UnionMember0.TRUE) + .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trim(Transformation.Trim.UnionMember0.TRUE) + .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .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..aad60f9b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt @@ -0,0 +1,70 @@ +// 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") + .type(VideoOverlay.Type.VIDEO) + .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.type()).isEqualTo(VideoOverlay.Type.VIDEO) + 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") + .type(VideoOverlay.Type.VIDEO) + .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-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 25a1fd27..a8234353 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,7 +6,12 @@ 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.assets.AssetListResponse +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 @@ -106,48 +111,59 @@ internal class ProGuardCompatibilityTest { } @Test - fun assetListResponseRoundtrip() { + fun overlayRoundtrip() { val jsonMapper = jsonMapper() - val assetListResponse = - AssetListResponse.ofFile( - File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() + val overlay = + Overlay.ofText( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customCoordinates("customCoordinates") - .customMetadata( - File.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .type(TextOverlay.Type.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(TextOverlayTransformation.Typography.B) + .width(0.0) .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 = + 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(assetListResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(streamingResolution), + jacksonTypeRef(), ) - assertThat(roundtrippedAssetListResponse).isEqualTo(assetListResponse) + assertThat(roundtrippedStreamingResolution).isEqualTo(streamingResolution) } } From a4b440a7f7a95d1ab2393e332300ae77ee4aea7a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 10:57:48 +0000 Subject: [PATCH 074/125] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 64418ba8..67507d30 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-f3bff3868f6fb17535ab409692a079b9187de5922d7f04578082ea44680d28db.yml -openapi_spec_hash: 00e12ee294dedaf7afab030d42178bf2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-81851750ac0e826623eae52a2361a85e97d1dc39cfcd47adea4b392440c897f1.yml +openapi_spec_hash: b36ee8d65b9b270168076c8d36420dc1 config_hash: 1dd1a96eff228aa2567b9973c36f5593 From cdc6082dc28adc48a6b0df17e341885db86f1c23 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 30 Aug 2025 12:54:52 +0000 Subject: [PATCH 075/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 67507d30..c328b0a5 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-81851750ac0e826623eae52a2361a85e97d1dc39cfcd47adea4b392440c897f1.yml openapi_spec_hash: b36ee8d65b9b270168076c8d36420dc1 -config_hash: 1dd1a96eff228aa2567b9973c36f5593 +config_hash: 93458331374b86a886e325d435070b07 From 7221948e3a4ec021462f51613e237230b7d69e5d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 30 Aug 2025 13:01:25 +0000 Subject: [PATCH 076/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index c328b0a5..57157abd 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-81851750ac0e826623eae52a2361a85e97d1dc39cfcd47adea4b392440c897f1.yml openapi_spec_hash: b36ee8d65b9b270168076c8d36420dc1 -config_hash: 93458331374b86a886e325d435070b07 +config_hash: 0388cd86c33cbbc99abfb19c4abb324f From 2c511a612f3dbd4a1e59839acae9155b13f86c79 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 30 Aug 2025 13:18:53 +0000 Subject: [PATCH 077/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 57157abd..9af54678 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-81851750ac0e826623eae52a2361a85e97d1dc39cfcd47adea4b392440c897f1.yml openapi_spec_hash: b36ee8d65b9b270168076c8d36420dc1 -config_hash: 0388cd86c33cbbc99abfb19c4abb324f +config_hash: 1335a5f946838eb26cf469ddf59cd223 From 0c72b3288073331ea4fb329038ad171462301be9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 30 Aug 2025 13:23:34 +0000 Subject: [PATCH 078/125] feat(api): manual updates --- .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 9af54678..fa65ec98 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-81851750ac0e826623eae52a2361a85e97d1dc39cfcd47adea4b392440c897f1.yml openapi_spec_hash: b36ee8d65b9b270168076c8d36420dc1 -config_hash: 1335a5f946838eb26cf469ddf59cd223 +config_hash: 249ee22f294858ab0971b8379f7cb519 diff --git a/README.md b/README.md index 48a34ace..84baa02e 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ [![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) from applications written in Java. +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). 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). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). ## Installation diff --git a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts index 37ae6e26..ca87253e 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") + url.set("https://imagekit.io/docs") licenses { license { From a4510a76ffa2eea2d0ce1a00285415f1ebf1307f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 31 Aug 2025 08:45:30 +0000 Subject: [PATCH 079/125] feat(api): manual updates --- .stats.yml | 4 +- .../com/imagekit/api/models/ImageOverlay.kt | 183 +- .../kotlin/com/imagekit/api/models/Overlay.kt | 3 +- .../imagekit/api/models/OverlayPosition.kt | 18 +- .../imagekit/api/models/SolidColorOverlay.kt | 184 +- .../models/SolidColorOverlayTransformation.kt | 418 +-- .../com/imagekit/api/models/SrcOptions.kt | 17 +- .../api/models/StreamingResolution.kt | 5 +- .../imagekit/api/models/SubtitleOverlay.kt | 181 +- .../models/SubtitleOverlayTransformation.kt | 325 +- .../com/imagekit/api/models/TextOverlay.kt | 181 +- .../api/models/TextOverlayTransformation.kt | 384 +-- .../com/imagekit/api/models/Transformation.kt | 1744 ++++------ .../api/models/TransformationPosition.kt | 2 +- .../com/imagekit/api/models/VideoOverlay.kt | 179 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 310 +- .../api/models/webhooks/UnwrapWebhookEvent.kt | 301 +- .../UploadPostTransformErrorWebhookEvent.kt | 1694 +++++++++ .../UploadPostTransformSuccessWebhookEvent.kt | 1291 +++++++ .../UploadPreTransformErrorWebhookEvent.kt | 1105 ++++++ .../UploadPreTransformSuccessWebhookEvent.kt | 3033 +++++++++++++++++ .../VideoTransformationAcceptedEvent.kt | 83 +- .../webhooks/VideoTransformationErrorEvent.kt | 100 +- .../webhooks/VideoTransformationReadyEvent.kt | 118 +- .../imagekit/api/models/ImageOverlayTest.kt | 3 - .../com/imagekit/api/models/OverlayTest.kt | 18 +- .../api/models/SolidColorOverlayTest.kt | 9 +- .../SolidColorOverlayTransformationTest.kt | 10 +- .../com/imagekit/api/models/SrcOptionsTest.kt | 39 +- .../api/models/SubtitleOverlayTest.kt | 3 - .../SubtitleOverlayTransformationTest.kt | 3 +- .../imagekit/api/models/TextOverlayTest.kt | 9 +- .../models/TextOverlayTransformationTest.kt | 7 +- .../imagekit/api/models/TransformationTest.kt | 57 +- .../imagekit/api/models/VideoOverlayTest.kt | 3 - .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 682 ++++ .../models/webhooks/UnwrapWebhookEventTest.kt | 680 ++++ ...ploadPostTransformErrorWebhookEventTest.kt | 156 + ...oadPostTransformSuccessWebhookEventTest.kt | 126 + ...UploadPreTransformErrorWebhookEventTest.kt | 112 + ...loadPreTransformSuccessWebhookEventTest.kt | 525 +++ .../api/proguard/ProGuardCompatibilityTest.kt | 3 +- 42 files changed, 11418 insertions(+), 2890 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEvent.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEventTest.kt diff --git a/.stats.yml b/.stats.yml index fa65ec98..caed6f5a 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-81851750ac0e826623eae52a2361a85e97d1dc39cfcd47adea4b392440c897f1.yml -openapi_spec_hash: b36ee8d65b9b270168076c8d36420dc1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0cdbdd05084a8219bc003a34670472f198cf91e5f6402cede2cb1094b7bfd98d.yml +openapi_spec_hash: d337c89146f41fa215560bb5aef2e4ec config_hash: 249ee22f294858ab0971b8379f7cb519 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 caed3c95..3c5b235f 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 @@ -25,7 +25,7 @@ private constructor( private val position: JsonField, private val timing: JsonField, private val input: JsonField, - private val type: JsonField, + private val type: JsonValue, private val encoding: JsonField, private val transformation: JsonField>, private val additionalProperties: MutableMap, @@ -38,7 +38,7 @@ private constructor( position: JsonField = JsonMissing.of(), @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing input: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("encoding") @ExcludeMissing encoding: JsonField = JsonMissing.of(), @JsonProperty("transformation") @ExcludeMissing @@ -69,10 +69,15 @@ private constructor( fun input(): String = input.getRequired("input") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * The input path can be included in the layer as either `i-{input}` or @@ -87,7 +92,10 @@ private constructor( /** * Array of transformations to be applied to the overlay image. Supported transformations - * depends on the base/parent asset. + * 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). @@ -116,13 +124,6 @@ private constructor( */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input - /** - * 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 [encoding]. * @@ -159,7 +160,6 @@ private constructor( * The following fields are required: * ```java * .input() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -171,7 +171,7 @@ private constructor( private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var input: JsonField? = null - private var type: 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() @@ -220,15 +220,19 @@ private constructor( */ fun input(input: JsonField) = apply { this.input = input } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * The input path can be included in the layer as either `i-{input}` or @@ -249,7 +253,10 @@ private constructor( /** * Array of transformations to be applied to the overlay image. Supported transformations - * depends on the base/parent asset. + * 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)) @@ -304,7 +311,6 @@ private constructor( * The following fields are required: * ```java * .input() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -314,7 +320,7 @@ private constructor( position, timing, checkRequired("input", input), - checkRequired("type", type), + type, encoding, (transformation ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -331,7 +337,11 @@ private constructor( position().ifPresent { it.validate() } timing().ifPresent { it.validate() } input() - type().validate() + _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 @@ -355,131 +365,10 @@ private constructor( (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (input.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("image")) 1 else 0 } + (encoding.asKnown().getOrNull()?.validity() ?: 0) + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - 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 IMAGE = of("image") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMAGE - } - - /** - * 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 { - IMAGE, - /** 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) { - IMAGE -> Value.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) { - IMAGE -> Known.IMAGE - 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 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 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 7f333a9c..51a9db0f 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 @@ -20,7 +20,8 @@ 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. + * 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) 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 188bd09c..42f5e18e 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 @@ -55,7 +55,8 @@ private constructor( /** * 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. + * `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). @@ -65,7 +66,8 @@ 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. + * `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). @@ -144,7 +146,8 @@ private constructor( /** * 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. + * `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)) @@ -165,7 +168,8 @@ 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. + * `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)) @@ -419,7 +423,8 @@ private constructor( /** * 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. + * `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) @@ -590,7 +595,8 @@ 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. + * `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) 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 04d5cb24..882fbd6c 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 @@ -6,7 +6,6 @@ import 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 @@ -25,7 +24,7 @@ private constructor( private val position: JsonField, private val timing: JsonField, private val color: JsonField, - private val type: JsonField, + private val type: JsonValue, private val transformation: JsonField>, private val additionalProperties: MutableMap, ) { @@ -37,7 +36,7 @@ private constructor( position: JsonField = JsonMissing.of(), @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("transformation") @ExcludeMissing transformation: JsonField> = JsonMissing.of(), @@ -69,14 +68,22 @@ private constructor( fun color(): String = color.getRequired("color") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Control width and height of the solid color overlay. Supported transformations depend on the - * base/parent asset. + * 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). @@ -105,13 +112,6 @@ private constructor( */ @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - /** - * 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 [transformation]. * @@ -141,7 +141,6 @@ private constructor( * The following fields are required: * ```java * .color() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -153,7 +152,7 @@ private constructor( private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var color: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("solidColor") private var transformation: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -205,19 +204,26 @@ private constructor( */ fun color(color: JsonField) = apply { this.color = color } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + 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. + * 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)) @@ -273,7 +279,6 @@ private constructor( * The following fields are required: * ```java * .color() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -283,7 +288,7 @@ private constructor( position, timing, checkRequired("color", color), - checkRequired("type", type), + type, (transformation ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -299,7 +304,11 @@ private constructor( position().ifPresent { it.validate() } timing().ifPresent { it.validate() } color() - type().validate() + _type().let { + if (it != JsonValue.from("solidColor")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } transformation().ifPresent { it.forEach { it.validate() } } validated = true } @@ -322,130 +331,9 @@ private constructor( (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (color.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("solidColor")) 1 else 0 } + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - 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 SOLID_COLOR = of("solidColor") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - SOLID_COLOR - } - - /** - * 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 { - SOLID_COLOR, - /** 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) { - SOLID_COLOR -> Value.SOLID_COLOR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - SOLID_COLOR -> Known.SOLID_COLOR - 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 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 fa15ed77..8d69770f 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 @@ -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 @@ -52,7 +51,8 @@ private constructor( ) : this(alpha, background, gradient, height, radius, width, mutableMapOf()) /** - * Alpha transparency level + * 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). @@ -60,7 +60,8 @@ private constructor( fun alpha(): Optional = alpha.getOptional("alpha") /** - * Background color + * 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). @@ -68,7 +69,9 @@ private constructor( fun background(): Optional = background.getOptional("background") /** - * Gradient effect for the overlay + * 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). @@ -76,7 +79,9 @@ private constructor( fun gradient(): Optional = gradient.getOptional("gradient") /** - * Height of the solid color overlay + * 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). @@ -84,7 +89,8 @@ private constructor( fun height(): Optional = height.getOptional("height") /** - * Corner radius of the solid color overlay + * 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). @@ -92,7 +98,9 @@ private constructor( fun radius(): Optional = radius.getOptional("radius") /** - * Width of the solid color overlay + * 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). @@ -186,7 +194,10 @@ private constructor( solidColorOverlayTransformation.additionalProperties.toMutableMap() } - /** Alpha transparency level */ + /** + * Specifies the transparency level of the solid color overlay. Accepts integers from `1` to + * `9`. + */ fun alpha(alpha: Double) = alpha(JsonField.of(alpha)) /** @@ -197,7 +208,10 @@ private constructor( */ fun alpha(alpha: JsonField) = apply { this.alpha = alpha } - /** Background color */ + /** + * 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)) /** @@ -209,7 +223,11 @@ private constructor( */ fun background(background: JsonField) = apply { this.background = background } - /** Gradient effect for the overlay */ + /** + * 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)) /** @@ -221,14 +239,17 @@ private constructor( */ fun gradient(gradient: JsonField) = apply { this.gradient = gradient } - /** Alias for calling [gradient] with `Gradient.ofUnionMember0(unionMember0)`. */ - fun gradient(unionMember0: Gradient.UnionMember0) = - gradient(Gradient.ofUnionMember0(unionMember0)) + /** 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)) - /** Height of the solid color overlay */ + /** + * 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)) /** @@ -245,7 +266,10 @@ private constructor( /** Alias for calling [height] with `Height.ofString(string)`. */ fun height(string: String) = height(Height.ofString(string)) - /** Corner radius of the solid color overlay */ + /** + * 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)) /** @@ -259,10 +283,14 @@ private constructor( /** Alias for calling [radius] with `Radius.ofNumber(number)`. */ fun radius(number: Double) = radius(Radius.ofNumber(number)) - /** Alias for calling [radius] with `Radius.ofUnionMember1(unionMember1)`. */ - fun radius(unionMember1: Radius.UnionMember1) = radius(Radius.ofUnionMember1(unionMember1)) + /** Alias for calling [radius] with `Radius.ofMax()`. */ + fun radiusMax() = radius(Radius.ofMax()) - /** Width of the solid color overlay */ + /** + * 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)) /** @@ -353,25 +381,29 @@ private constructor( (radius.asKnown().getOrNull()?.validity() ?: 0) + (width.asKnown().getOrNull()?.validity() ?: 0) - /** Gradient effect for the overlay */ + /** + * 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 unionMember0: UnionMember0? = null, + private val true_: JsonValue? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun true_(): Optional = Optional.ofNullable(true_) fun string(): Optional = Optional.ofNullable(string) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTrue(): Boolean = true_ != null fun isString(): Boolean = string != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTrue(): JsonValue = true_.getOrThrow("true_") fun asString(): String = string.getOrThrow("string") @@ -379,7 +411,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + true_ != null -> visitor.visitTrue(true_) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -393,8 +425,14 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } } override fun visitString(string: String) {} @@ -421,8 +459,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -435,14 +473,14 @@ private constructor( return true } - return other is Gradient && unionMember0 == other.unionMember0 && string == other.string + return other is Gradient && true_ == other.true_ && string == other.string } - override fun hashCode(): Int = Objects.hash(unionMember0, string) + override fun hashCode(): Int = Objects.hash(true_, string) override fun toString(): String = when { - unionMember0 != null -> "Gradient{unionMember0=$unionMember0}" + true_ != null -> "Gradient{true_=$true_}" string != null -> "Gradient{string=$string}" _json != null -> "Gradient{_unknown=$_json}" else -> throw IllegalStateException("Invalid Gradient") @@ -450,8 +488,7 @@ private constructor( companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Gradient(unionMember0 = unionMember0) + @JvmStatic fun ofTrue() = Gradient(true_ = JsonValue.from(true)) @JvmStatic fun ofString(string: String) = Gradient(string = string) } @@ -461,7 +498,7 @@ private constructor( */ interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTrue(true_: JsonValue): T fun visitString(string: String): T @@ -487,9 +524,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Gradient(unionMember0 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Gradient(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { Gradient(string = it, _json = json) }, @@ -518,138 +555,20 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) + 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") } } } - - class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) - } - - /** An enum containing [UnionMember0]'s known values. */ - enum class Known { - TRUE - } - - /** - * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } - /** Height of the solid color overlay */ + /** + * 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 @@ -817,34 +736,37 @@ private constructor( } } - /** Corner radius of the solid color overlay */ + /** + * 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 unionMember1: UnionMember1? = null, + private val max: JsonValue? = null, private val _json: JsonValue? = null, ) { fun number(): Optional = Optional.ofNullable(number) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun max(): Optional = Optional.ofNullable(max) fun isNumber(): Boolean = number != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isMax(): Boolean = max != null fun asNumber(): Double = number.getOrThrow("number") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asMax(): JsonValue = max.getOrThrow("max") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { number != null -> visitor.visitNumber(number) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + max != null -> visitor.visitMax(max) else -> visitor.unknown(_json) } @@ -859,8 +781,12 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) {} - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() + override fun visitMax(max: JsonValue) { + max.let { + if (it != JsonValue.from("max")) { + throw ImageKitInvalidDataException("'max' is invalid, received $it") + } + } } } ) @@ -887,8 +813,8 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) = 1 - override fun visitUnionMember1(unionMember1: UnionMember1) = - unionMember1.validity() + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -899,15 +825,15 @@ private constructor( return true } - return other is Radius && number == other.number && unionMember1 == other.unionMember1 + return other is Radius && number == other.number && max == other.max } - override fun hashCode(): Int = Objects.hash(number, unionMember1) + override fun hashCode(): Int = Objects.hash(number, max) override fun toString(): String = when { number != null -> "Radius{number=$number}" - unionMember1 != null -> "Radius{unionMember1=$unionMember1}" + max != null -> "Radius{max=$max}" _json != null -> "Radius{_unknown=$_json}" else -> throw IllegalStateException("Invalid Radius") } @@ -916,8 +842,7 @@ private constructor( @JvmStatic fun ofNumber(number: Double) = Radius(number = number) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Radius(unionMember1 = unionMember1) + @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]. */ @@ -925,7 +850,7 @@ private constructor( fun visitNumber(number: Double): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitMax(max: JsonValue): T /** * Maps an unknown variant of [Radius] to a value of type [T]. @@ -949,9 +874,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Radius(unionMember1 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Radius(max = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { Radius(number = it, _json = json) }, @@ -981,140 +906,19 @@ private constructor( ) { when { value.number != null -> generator.writeObject(value.number) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.max != null -> generator.writeObject(value.max) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Radius") } } } - - class UnionMember1 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MAX = of("max") - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - /** An enum containing [UnionMember1]'s known values. */ - enum class Known { - MAX - } - - /** - * An enum containing [UnionMember1]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember1] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAX, - /** - * An enum member indicating that [UnionMember1] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAX -> Value.MAX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - MAX -> Known.MAX - else -> throw ImageKitInvalidDataException("Unknown UnionMember1: $value") - } - - /** - * Returns this class 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(): UnionMember1 = 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 UnionMember1 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } - /** Width of the solid color overlay */ + /** + * 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 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 d0fe7069..09f3b4ce 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 @@ -19,7 +19,10 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Options for generating ImageKit URLs with transformations */ +/** + * Options for generating ImageKit URLs with transformations. See the + * [Transformations guide](https://imagekit.io/docs/transformations). + */ class SrcOptions private constructor( private val src: JsonField, @@ -86,7 +89,8 @@ private constructor( /** * 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. + * 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). @@ -97,7 +101,8 @@ private constructor( /** * 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`. + * 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). @@ -245,7 +250,8 @@ private constructor( /** * 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. + * chained transformations. See + * [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). */ fun transformation(transformation: List) = transformation(JsonField.of(transformation)) @@ -276,7 +282,8 @@ private constructor( /** * 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`. + * set this to `path`. Learn more in the + * [Transformations guide](https://imagekit.io/docs/transformations). */ fun transformationPosition(transformationPosition: TransformationPosition) = transformationPosition(JsonField.of(transformationPosition)) 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 index 2413aa27..f9aa05d5 100644 --- 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 @@ -7,7 +7,10 @@ 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 */ +/** + * Available streaming resolutions for + * [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) + */ class StreamingResolution @JsonCreator private constructor(private val value: JsonField) : Enum { 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 9f568e8c..6a0485c3 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 @@ -25,7 +25,7 @@ private constructor( private val position: JsonField, private val timing: JsonField, private val input: JsonField, - private val type: JsonField, + private val type: JsonValue, private val encoding: JsonField, private val transformation: JsonField>, private val additionalProperties: MutableMap, @@ -38,7 +38,7 @@ private constructor( position: JsonField = JsonMissing.of(), @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing input: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("encoding") @ExcludeMissing encoding: JsonField = JsonMissing.of(), @JsonProperty("transformation") @ExcludeMissing @@ -69,10 +69,15 @@ private constructor( fun input(): String = input.getRequired("input") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * The input path can be included in the layer as either `i-{input}` or @@ -86,7 +91,8 @@ private constructor( fun encoding(): Optional = encoding.getOptional("encoding") /** - * Control styling of the subtitle. + * 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). @@ -115,13 +121,6 @@ private constructor( */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input - /** - * 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 [encoding]. * @@ -158,7 +157,6 @@ private constructor( * The following fields are required: * ```java * .input() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -170,7 +168,7 @@ private constructor( private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var input: JsonField? = null - private var type: 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() @@ -219,15 +217,19 @@ private constructor( */ fun input(input: JsonField) = apply { this.input = input } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * The input path can be included in the layer as either `i-{input}` or @@ -246,7 +248,10 @@ private constructor( */ fun encoding(encoding: JsonField) = apply { this.encoding = encoding } - /** Control styling of the subtitle. */ + /** + * 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)) @@ -300,7 +305,6 @@ private constructor( * The following fields are required: * ```java * .input() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -310,7 +314,7 @@ private constructor( position, timing, checkRequired("input", input), - checkRequired("type", type), + type, encoding, (transformation ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -327,7 +331,11 @@ private constructor( position().ifPresent { it.validate() } timing().ifPresent { it.validate() } input() - type().validate() + _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 @@ -351,131 +359,10 @@ private constructor( (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (input.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("subtitle")) 1 else 0 } + (encoding.asKnown().getOrNull()?.validity() ?: 0) + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - 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 SUBTITLE = of("subtitle") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - SUBTITLE - } - - /** - * 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 { - SUBTITLE, - /** 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) { - SUBTITLE -> Value.SUBTITLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - SUBTITLE -> Known.SUBTITLE - 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 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 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 5fef0b6a..11c122df 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 @@ -6,28 +6,22 @@ import 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 +/** + * 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, @@ -35,7 +29,7 @@ private constructor( private val fontFamily: JsonField, private val fontOutline: JsonField, private val fontShadow: JsonField, - private val fontSize: JsonField, + private val fontSize: JsonField, private val typography: JsonField, private val additionalProperties: MutableMap, ) { @@ -55,7 +49,7 @@ private constructor( @JsonProperty("fontShadow") @ExcludeMissing fontShadow: JsonField = JsonMissing.of(), - @JsonProperty("fontSize") @ExcludeMissing fontSize: JsonField = JsonMissing.of(), + @JsonProperty("fontSize") @ExcludeMissing fontSize: JsonField = JsonMissing.of(), @JsonProperty("typography") @ExcludeMissing typography: JsonField = JsonMissing.of(), @@ -71,7 +65,11 @@ private constructor( ) /** - * Background color for subtitles + * 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). @@ -79,7 +77,11 @@ private constructor( fun background(): Optional = background.getOptional("background") /** - * Text color for subtitles + * 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). @@ -87,7 +89,8 @@ private constructor( fun color(): Optional = color.getOptional("color") /** - * Font family for subtitles + * 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). @@ -95,7 +98,14 @@ private constructor( fun fontFamily(): Optional = fontFamily.getOptional("fontFamily") /** - * Font outline for subtitles + * 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). @@ -103,7 +113,14 @@ private constructor( fun fontOutline(): Optional = fontOutline.getOptional("fontOutline") /** - * Font shadow for subtitles + * 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). @@ -111,15 +128,22 @@ private constructor( fun fontShadow(): Optional = fontShadow.getOptional("fontShadow") /** - * Font size for subtitles + * 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") + fun fontSize(): Optional = fontSize.getOptional("fontSize") /** - * Typography style for subtitles + * 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). @@ -166,7 +190,7 @@ private constructor( * * Unlike [fontSize], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("fontSize") @ExcludeMissing fun _fontSize(): JsonField = fontSize + @JsonProperty("fontSize") @ExcludeMissing fun _fontSize(): JsonField = fontSize /** * Returns the raw JSON value of [typography]. @@ -206,7 +230,7 @@ private constructor( 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 fontSize: JsonField = JsonMissing.of() private var typography: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -222,7 +246,13 @@ private constructor( additionalProperties = subtitleOverlayTransformation.additionalProperties.toMutableMap() } - /** Background color for subtitles */ + /** + * 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)) /** @@ -234,7 +264,13 @@ private constructor( */ fun background(background: JsonField) = apply { this.background = background } - /** Text color for subtitles */ + /** + * 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)) /** @@ -245,7 +281,10 @@ private constructor( */ fun color(color: JsonField) = apply { this.color = color } - /** Font family for subtitles */ + /** + * 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)) /** @@ -257,7 +296,16 @@ private constructor( */ fun fontFamily(fontFamily: JsonField) = apply { this.fontFamily = fontFamily } - /** Font outline for subtitles */ + /** + * 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)) /** @@ -269,7 +317,16 @@ private constructor( */ fun fontOutline(fontOutline: JsonField) = apply { this.fontOutline = fontOutline } - /** Font shadow for subtitles */ + /** + * 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)) /** @@ -281,25 +338,29 @@ private constructor( */ fun fontShadow(fontShadow: JsonField) = apply { this.fontShadow = fontShadow } - /** Font size for subtitles */ - fun fontSize(fontSize: FontSize) = fontSize(JsonField.of(fontSize)) + /** + * 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 [FontSize] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 } - - /** Alias for calling [fontSize] with `FontSize.ofNumber(number)`. */ - fun fontSize(number: Double) = fontSize(FontSize.ofNumber(number)) + fun fontSize(fontSize: JsonField) = apply { this.fontSize = fontSize } - /** Alias for calling [fontSize] with `FontSize.ofString(string)`. */ - fun fontSize(string: String) = fontSize(FontSize.ofString(string)) - - /** Typography style for subtitles */ + /** + * 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)) /** @@ -360,7 +421,7 @@ private constructor( fontFamily() fontOutline() fontShadow() - fontSize().ifPresent { it.validate() } + fontSize() typography().ifPresent { it.validate() } validated = true } @@ -385,180 +446,16 @@ private constructor( (if (fontFamily.asKnown().isPresent) 1 else 0) + (if (fontOutline.asKnown().isPresent) 1 else 0) + (if (fontShadow.asKnown().isPresent) 1 else 0) + - (fontSize.asKnown().getOrNull()?.validity() ?: 0) + + (if (fontSize.asKnown().isPresent) 1 else 0) + (typography.asKnown().getOrNull()?.validity() ?: 0) - /** Font size for subtitles */ - @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") - } - } - } - } - - /** Typography style for subtitles */ + /** + * 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 { /** 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 6d37116c..6bd7dfef 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 @@ -25,7 +25,7 @@ private constructor( private val position: JsonField, private val timing: JsonField, private val text: JsonField, - private val type: JsonField, + private val type: JsonValue, private val encoding: JsonField, private val transformation: JsonField>, private val additionalProperties: MutableMap, @@ -38,7 +38,7 @@ private constructor( position: JsonField = JsonMissing.of(), @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("encoding") @ExcludeMissing encoding: JsonField = JsonMissing.of(), @JsonProperty("transformation") @ExcludeMissing @@ -70,10 +70,15 @@ private constructor( fun text(): String = text.getRequired("text") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Text can be included in the layer as either `i-{input}` (plain text) or @@ -87,7 +92,8 @@ private constructor( fun encoding(): Optional = encoding.getOptional("encoding") /** - * Control styling of the text overlay. + * 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). @@ -116,13 +122,6 @@ private constructor( */ @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - /** - * 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 [encoding]. * @@ -159,7 +158,6 @@ private constructor( * The following fields are required: * ```java * .text() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -171,7 +169,7 @@ private constructor( private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var text: JsonField? = null - private var type: 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() @@ -223,15 +221,19 @@ private constructor( */ fun text(text: JsonField) = apply { this.text = text } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * Text can be included in the layer as either `i-{input}` (plain text) or @@ -250,7 +252,10 @@ private constructor( */ fun encoding(encoding: JsonField) = apply { this.encoding = encoding } - /** Control styling of the text overlay. */ + /** + * 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)) @@ -304,7 +309,6 @@ private constructor( * The following fields are required: * ```java * .text() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -314,7 +318,7 @@ private constructor( position, timing, checkRequired("text", text), - checkRequired("type", type), + type, encoding, (transformation ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -331,7 +335,11 @@ private constructor( position().ifPresent { it.validate() } timing().ifPresent { it.validate() } text() - type().validate() + _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 @@ -355,131 +363,10 @@ private constructor( (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + (encoding.asKnown().getOrNull()?.validity() ?: 0) + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - 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") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TEXT - } - - /** - * 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, - /** 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 - 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() - } - /** * 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 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 c8438549..c29f846b 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 @@ -41,7 +41,7 @@ private constructor( private val padding: JsonField, private val radius: JsonField, private val rotation: JsonField, - private val typography: JsonField, + private val typography: JsonField, private val width: JsonField, private val additionalProperties: MutableMap, ) { @@ -69,7 +69,7 @@ private constructor( @JsonProperty("rotation") @ExcludeMissing rotation: JsonField = JsonMissing.of(), @JsonProperty("typography") @ExcludeMissing - typography: JsonField = JsonMissing.of(), + typography: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), ) : this( alpha, @@ -124,7 +124,10 @@ private constructor( /** * Specifies the font family of the overlaid text. Choose from the supported fonts list or use a - * custom font. + * 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). @@ -149,7 +152,10 @@ private constructor( fun innerAlignment(): Optional = innerAlignment.getOptional("innerAlignment") /** - * Specifies the line height of the text overlay. + * 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). @@ -185,18 +191,20 @@ private constructor( fun rotation(): Optional = rotation.getOptional("rotation") /** - * Specifies the typography style of the text. Supported values: `b` for bold, `i` for italics, - * and `b_i` for bold with italics. + * 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") + 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`. + * 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). @@ -289,9 +297,7 @@ private constructor( * * Unlike [typography], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("typography") - @ExcludeMissing - fun _typography(): JsonField = typography + @JsonProperty("typography") @ExcludeMissing fun _typography(): JsonField = typography /** * Returns the raw JSON value of [width]. @@ -334,7 +340,7 @@ private constructor( 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 typography: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -412,7 +418,10 @@ private constructor( /** * Specifies the font family of the overlaid text. Choose from the supported fonts list or - * use a custom font. + * 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)) @@ -461,7 +470,12 @@ private constructor( this.innerAlignment = innerAlignment } - /** Specifies the line height of the text overlay. */ + /** + * 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)) /** @@ -517,8 +531,8 @@ private constructor( /** Alias for calling [radius] with `Radius.ofNumber(number)`. */ fun radius(number: Double) = radius(Radius.ofNumber(number)) - /** Alias for calling [radius] with `Radius.ofUnionMember1(unionMember1)`. */ - fun radius(unionMember1: Radius.UnionMember1) = radius(Radius.ofUnionMember1(unionMember1)) + /** 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 @@ -542,24 +556,27 @@ private constructor( fun rotation(string: String) = rotation(Rotation.ofString(string)) /** - * Specifies the typography style of the text. Supported values: `b` for bold, `i` for - * italics, and `b_i` for bold with italics. + * 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: Typography) = typography(JsonField.of(typography)) + 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 [Typography] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported 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 } + 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`. + * 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)) @@ -638,7 +655,7 @@ private constructor( padding().ifPresent { it.validate() } radius().ifPresent { it.validate() } rotation().ifPresent { it.validate() } - typography().ifPresent { it.validate() } + typography() width().ifPresent { it.validate() } validated = true } @@ -669,7 +686,7 @@ private constructor( (padding.asKnown().getOrNull()?.validity() ?: 0) + (radius.asKnown().getOrNull()?.validity() ?: 0) + (rotation.asKnown().getOrNull()?.validity() ?: 0) + - (typography.asKnown().getOrNull()?.validity() ?: 0) + + (if (typography.asKnown().isPresent) 1 else 0) + (width.asKnown().getOrNull()?.validity() ?: 0) /** Flip the text overlay horizontally, vertically, or both. */ @@ -1123,7 +1140,12 @@ private constructor( override fun toString() = value.toString() } - /** Specifies the line height of the text overlay. */ + /** + * 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 @@ -1476,28 +1498,28 @@ private constructor( class Radius private constructor( private val number: Double? = null, - private val unionMember1: UnionMember1? = null, + private val max: JsonValue? = null, private val _json: JsonValue? = null, ) { fun number(): Optional = Optional.ofNullable(number) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun max(): Optional = Optional.ofNullable(max) fun isNumber(): Boolean = number != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isMax(): Boolean = max != null fun asNumber(): Double = number.getOrThrow("number") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asMax(): JsonValue = max.getOrThrow("max") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { number != null -> visitor.visitNumber(number) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + max != null -> visitor.visitMax(max) else -> visitor.unknown(_json) } @@ -1512,8 +1534,12 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) {} - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() + override fun visitMax(max: JsonValue) { + max.let { + if (it != JsonValue.from("max")) { + throw ImageKitInvalidDataException("'max' is invalid, received $it") + } + } } } ) @@ -1540,8 +1566,8 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) = 1 - override fun visitUnionMember1(unionMember1: UnionMember1) = - unionMember1.validity() + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -1552,15 +1578,15 @@ private constructor( return true } - return other is Radius && number == other.number && unionMember1 == other.unionMember1 + return other is Radius && number == other.number && max == other.max } - override fun hashCode(): Int = Objects.hash(number, unionMember1) + override fun hashCode(): Int = Objects.hash(number, max) override fun toString(): String = when { number != null -> "Radius{number=$number}" - unionMember1 != null -> "Radius{unionMember1=$unionMember1}" + max != null -> "Radius{max=$max}" _json != null -> "Radius{_unknown=$_json}" else -> throw IllegalStateException("Invalid Radius") } @@ -1569,8 +1595,7 @@ private constructor( @JvmStatic fun ofNumber(number: Double) = Radius(number = number) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Radius(unionMember1 = unionMember1) + @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]. */ @@ -1578,7 +1603,7 @@ private constructor( fun visitNumber(number: Double): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitMax(max: JsonValue): T /** * Maps an unknown variant of [Radius] to a value of type [T]. @@ -1602,9 +1627,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Radius(unionMember1 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Radius(max = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { Radius(number = it, _json = json) }, @@ -1634,137 +1659,12 @@ private constructor( ) { when { value.number != null -> generator.writeObject(value.number) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.max != null -> generator.writeObject(value.max) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Radius") } } } - - class UnionMember1 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MAX = of("max") - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - /** An enum containing [UnionMember1]'s known values. */ - enum class Known { - MAX - } - - /** - * An enum containing [UnionMember1]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember1] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAX, - /** - * An enum member indicating that [UnionMember1] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAX -> Value.MAX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - MAX -> Known.MAX - else -> throw ImageKitInvalidDataException("Unknown UnionMember1: $value") - } - - /** - * Returns this class 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(): UnionMember1 = 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 UnionMember1 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } /** @@ -1940,149 +1840,11 @@ private constructor( } } - /** - * Specifies the typography style of the text. Supported values: `b` for bold, `i` for italics, - * and `b_i` for bold with italics. - */ - 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() - } - /** * 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`. + * 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) 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 ef2d67b6..ee1ca86e 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 @@ -34,12 +34,14 @@ 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. + * 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, @@ -100,6 +102,7 @@ private constructor( @JsonProperty("aiDropShadow") @ExcludeMissing aiDropShadow: JsonField = JsonMissing.of(), + @JsonProperty("aiEdit") @ExcludeMissing aiEdit: JsonField = JsonMissing.of(), @JsonProperty("aiRemoveBackground") @ExcludeMissing aiRemoveBackground: JsonField = JsonMissing.of(), @@ -188,6 +191,7 @@ private constructor( ) : this( aiChangeBackground, aiDropShadow, + aiEdit, aiRemoveBackground, aiRemoveBackgroundExternal, aiRetouch, @@ -243,7 +247,8 @@ private constructor( /** * 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. + * 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). @@ -255,7 +260,8 @@ private constructor( * 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. + * 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). @@ -263,7 +269,18 @@ private constructor( fun aiDropShadow(): Optional = aiDropShadow.getOptional("aiDropShadow") /** - * Applies ImageKit's in-house background removal. Supported inside overlay. + * 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). @@ -273,7 +290,8 @@ private constructor( /** * 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. + * 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). @@ -283,6 +301,7 @@ private constructor( /** * 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). @@ -290,7 +309,8 @@ private constructor( fun aiRetouch(): Optional = aiRetouch.getOptional("aiRetouch") /** - * Upscales images beyond their original dimensions using AI. Not supported inside overlay. + * 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). @@ -300,7 +320,8 @@ private constructor( /** * 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. + * 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). @@ -310,7 +331,8 @@ private constructor( /** * 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`. + * `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). @@ -318,7 +340,8 @@ private constructor( fun aspectRatio(): Optional = aspectRatio.getOptional("aspectRatio") /** - * Specifies the audio codec, e.g., `aac`, `opus`, or `none`. + * 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). @@ -328,11 +351,14 @@ private constructor( /** * Specifies the background to be used in conjunction with certain cropping strategies when * resizing an image. - * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. - * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. + * - 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}]`. + * `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). @@ -341,7 +367,8 @@ private constructor( /** * Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, or an - * expression like `bl-10`. + * 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). @@ -350,7 +377,8 @@ private constructor( /** * 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`. + * (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). @@ -358,7 +386,8 @@ private constructor( fun border(): Optional = border.getOptional("border") /** - * Indicates whether the output image should retain the original color profile. + * 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). @@ -366,7 +395,8 @@ private constructor( fun colorProfile(): Optional = colorProfile.getOptional("colorProfile") /** - * Automatically enhances the contrast of an image (contrast stretch). + * 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). @@ -375,7 +405,8 @@ private constructor( contrastStretch.getOptional("contrastStretch") /** - * Crop modes for image resizing + * 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). @@ -383,7 +414,8 @@ private constructor( fun crop(): Optional = crop.getOptional("crop") /** - * Additional crop modes for image resizing + * 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). @@ -391,7 +423,8 @@ private constructor( fun cropMode(): Optional = cropMode.getOptional("cropMode") /** - * Specifies a fallback image if the resource is not found, e.g., a URL or file path. + * 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). @@ -400,7 +433,7 @@ private constructor( /** * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) - * calculation. + * 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). @@ -410,7 +443,7 @@ private constructor( /** * 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. + * 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). @@ -419,7 +452,8 @@ private constructor( /** * 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. + * 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). @@ -428,7 +462,8 @@ private constructor( /** * Flips or mirrors an image either horizontally, vertically, or both. Acceptable values: `h` - * (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_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). @@ -436,8 +471,13 @@ private constructor( fun flip(): Optional = flip.getOptional("flip") /** - * This parameter can be used with pad resize, maintain ratio, or extract crop to modify the - * padding or cropping behavior. + * 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). @@ -448,7 +488,9 @@ private constructor( * 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. + * 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). @@ -457,7 +499,8 @@ private constructor( /** * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a - * string for a custom gradient. + * 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). @@ -465,7 +508,8 @@ private constructor( fun gradient(): Optional = gradient.getOptional("gradient") /** - * Enables a grayscale effect for images. + * 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). @@ -475,7 +519,9 @@ private constructor( /** * 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`). + * 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). @@ -483,7 +529,8 @@ private constructor( fun height(): Optional = height.getOptional("height") /** - * Specifies whether the output image (in JPEG or PNG) should be compressed losslessly. + * 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). @@ -492,7 +539,8 @@ private constructor( /** * By default, ImageKit removes all metadata during automatic image compression. Set this to - * true to preserve metadata. + * 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). @@ -500,7 +548,8 @@ private constructor( fun metadata(): Optional = metadata.getOptional("metadata") /** - * Named transformation reference + * 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). @@ -508,7 +557,8 @@ private constructor( fun named(): Optional = named.getOptional("named") /** - * Specifies the opacity level of the output image. + * 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). @@ -516,7 +566,8 @@ private constructor( fun opacity(): Optional = opacity.getOptional("opacity") /** - * If set to true, serves the original file without applying any transformations. + * 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). @@ -525,7 +576,8 @@ private constructor( /** * Specifies an overlay to be applied on the parent image or video. ImageKit supports overlays - * including images, text, videos, subtitles, and solid colors. + * 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). @@ -535,7 +587,8 @@ private constructor( /** * 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). + * 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). @@ -545,7 +598,8 @@ private constructor( /** * 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. + * 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). @@ -555,7 +609,8 @@ private constructor( /** * 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. + * 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). @@ -563,7 +618,8 @@ private constructor( fun quality(): Optional = quality.getOptional("quality") /** - * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular/oval shapes. + * 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). @@ -583,7 +639,8 @@ private constructor( * 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. + * 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). @@ -593,7 +650,8 @@ private constructor( /** * 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. + * 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). @@ -602,7 +660,8 @@ private constructor( /** * Sharpens the input image, highlighting edges and finer details. Pass `true` for default - * sharpening, or provide a numeric value for custom sharpening. + * 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). @@ -611,7 +670,8 @@ private constructor( /** * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. Arithmetic - * expressions are also supported. + * 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). @@ -620,7 +680,8 @@ private constructor( /** * An array of resolutions for adaptive bitrate streaming, e.g., - * [`240`, `360`, `480`, `720`, `1080`]. + * [`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). @@ -630,7 +691,8 @@ private constructor( /** * 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. + * 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). @@ -639,7 +701,8 @@ private constructor( /** * Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a default - * unsharp mask, or provide a string for a custom unsharp mask. + * 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). @@ -647,7 +710,8 @@ private constructor( fun unsharpMask(): Optional = unsharpMask.getOptional("unsharpMask") /** - * Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. + * 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). @@ -657,7 +721,9 @@ private constructor( /** * 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`). + * 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). @@ -665,7 +731,8 @@ private constructor( fun width(): Optional = width.getOptional("width") /** - * Focus using cropped image coordinates - X coordinate + * 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). @@ -673,7 +740,8 @@ private constructor( fun x(): Optional = x.getOptional("x") /** - * Focus using cropped image coordinates - X center coordinate + * 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). @@ -681,7 +749,8 @@ private constructor( fun xCenter(): Optional = xCenter.getOptional("xCenter") /** - * Focus using cropped image coordinates - Y coordinate + * 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). @@ -689,7 +758,8 @@ private constructor( fun y(): Optional = y.getOptional("y") /** - * Focus using cropped image coordinates - Y center coordinate + * 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). @@ -698,7 +768,8 @@ private constructor( /** * 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-. + * 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). @@ -724,6 +795,13 @@ private constructor( @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]. * @@ -1120,6 +1198,7 @@ private 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() @@ -1176,6 +1255,7 @@ private constructor( internal fun from(transformation: Transformation) = apply { aiChangeBackground = transformation.aiChangeBackground aiDropShadow = transformation.aiDropShadow + aiEdit = transformation.aiEdit aiRemoveBackground = transformation.aiRemoveBackground aiRemoveBackgroundExternal = transformation.aiRemoveBackgroundExternal aiRetouch = transformation.aiRetouch @@ -1231,7 +1311,8 @@ private constructor( /** * 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. + * overlay. See + * [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). */ fun aiChangeBackground(aiChangeBackground: String) = aiChangeBackground(JsonField.of(aiChangeBackground)) @@ -1251,7 +1332,8 @@ private constructor( * 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. + * 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)) @@ -1266,14 +1348,32 @@ private constructor( this.aiDropShadow = aiDropShadow } - /** Alias for calling [aiDropShadow] with `AiDropShadow.ofUnionMember0(unionMember0)`. */ - fun aiDropShadow(unionMember0: AiDropShadow.UnionMember0) = - aiDropShadow(AiDropShadow.ofUnionMember0(unionMember0)) + /** 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)) - /** Applies ImageKit's in-house background removal. Supported inside overlay. */ + /** + * 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)) @@ -1290,7 +1390,8 @@ private constructor( /** * 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. + * 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)) @@ -1308,7 +1409,7 @@ private constructor( /** * Performs AI-based retouching to improve faces or product shots. Not supported inside - * overlay. + * overlay. See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). */ fun aiRetouch(aiRetouch: AiRetouch) = aiRetouch(JsonField.of(aiRetouch)) @@ -1323,6 +1424,7 @@ private constructor( /** * 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)) @@ -1339,7 +1441,8 @@ private constructor( * 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. + * 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)) @@ -1357,7 +1460,8 @@ private constructor( /** * 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`. + * 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)) @@ -1378,7 +1482,10 @@ private constructor( /** 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`. */ + /** + * 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)) /** @@ -1393,11 +1500,15 @@ private constructor( /** * Specifies the background to be used in conjunction with certain cropping strategies when * resizing an image. - * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. - * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. + * - 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)) @@ -1412,7 +1523,8 @@ private constructor( /** * Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, or an - * expression like `bl-10`. + * expression like `bl-10`. See + * [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). */ fun blur(blur: Double) = blur(JsonField.of(blur)) @@ -1427,7 +1539,8 @@ private constructor( /** * 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`. + * like `ih_div_20_FF00FF`. See + * [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). */ fun border(border: String) = border(JsonField.of(border)) @@ -1439,7 +1552,10 @@ private constructor( */ fun border(border: JsonField) = apply { this.border = border } - /** Indicates whether the output image should retain the original color profile. */ + /** + * 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)) /** @@ -1453,7 +1569,10 @@ private constructor( this.colorProfile = colorProfile } - /** Automatically enhances the contrast of an image (contrast stretch). */ + /** + * 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)) @@ -1468,7 +1587,10 @@ private constructor( this.contrastStretch = contrastStretch } - /** Crop modes for image resizing */ + /** + * 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)) /** @@ -1479,7 +1601,10 @@ private constructor( */ fun crop(crop: JsonField) = apply { this.crop = crop } - /** Additional crop modes for image resizing */ + /** + * 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)) /** @@ -1491,7 +1616,10 @@ private constructor( */ 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. */ + /** + * 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)) /** @@ -1507,7 +1635,7 @@ private constructor( /** * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) - * calculation. + * calculation. See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). */ fun dpr(dpr: Double) = dpr(JsonField.of(dpr)) @@ -1522,7 +1650,8 @@ private constructor( /** * 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. + * expressions are supported. See + * [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). */ fun duration(duration: Duration) = duration(JsonField.of(duration)) @@ -1543,7 +1672,8 @@ private constructor( /** * 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. + * 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)) @@ -1564,7 +1694,8 @@ private constructor( /** * Flips or mirrors an image either horizontally, vertically, or both. Acceptable values: - * `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. + * `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)) @@ -1577,8 +1708,13 @@ private constructor( fun flip(flip: JsonField) = apply { this.flip = flip } /** - * This parameter can be used with pad resize, maintain ratio, or extract crop to modify the - * padding or cropping behavior. + * 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)) @@ -1594,7 +1730,9 @@ private constructor( * 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. + * 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)) @@ -1608,7 +1746,8 @@ private constructor( /** * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide - * a string for a custom gradient. + * 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)) @@ -1621,14 +1760,16 @@ private constructor( */ fun gradient(gradient: JsonField) = apply { this.gradient = gradient } - /** Alias for calling [gradient] with `Gradient.ofUnionMember0(unionMember0)`. */ - fun gradient(unionMember0: Gradient.UnionMember0) = - gradient(Gradient.ofUnionMember0(unionMember0)) + /** 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. */ + /** + * 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)) /** @@ -1643,7 +1784,9 @@ private constructor( /** * 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`). + * 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)) @@ -1661,7 +1804,10 @@ private constructor( /** 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. */ + /** + * 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)) /** @@ -1675,7 +1821,8 @@ private constructor( /** * By default, ImageKit removes all metadata during automatic image compression. Set this to - * true to preserve metadata. + * true to preserve metadata. See + * [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). */ fun metadata(metadata: Boolean) = metadata(JsonField.of(metadata)) @@ -1688,7 +1835,10 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** Named transformation reference */ + /** + * Named transformation reference. See + * [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + */ fun named(named: String) = named(JsonField.of(named)) /** @@ -1699,7 +1849,10 @@ private constructor( */ fun named(named: JsonField) = apply { this.named = named } - /** Specifies the opacity level of the output image. */ + /** + * 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)) /** @@ -1710,7 +1863,10 @@ private constructor( */ fun opacity(opacity: JsonField) = apply { this.opacity = opacity } - /** If set to true, serves the original file without applying any transformations. */ + /** + * 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)) /** @@ -1724,7 +1880,8 @@ private constructor( /** * Specifies an overlay to be applied on the parent image or video. ImageKit supports - * overlays including images, text, videos, subtitles, and solid colors. + * 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)) @@ -1743,13 +1900,11 @@ private constructor( * Alias for calling [overlay] with the following: * ```java * TextOverlay.builder() - * .type(TextOverlay.Type.TEXT) * .text(text) * .build() * ``` */ - fun textOverlay(text: String) = - overlay(TextOverlay.builder().type(TextOverlay.Type.TEXT).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)) @@ -1758,13 +1913,11 @@ private constructor( * Alias for calling [overlay] with the following: * ```java * ImageOverlay.builder() - * .type(ImageOverlay.Type.IMAGE) * .input(input) * .build() * ``` */ - fun imageOverlay(input: String) = - overlay(ImageOverlay.builder().type(ImageOverlay.Type.IMAGE).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)) @@ -1773,13 +1926,11 @@ private constructor( * Alias for calling [overlay] with the following: * ```java * VideoOverlay.builder() - * .type(VideoOverlay.Type.VIDEO) * .input(input) * .build() * ``` */ - fun videoOverlay(input: String) = - overlay(VideoOverlay.builder().type(VideoOverlay.Type.VIDEO).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)) @@ -1788,15 +1939,11 @@ private constructor( * Alias for calling [overlay] with the following: * ```java * SubtitleOverlay.builder() - * .type(SubtitleOverlay.Type.SUBTITLE) * .input(input) * .build() * ``` */ - fun subtitleOverlay(input: String) = - overlay( - SubtitleOverlay.builder().type(SubtitleOverlay.Type.SUBTITLE).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)) @@ -1805,23 +1952,18 @@ private constructor( * Alias for calling [overlay] with the following: * ```java * SolidColorOverlay.builder() - * .type(SolidColorOverlay.Type.SOLID_COLOR) * .color(color) * .build() * ``` */ fun solidColorOverlay(color: String) = - overlay( - SolidColorOverlay.builder() - .type(SolidColorOverlay.Type.SOLID_COLOR) - .color(color) - .build() - ) + 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). + * 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)) @@ -1842,7 +1984,8 @@ private constructor( /** * 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. + * 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)) @@ -1858,7 +2001,8 @@ private constructor( /** * 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. + * 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)) @@ -1871,8 +2015,8 @@ private constructor( fun quality(quality: JsonField) = apply { this.quality = quality } /** - * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular/oval - * shapes. + * 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)) @@ -1887,8 +2031,8 @@ private constructor( /** Alias for calling [radius] with `Radius.ofNumber(number)`. */ fun radius(number: Double) = radius(Radius.ofNumber(number)) - /** Alias for calling [radius] with `Radius.ofUnionMember1(unionMember1)`. */ - fun radius(unionMember1: Radius.UnionMember1) = radius(Radius.ofUnionMember1(unionMember1)) + /** 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 @@ -1908,7 +2052,8 @@ private constructor( * 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. + * 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)) @@ -1930,7 +2075,8 @@ private constructor( /** * 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. + * 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)) @@ -1942,15 +2088,16 @@ private constructor( */ fun shadow(shadow: JsonField) = apply { this.shadow = shadow } - /** Alias for calling [shadow] with `Shadow.ofUnionMember0(unionMember0)`. */ - fun shadow(unionMember0: Shadow.UnionMember0) = shadow(Shadow.ofUnionMember0(unionMember0)) + /** 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. + * 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)) @@ -1962,16 +2109,16 @@ private constructor( */ fun sharpen(sharpen: JsonField) = apply { this.sharpen = sharpen } - /** Alias for calling [sharpen] with `Sharpen.ofUnionMember0(unionMember0)`. */ - fun sharpen(unionMember0: Sharpen.UnionMember0) = - sharpen(Sharpen.ofUnionMember0(unionMember0)) + /** 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. + * 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)) @@ -1994,7 +2141,8 @@ private constructor( /** * An array of resolutions for adaptive bitrate streaming, e.g., - * [`240`, `360`, `480`, `720`, `1080`]. + * [`240`, `360`, `480`, `720`, `1080`]. See + * [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). */ fun streamingResolutions(streamingResolutions: List) = streamingResolutions(JsonField.of(streamingResolutions)) @@ -2025,7 +2173,8 @@ private constructor( /** * 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. + * 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)) @@ -2037,15 +2186,16 @@ private constructor( */ fun trim(trim: JsonField) = apply { this.trim = trim } - /** Alias for calling [trim] with `Trim.ofUnionMember0(unionMember0)`. */ - fun trim(unionMember0: Trim.UnionMember0) = trim(Trim.ofUnionMember0(unionMember0)) + /** 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. + * 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)) @@ -2060,14 +2210,16 @@ private constructor( this.unsharpMask = unsharpMask } - /** Alias for calling [unsharpMask] with `UnsharpMask.ofUnionMember0(unionMember0)`. */ - fun unsharpMask(unionMember0: UnsharpMask.UnionMember0) = - unsharpMask(UnsharpMask.ofUnionMember0(unionMember0)) + /** 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`. */ + /** + * 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)) /** @@ -2082,7 +2234,9 @@ private constructor( /** * 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`). + * 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)) @@ -2100,7 +2254,10 @@ private constructor( /** Alias for calling [width] with `Width.ofString(string)`. */ fun width(string: String) = width(Width.ofString(string)) - /** Focus using cropped image coordinates - X coordinate */ + /** + * 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)) /** @@ -2117,7 +2274,10 @@ private constructor( /** Alias for calling [x] with `X.ofString(string)`. */ fun x(string: String) = x(X.ofString(string)) - /** Focus using cropped image coordinates - X center coordinate */ + /** + * 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)) /** @@ -2134,7 +2294,10 @@ private constructor( /** Alias for calling [xCenter] with `XCenter.ofString(string)`. */ fun xCenter(string: String) = xCenter(XCenter.ofString(string)) - /** Focus using cropped image coordinates - Y coordinate */ + /** + * 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)) /** @@ -2151,7 +2314,10 @@ private constructor( /** Alias for calling [y] with `Y.ofString(string)`. */ fun y(string: String) = y(Y.ofString(string)) - /** Focus using cropped image coordinates - Y center coordinate */ + /** + * 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)) /** @@ -2170,7 +2336,8 @@ private constructor( /** * 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-. + * 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)) @@ -2210,6 +2377,7 @@ private constructor( Transformation( aiChangeBackground, aiDropShadow, + aiEdit, aiRemoveBackground, aiRemoveBackgroundExternal, aiRetouch, @@ -2272,6 +2440,7 @@ private constructor( aiChangeBackground() aiDropShadow().ifPresent { it.validate() } + aiEdit() aiRemoveBackground().ifPresent { it.validate() } aiRemoveBackgroundExternal().ifPresent { it.validate() } aiRetouch().ifPresent { it.validate() } @@ -2341,6 +2510,7 @@ private constructor( 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) + @@ -2395,26 +2565,27 @@ private constructor( * 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. + * 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 unionMember0: UnionMember0? = null, + private val true_: JsonValue? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun true_(): Optional = Optional.ofNullable(true_) fun string(): Optional = Optional.ofNullable(string) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTrue(): Boolean = true_ != null fun isString(): Boolean = string != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTrue(): JsonValue = true_.getOrThrow("true_") fun asString(): String = string.getOrThrow("string") @@ -2422,7 +2593,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + true_ != null -> visitor.visitTrue(true_) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -2436,8 +2607,14 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } } override fun visitString(string: String) {} @@ -2464,8 +2641,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -2478,16 +2655,14 @@ private constructor( return true } - return other is AiDropShadow && - unionMember0 == other.unionMember0 && - string == other.string + return other is AiDropShadow && true_ == other.true_ && string == other.string } - override fun hashCode(): Int = Objects.hash(unionMember0, string) + override fun hashCode(): Int = Objects.hash(true_, string) override fun toString(): String = when { - unionMember0 != null -> "AiDropShadow{unionMember0=$unionMember0}" + true_ != null -> "AiDropShadow{true_=$true_}" string != null -> "AiDropShadow{string=$string}" _json != null -> "AiDropShadow{_unknown=$_json}" else -> throw IllegalStateException("Invalid AiDropShadow") @@ -2495,9 +2670,7 @@ private constructor( companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - AiDropShadow(unionMember0 = unionMember0) + @JvmStatic fun ofTrue() = AiDropShadow(true_ = JsonValue.from(true)) @JvmStatic fun ofString(string: String) = AiDropShadow(string = string) } @@ -2508,7 +2681,7 @@ private constructor( */ interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTrue(true_: JsonValue): T fun visitString(string: String): T @@ -2534,9 +2707,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - AiDropShadow(unionMember0 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { AiDropShadow(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { AiDropShadow(string = it, _json = json) }, @@ -2565,138 +2738,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) + 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") } } } - - class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) - } - - /** An enum containing [UnionMember0]'s known values. */ - enum class Known { - TRUE - } - - /** - * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } - /** Applies ImageKit's in-house background removal. Supported inside overlay. */ + /** + * 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 { @@ -2822,7 +2876,8 @@ private constructor( /** * 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. + * 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 @@ -2952,6 +3007,7 @@ private constructor( /** * 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 { @@ -3073,7 +3129,10 @@ private constructor( override fun toString() = value.toString() } - /** Upscales images beyond their original dimensions using AI. Not supported inside overlay. */ + /** + * 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 { /** @@ -3197,7 +3256,8 @@ private constructor( /** * 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. + * 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 { @@ -3323,7 +3383,8 @@ private constructor( /** * 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`. + * `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) @@ -3495,7 +3556,10 @@ private constructor( } } - /** Specifies the audio codec, e.g., `aac`, `opus`, or `none`. */ + /** + * 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 { /** @@ -3631,7 +3695,10 @@ private constructor( override fun toString() = value.toString() } - /** Automatically enhances the contrast of an image (contrast stretch). */ + /** + * 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 { @@ -3754,7 +3821,10 @@ private constructor( override fun toString() = value.toString() } - /** Crop modes for image resizing */ + /** + * 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 { /** @@ -3900,7 +3970,10 @@ private constructor( override fun toString() = value.toString() } - /** Additional crop modes for image resizing */ + /** + * 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 { /** @@ -4037,7 +4110,7 @@ private constructor( /** * 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. + * supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). */ @JsonDeserialize(using = Duration.Deserializer::class) @JsonSerialize(using = Duration.Serializer::class) @@ -4210,7 +4283,8 @@ private constructor( /** * 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. + * 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) @@ -4383,7 +4457,8 @@ private constructor( /** * Flips or mirrors an image either horizontally, vertically, or both. Acceptable values: `h` - * (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_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 { @@ -4528,7 +4603,9 @@ private constructor( * 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. + * 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 { @@ -4713,26 +4790,27 @@ private constructor( /** * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a - * string for a custom gradient. + * 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 unionMember0: UnionMember0? = null, + private val true_: JsonValue? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun true_(): Optional = Optional.ofNullable(true_) fun string(): Optional = Optional.ofNullable(string) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTrue(): Boolean = true_ != null fun isString(): Boolean = string != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTrue(): JsonValue = true_.getOrThrow("true_") fun asString(): String = string.getOrThrow("string") @@ -4740,7 +4818,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + true_ != null -> visitor.visitTrue(true_) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -4754,8 +4832,14 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } } override fun visitString(string: String) {} @@ -4782,8 +4866,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -4796,14 +4880,14 @@ private constructor( return true } - return other is Gradient && unionMember0 == other.unionMember0 && string == other.string + return other is Gradient && true_ == other.true_ && string == other.string } - override fun hashCode(): Int = Objects.hash(unionMember0, string) + override fun hashCode(): Int = Objects.hash(true_, string) override fun toString(): String = when { - unionMember0 != null -> "Gradient{unionMember0=$unionMember0}" + true_ != null -> "Gradient{true_=$true_}" string != null -> "Gradient{string=$string}" _json != null -> "Gradient{_unknown=$_json}" else -> throw IllegalStateException("Invalid Gradient") @@ -4811,8 +4895,7 @@ private constructor( companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Gradient(unionMember0 = unionMember0) + @JvmStatic fun ofTrue() = Gradient(true_ = JsonValue.from(true)) @JvmStatic fun ofString(string: String) = Gradient(string = string) } @@ -4822,7 +4905,7 @@ private constructor( */ interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTrue(true_: JsonValue): T fun visitString(string: String): T @@ -4848,9 +4931,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Gradient(unionMember0 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Gradient(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { Gradient(string = it, _json = json) }, @@ -4879,138 +4962,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) + 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") } } } - - class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) - } - - /** An enum containing [UnionMember0]'s known values. */ - enum class Known { - TRUE - } - - /** - * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } - /** Enables a grayscale effect for images. */ + /** + * 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 { /** @@ -5134,7 +5098,9 @@ private constructor( /** * 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`). + * 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) @@ -5306,7 +5272,8 @@ private constructor( /** * 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). + * 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) @@ -5475,35 +5442,36 @@ private constructor( } /** - * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular/oval shapes. + * 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 unionMember1: UnionMember1? = null, + private val max: JsonValue? = null, private val _json: JsonValue? = null, ) { fun number(): Optional = Optional.ofNullable(number) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun max(): Optional = Optional.ofNullable(max) fun isNumber(): Boolean = number != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isMax(): Boolean = max != null fun asNumber(): Double = number.getOrThrow("number") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asMax(): JsonValue = max.getOrThrow("max") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { number != null -> visitor.visitNumber(number) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + max != null -> visitor.visitMax(max) else -> visitor.unknown(_json) } @@ -5518,8 +5486,12 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) {} - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() + override fun visitMax(max: JsonValue) { + max.let { + if (it != JsonValue.from("max")) { + throw ImageKitInvalidDataException("'max' is invalid, received $it") + } + } } } ) @@ -5546,8 +5518,8 @@ private constructor( object : Visitor { override fun visitNumber(number: Double) = 1 - override fun visitUnionMember1(unionMember1: UnionMember1) = - unionMember1.validity() + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } override fun unknown(json: JsonValue?) = 0 } @@ -5558,15 +5530,15 @@ private constructor( return true } - return other is Radius && number == other.number && unionMember1 == other.unionMember1 + return other is Radius && number == other.number && max == other.max } - override fun hashCode(): Int = Objects.hash(number, unionMember1) + override fun hashCode(): Int = Objects.hash(number, max) override fun toString(): String = when { number != null -> "Radius{number=$number}" - unionMember1 != null -> "Radius{unionMember1=$unionMember1}" + max != null -> "Radius{max=$max}" _json != null -> "Radius{_unknown=$_json}" else -> throw IllegalStateException("Invalid Radius") } @@ -5575,8 +5547,7 @@ private constructor( @JvmStatic fun ofNumber(number: Double) = Radius(number = number) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Radius(unionMember1 = unionMember1) + @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]. */ @@ -5584,7 +5555,7 @@ private constructor( fun visitNumber(number: Double): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitMax(max: JsonValue): T /** * Maps an unknown variant of [Radius] to a value of type [T]. @@ -5608,9 +5579,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Radius(unionMember1 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Radius(max = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { Radius(number = it, _json = json) }, @@ -5640,144 +5611,20 @@ private constructor( ) { when { value.number != null -> generator.writeObject(value.number) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.max != null -> generator.writeObject(value.max) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Radius") } } } - - class UnionMember1 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MAX = of("max") - - @JvmStatic fun of(value: String) = UnionMember1(JsonField.of(value)) - } - - /** An enum containing [UnionMember1]'s known values. */ - enum class Known { - MAX - } - - /** - * An enum containing [UnionMember1]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember1] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAX, - /** - * An enum member indicating that [UnionMember1] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAX -> Value.MAX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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) { - MAX -> Known.MAX - else -> throw ImageKitInvalidDataException("Unknown UnionMember1: $value") - } - - /** - * Returns this class 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(): UnionMember1 = 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 UnionMember1 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } /** * 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. + * 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) @@ -5951,26 +5798,27 @@ private constructor( /** * 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. + * 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 unionMember0: UnionMember0? = null, + private val true_: JsonValue? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun true_(): Optional = Optional.ofNullable(true_) fun string(): Optional = Optional.ofNullable(string) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTrue(): Boolean = true_ != null fun isString(): Boolean = string != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTrue(): JsonValue = true_.getOrThrow("true_") fun asString(): String = string.getOrThrow("string") @@ -5978,7 +5826,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + true_ != null -> visitor.visitTrue(true_) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -5992,8 +5840,14 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } } override fun visitString(string: String) {} @@ -6020,8 +5874,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -6034,14 +5888,14 @@ private constructor( return true } - return other is Shadow && unionMember0 == other.unionMember0 && string == other.string + return other is Shadow && true_ == other.true_ && string == other.string } - override fun hashCode(): Int = Objects.hash(unionMember0, string) + override fun hashCode(): Int = Objects.hash(true_, string) override fun toString(): String = when { - unionMember0 != null -> "Shadow{unionMember0=$unionMember0}" + true_ != null -> "Shadow{true_=$true_}" string != null -> "Shadow{string=$string}" _json != null -> "Shadow{_unknown=$_json}" else -> throw IllegalStateException("Invalid Shadow") @@ -6049,8 +5903,7 @@ private constructor( companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Shadow(unionMember0 = unionMember0) + @JvmStatic fun ofTrue() = Shadow(true_ = JsonValue.from(true)) @JvmStatic fun ofString(string: String) = Shadow(string = string) } @@ -6058,7 +5911,7 @@ private constructor( /** An interface that defines how to map each variant of [Shadow] to a value of type [T]. */ interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTrue(true_: JsonValue): T fun visitString(string: String): T @@ -6084,9 +5937,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Shadow(unionMember0 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Shadow(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { Shadow(string = it, _json = json) }, @@ -6115,159 +5968,38 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) + 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") } } } - - class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) - } - - /** An enum containing [UnionMember0]'s known values. */ - enum class Known { - TRUE - } - - /** - * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } /** * Sharpens the input image, highlighting edges and finer details. Pass `true` for default - * sharpening, or provide a numeric value for custom sharpening. + * 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 unionMember0: UnionMember0? = null, + private val true_: JsonValue? = null, private val number: Double? = null, private val _json: JsonValue? = null, ) { - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun true_(): Optional = Optional.ofNullable(true_) fun number(): Optional = Optional.ofNullable(number) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTrue(): Boolean = true_ != null fun isNumber(): Boolean = number != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTrue(): JsonValue = true_.getOrThrow("true_") fun asNumber(): Double = number.getOrThrow("number") @@ -6275,7 +6007,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + true_ != null -> visitor.visitTrue(true_) number != null -> visitor.visitNumber(number) else -> visitor.unknown(_json) } @@ -6289,8 +6021,14 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } } override fun visitNumber(number: Double) {} @@ -6317,8 +6055,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitNumber(number: Double) = 1 @@ -6331,14 +6069,14 @@ private constructor( return true } - return other is Sharpen && unionMember0 == other.unionMember0 && number == other.number + return other is Sharpen && true_ == other.true_ && number == other.number } - override fun hashCode(): Int = Objects.hash(unionMember0, number) + override fun hashCode(): Int = Objects.hash(true_, number) override fun toString(): String = when { - unionMember0 != null -> "Sharpen{unionMember0=$unionMember0}" + true_ != null -> "Sharpen{true_=$true_}" number != null -> "Sharpen{number=$number}" _json != null -> "Sharpen{_unknown=$_json}" else -> throw IllegalStateException("Invalid Sharpen") @@ -6346,8 +6084,7 @@ private constructor( companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Sharpen(unionMember0 = unionMember0) + @JvmStatic fun ofTrue() = Sharpen(true_ = JsonValue.from(true)) @JvmStatic fun ofNumber(number: Double) = Sharpen(number = number) } @@ -6357,7 +6094,7 @@ private constructor( */ interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTrue(true_: JsonValue): T fun visitNumber(number: Double): T @@ -6383,9 +6120,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Sharpen(unionMember0 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Sharpen(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { Sharpen(number = it, _json = json) }, @@ -6414,140 +6151,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) + 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") } } } - - class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) - } - - /** An enum containing [UnionMember0]'s known values. */ - enum class Known { - TRUE - } - - /** - * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } /** * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. Arithmetic - * expressions are also supported. + * 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) @@ -6721,26 +6337,27 @@ private constructor( /** * 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. + * 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 unionMember0: UnionMember0? = null, + private val true_: JsonValue? = null, private val number: Double? = null, private val _json: JsonValue? = null, ) { - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun true_(): Optional = Optional.ofNullable(true_) fun number(): Optional = Optional.ofNullable(number) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTrue(): Boolean = true_ != null fun isNumber(): Boolean = number != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTrue(): JsonValue = true_.getOrThrow("true_") fun asNumber(): Double = number.getOrThrow("number") @@ -6748,7 +6365,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + true_ != null -> visitor.visitTrue(true_) number != null -> visitor.visitNumber(number) else -> visitor.unknown(_json) } @@ -6762,8 +6379,14 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } } override fun visitNumber(number: Double) {} @@ -6790,8 +6413,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitNumber(number: Double) = 1 @@ -6804,14 +6427,14 @@ private constructor( return true } - return other is Trim && unionMember0 == other.unionMember0 && number == other.number + return other is Trim && true_ == other.true_ && number == other.number } - override fun hashCode(): Int = Objects.hash(unionMember0, number) + override fun hashCode(): Int = Objects.hash(true_, number) override fun toString(): String = when { - unionMember0 != null -> "Trim{unionMember0=$unionMember0}" + true_ != null -> "Trim{true_=$true_}" number != null -> "Trim{number=$number}" _json != null -> "Trim{_unknown=$_json}" else -> throw IllegalStateException("Invalid Trim") @@ -6819,8 +6442,7 @@ private constructor( companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Trim(unionMember0 = unionMember0) + @JvmStatic fun ofTrue() = Trim(true_ = JsonValue.from(true)) @JvmStatic fun ofNumber(number: Double) = Trim(number = number) } @@ -6828,7 +6450,7 @@ private constructor( /** An interface that defines how to map each variant of [Trim] to a value of type [T]. */ interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTrue(true_: JsonValue): T fun visitNumber(number: Double): T @@ -6853,9 +6475,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Trim(unionMember0 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Trim(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { Trim(number = it, _json = json) }, @@ -6884,159 +6506,38 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) + 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") } } } - - class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) - } - - /** An enum containing [UnionMember0]'s known values. */ - enum class Known { - TRUE - } - - /** - * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } /** * Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a default - * unsharp mask, or provide a string for a custom unsharp mask. + * 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 unionMember0: UnionMember0? = null, + private val true_: JsonValue? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + fun true_(): Optional = Optional.ofNullable(true_) fun string(): Optional = Optional.ofNullable(string) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isTrue(): Boolean = true_ != null fun isString(): Boolean = string != null - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + fun asTrue(): JsonValue = true_.getOrThrow("true_") fun asString(): String = string.getOrThrow("string") @@ -7044,7 +6545,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + true_ != null -> visitor.visitTrue(true_) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -7058,8 +6559,14 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } } override fun visitString(string: String) {} @@ -7086,8 +6593,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } override fun visitString(string: String) = 1 @@ -7100,16 +6607,14 @@ private constructor( return true } - return other is UnsharpMask && - unionMember0 == other.unionMember0 && - string == other.string + return other is UnsharpMask && true_ == other.true_ && string == other.string } - override fun hashCode(): Int = Objects.hash(unionMember0, string) + override fun hashCode(): Int = Objects.hash(true_, string) override fun toString(): String = when { - unionMember0 != null -> "UnsharpMask{unionMember0=$unionMember0}" + true_ != null -> "UnsharpMask{true_=$true_}" string != null -> "UnsharpMask{string=$string}" _json != null -> "UnsharpMask{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnsharpMask") @@ -7117,9 +6622,7 @@ private constructor( companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - UnsharpMask(unionMember0 = unionMember0) + @JvmStatic fun ofTrue() = UnsharpMask(true_ = JsonValue.from(true)) @JvmStatic fun ofString(string: String) = UnsharpMask(string = string) } @@ -7130,7 +6633,7 @@ private constructor( */ interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitTrue(true_: JsonValue): T fun visitString(string: String): T @@ -7156,9 +6659,9 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UnsharpMask(unionMember0 = it, _json = json) - }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { UnsharpMask(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, tryDeserialize(node, jacksonTypeRef())?.let { UnsharpMask(string = it, _json = json) }, @@ -7187,138 +6690,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) + 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") } } } - - class UnionMember0 @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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) = UnionMember0(JsonField.of(value)) - } - - /** An enum containing [UnionMember0]'s known values. */ - enum class Known { - TRUE - } - - /** - * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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 [UnionMember0] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 UnionMember0: $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(): UnionMember0 = 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 UnionMember0 && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } } - /** Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. */ + /** + * 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 { /** @@ -7463,7 +6847,9 @@ private constructor( /** * 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`). + * 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) @@ -7632,7 +7018,10 @@ private constructor( } } - /** Focus using cropped image coordinates - X coordinate */ + /** + * 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 @@ -7799,7 +7188,10 @@ private constructor( } } - /** Focus using cropped image coordinates - X center coordinate */ + /** + * 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 @@ -7969,7 +7361,10 @@ private constructor( } } - /** Focus using cropped image coordinates - Y coordinate */ + /** + * 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 @@ -8136,7 +7531,10 @@ private constructor( } } - /** Focus using cropped image coordinates - Y center coordinate */ + /** + * 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 @@ -8314,6 +7712,7 @@ private constructor( return other is Transformation && aiChangeBackground == other.aiChangeBackground && aiDropShadow == other.aiDropShadow && + aiEdit == other.aiEdit && aiRemoveBackground == other.aiRemoveBackground && aiRemoveBackgroundExternal == other.aiRemoveBackgroundExternal && aiRetouch == other.aiRetouch && @@ -8370,6 +7769,7 @@ private constructor( Objects.hash( aiChangeBackground, aiDropShadow, + aiEdit, aiRemoveBackground, aiRemoveBackgroundExternal, aiRetouch, @@ -8426,5 +7826,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Transformation{aiChangeBackground=$aiChangeBackground, aiDropShadow=$aiDropShadow, 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, 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 index aca5d81a..5a62532e 100644 --- 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 @@ -10,7 +10,7 @@ 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`. + * to `path`. Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). */ class TransformationPosition @JsonCreator 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 d40d2fe9..2ca94d24 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 @@ -25,7 +25,7 @@ private constructor( private val position: JsonField, private val timing: JsonField, private val input: JsonField, - private val type: JsonField, + private val type: JsonValue, private val encoding: JsonField, private val transformation: JsonField>, private val additionalProperties: MutableMap, @@ -38,7 +38,7 @@ private constructor( position: JsonField = JsonMissing.of(), @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing input: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("encoding") @ExcludeMissing encoding: JsonField = JsonMissing.of(), @JsonProperty("transformation") @ExcludeMissing @@ -69,10 +69,15 @@ private constructor( fun input(): String = input.getRequired("input") /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * 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). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * The input path can be included in the layer as either `i-{input}` or @@ -87,7 +92,8 @@ private constructor( /** * Array of transformation to be applied to the overlay video. Except `streamingResolutions`, - * all other video transformations are supported. + * 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). @@ -116,13 +122,6 @@ private constructor( */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input - /** - * 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 [encoding]. * @@ -159,7 +158,6 @@ private constructor( * The following fields are required: * ```java * .input() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -171,7 +169,7 @@ private constructor( private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var input: JsonField? = null - private var type: 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() @@ -220,15 +218,19 @@ private constructor( */ fun input(input: JsonField) = apply { this.input = input } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { this.type = type } + fun type(type: JsonValue) = apply { this.type = type } /** * The input path can be included in the layer as either `i-{input}` or @@ -249,7 +251,8 @@ private constructor( /** * Array of transformation to be applied to the overlay video. Except - * `streamingResolutions`, all other video transformations are supported. + * `streamingResolutions`, all other video transformations are supported. See + * [Video transformations](https://imagekit.io/docs/video-transformation). */ fun transformation(transformation: List) = transformation(JsonField.of(transformation)) @@ -304,7 +307,6 @@ private constructor( * The following fields are required: * ```java * .input() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -314,7 +316,7 @@ private constructor( position, timing, checkRequired("input", input), - checkRequired("type", type), + type, encoding, (transformation ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -331,7 +333,11 @@ private constructor( position().ifPresent { it.validate() } timing().ifPresent { it.validate() } input() - type().validate() + _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 @@ -355,131 +361,10 @@ private constructor( (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (input.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("video")) 1 else 0 } + (encoding.asKnown().getOrNull()?.validity() ?: 0) + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - 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 = of("video") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - VIDEO - } - - /** - * 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, - /** 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 -> Value.VIDEO - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use 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 -> Known.VIDEO - 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 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 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 49d16f6d..fb6fb3c3 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 @@ -25,33 +30,133 @@ private constructor( private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, private val videoTransformationReady: VideoTransformationReadyEvent? = null, private val videoTransformationError: VideoTransformationErrorEvent? = null, + private val uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent? = null, + private val uploadPreTransformError: UploadPreTransformErrorWebhookEvent? = null, + private val uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent? = null, + private val uploadPostTransformError: UploadPostTransformErrorWebhookEvent? = 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(): UploadPreTransformSuccessWebhookEvent = + 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(): UploadPreTransformErrorWebhookEvent = + 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(): UploadPostTransformSuccessWebhookEvent = + uploadPostTransformSuccess.getOrThrow("uploadPostTransformSuccess") + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun asUploadPostTransformError(): UploadPostTransformErrorWebhookEvent = + uploadPostTransformError.getOrThrow("uploadPostTransformError") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -62,6 +167,14 @@ private constructor( 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) } @@ -91,6 +204,30 @@ private constructor( ) { videoTransformationError.validate() } + + override fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + ) { + uploadPreTransformSuccess.validate() + } + + override fun visitUploadPreTransformError( + uploadPreTransformError: UploadPreTransformErrorWebhookEvent + ) { + uploadPreTransformError.validate() + } + + override fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + ) { + uploadPostTransformSuccess.validate() + } + + override fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorWebhookEvent + ) { + uploadPostTransformError.validate() + } } ) validated = true @@ -125,6 +262,22 @@ private constructor( videoTransformationError: VideoTransformationErrorEvent ) = videoTransformationError.validity() + override fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + ) = uploadPreTransformSuccess.validity() + + override fun visitUploadPreTransformError( + uploadPreTransformError: UploadPreTransformErrorWebhookEvent + ) = uploadPreTransformError.validity() + + override fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + ) = uploadPostTransformSuccess.validity() + + override fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorWebhookEvent + ) = uploadPostTransformError.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -137,7 +290,11 @@ private constructor( return other is UnsafeUnwrapWebhookEvent && videoTransformationAccepted == other.videoTransformationAccepted && videoTransformationReady == other.videoTransformationReady && - videoTransformationError == other.videoTransformationError + videoTransformationError == other.videoTransformationError && + uploadPreTransformSuccess == other.uploadPreTransformSuccess && + uploadPreTransformError == other.uploadPreTransformError && + uploadPostTransformSuccess == other.uploadPostTransformSuccess && + uploadPostTransformError == other.uploadPostTransformError } override fun hashCode(): Int = @@ -145,6 +302,10 @@ private constructor( videoTransformationAccepted, videoTransformationReady, videoTransformationError, + uploadPreTransformSuccess, + uploadPreTransformError, + uploadPostTransformSuccess, + uploadPostTransformError, ) override fun toString(): String = @@ -155,24 +316,84 @@ private constructor( "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: UploadPreTransformSuccessWebhookEvent + ) = 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: UploadPreTransformErrorWebhookEvent + ) = 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: UploadPostTransformSuccessWebhookEvent + ) = 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: UploadPostTransformErrorWebhookEvent + ) = UnsafeUnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) } /** @@ -181,18 +402,66 @@ 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: UploadPreTransformSuccessWebhookEvent + ): 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: UploadPreTransformErrorWebhookEvent + ): 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: UploadPostTransformSuccessWebhookEvent + ): T + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorWebhookEvent + ): T + /** * Maps an unknown variant of [UnsafeUnwrapWebhookEvent] to a value of type [T]. * @@ -229,6 +498,37 @@ private constructor( 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() } @@ -260,6 +560,14 @@ private constructor( 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 index 14560566..c2a01846 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 @@ -25,33 +30,133 @@ private constructor( private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, private val videoTransformationReady: VideoTransformationReadyEvent? = null, private val videoTransformationError: VideoTransformationErrorEvent? = null, + private val uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent? = null, + private val uploadPreTransformError: UploadPreTransformErrorWebhookEvent? = null, + private val uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent? = null, + private val uploadPostTransformError: UploadPostTransformErrorWebhookEvent? = 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(): UploadPreTransformSuccessWebhookEvent = + 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(): UploadPreTransformErrorWebhookEvent = + 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(): UploadPostTransformSuccessWebhookEvent = + uploadPostTransformSuccess.getOrThrow("uploadPostTransformSuccess") + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun asUploadPostTransformError(): UploadPostTransformErrorWebhookEvent = + uploadPostTransformError.getOrThrow("uploadPostTransformError") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -62,6 +167,14 @@ private constructor( 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) } @@ -91,6 +204,30 @@ private constructor( ) { videoTransformationError.validate() } + + override fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + ) { + uploadPreTransformSuccess.validate() + } + + override fun visitUploadPreTransformError( + uploadPreTransformError: UploadPreTransformErrorWebhookEvent + ) { + uploadPreTransformError.validate() + } + + override fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + ) { + uploadPostTransformSuccess.validate() + } + + override fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorWebhookEvent + ) { + uploadPostTransformError.validate() + } } ) validated = true @@ -125,6 +262,22 @@ private constructor( videoTransformationError: VideoTransformationErrorEvent ) = videoTransformationError.validity() + override fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + ) = uploadPreTransformSuccess.validity() + + override fun visitUploadPreTransformError( + uploadPreTransformError: UploadPreTransformErrorWebhookEvent + ) = uploadPreTransformError.validity() + + override fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + ) = uploadPostTransformSuccess.validity() + + override fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorWebhookEvent + ) = uploadPostTransformError.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -137,7 +290,11 @@ private constructor( return other is UnwrapWebhookEvent && videoTransformationAccepted == other.videoTransformationAccepted && videoTransformationReady == other.videoTransformationReady && - videoTransformationError == other.videoTransformationError + videoTransformationError == other.videoTransformationError && + uploadPreTransformSuccess == other.uploadPreTransformSuccess && + uploadPreTransformError == other.uploadPreTransformError && + uploadPostTransformSuccess == other.uploadPostTransformSuccess && + uploadPostTransformError == other.uploadPostTransformError } override fun hashCode(): Int = @@ -145,6 +302,10 @@ private constructor( videoTransformationAccepted, videoTransformationReady, videoTransformationError, + uploadPreTransformSuccess, + uploadPreTransformError, + uploadPostTransformSuccess, + uploadPostTransformError, ) override fun toString(): String = @@ -155,24 +316,84 @@ private constructor( "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: UploadPreTransformSuccessWebhookEvent + ) = 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: UploadPreTransformErrorWebhookEvent + ) = 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: UploadPostTransformSuccessWebhookEvent + ) = 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: UploadPostTransformErrorWebhookEvent + ) = UnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) } /** @@ -181,18 +402,66 @@ 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: UploadPreTransformSuccessWebhookEvent + ): 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: UploadPreTransformErrorWebhookEvent + ): 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: UploadPostTransformSuccessWebhookEvent + ): T + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorWebhookEvent + ): T + /** * Maps an unknown variant of [UnwrapWebhookEvent] to a value of type [T]. * @@ -225,6 +494,28 @@ private constructor( 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() } @@ -255,6 +546,14 @@ private constructor( 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/UploadPostTransformErrorWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEvent.kt new file mode 100644 index 00000000..dd1cb7eb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEvent.kt @@ -0,0 +1,1694 @@ +// 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 UploadPostTransformErrorWebhookEvent +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 + * [UploadPostTransformErrorWebhookEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UploadPostTransformErrorWebhookEvent]. */ + 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( + uploadPostTransformErrorWebhookEvent: UploadPostTransformErrorWebhookEvent + ) = apply { + id = uploadPostTransformErrorWebhookEvent.id + createdAt = uploadPostTransformErrorWebhookEvent.createdAt + data = uploadPostTransformErrorWebhookEvent.data + request = uploadPostTransformErrorWebhookEvent.request + type = uploadPostTransformErrorWebhookEvent.type + additionalProperties = + uploadPostTransformErrorWebhookEvent.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 [UploadPostTransformErrorWebhookEvent]. + * + * 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(): UploadPostTransformErrorWebhookEvent = + UploadPostTransformErrorWebhookEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UploadPostTransformErrorWebhookEvent = 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 UploadPostTransformErrorWebhookEvent && + 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() = + "UploadPostTransformErrorWebhookEvent{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/UploadPostTransformSuccessWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEvent.kt new file mode 100644 index 00000000..0c70ea5f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEvent.kt @@ -0,0 +1,1291 @@ +// 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 UploadPostTransformSuccessWebhookEvent +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 + * [UploadPostTransformSuccessWebhookEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UploadPostTransformSuccessWebhookEvent]. */ + 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( + uploadPostTransformSuccessWebhookEvent: UploadPostTransformSuccessWebhookEvent + ) = apply { + id = uploadPostTransformSuccessWebhookEvent.id + createdAt = uploadPostTransformSuccessWebhookEvent.createdAt + data = uploadPostTransformSuccessWebhookEvent.data + request = uploadPostTransformSuccessWebhookEvent.request + type = uploadPostTransformSuccessWebhookEvent.type + additionalProperties = + uploadPostTransformSuccessWebhookEvent.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 [UploadPostTransformSuccessWebhookEvent]. + * + * 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(): UploadPostTransformSuccessWebhookEvent = + UploadPostTransformSuccessWebhookEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UploadPostTransformSuccessWebhookEvent = 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 UploadPostTransformSuccessWebhookEvent && + 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() = + "UploadPostTransformSuccessWebhookEvent{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/UploadPreTransformErrorWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEvent.kt new file mode 100644 index 00000000..2265fbb2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEvent.kt @@ -0,0 +1,1105 @@ +// 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 UploadPreTransformErrorWebhookEvent +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 + * [UploadPreTransformErrorWebhookEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UploadPreTransformErrorWebhookEvent]. */ + 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( + uploadPreTransformErrorWebhookEvent: UploadPreTransformErrorWebhookEvent + ) = apply { + id = uploadPreTransformErrorWebhookEvent.id + createdAt = uploadPreTransformErrorWebhookEvent.createdAt + data = uploadPreTransformErrorWebhookEvent.data + request = uploadPreTransformErrorWebhookEvent.request + type = uploadPreTransformErrorWebhookEvent.type + additionalProperties = + uploadPreTransformErrorWebhookEvent.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 [UploadPreTransformErrorWebhookEvent]. + * + * 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(): UploadPreTransformErrorWebhookEvent = + UploadPreTransformErrorWebhookEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UploadPreTransformErrorWebhookEvent = 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 UploadPreTransformErrorWebhookEvent && + 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() = + "UploadPreTransformErrorWebhookEvent{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/UploadPreTransformSuccessWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEvent.kt new file mode 100644 index 00000000..5b934121 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEvent.kt @@ -0,0 +1,3033 @@ +// 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 UploadPreTransformSuccessWebhookEvent +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 + * [UploadPreTransformSuccessWebhookEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UploadPreTransformSuccessWebhookEvent]. */ + 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( + uploadPreTransformSuccessWebhookEvent: UploadPreTransformSuccessWebhookEvent + ) = apply { + id = uploadPreTransformSuccessWebhookEvent.id + createdAt = uploadPreTransformSuccessWebhookEvent.createdAt + data = uploadPreTransformSuccessWebhookEvent.data + request = uploadPreTransformSuccessWebhookEvent.request + type = uploadPreTransformSuccessWebhookEvent.type + additionalProperties = + uploadPreTransformSuccessWebhookEvent.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 [UploadPreTransformSuccessWebhookEvent]. + * + * 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(): UploadPreTransformSuccessWebhookEvent = + UploadPreTransformSuccessWebhookEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UploadPreTransformSuccessWebhookEvent = 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 awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @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(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 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 [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 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 { + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + 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( + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + 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 = + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + 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 && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{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 UploadPreTransformSuccessWebhookEvent && + 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() = + "UploadPreTransformSuccessWebhookEvent{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 index 99f84cc8..50f7bc07 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,6 +21,11 @@ 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, @@ -51,6 +56,8 @@ private constructor( 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). */ @@ -63,6 +70,8 @@ private constructor( 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). */ @@ -171,6 +180,7 @@ private constructor( */ 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)) /** @@ -192,6 +202,7 @@ private constructor( */ 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)) /** @@ -317,12 +328,16 @@ private constructor( ) : 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). */ @@ -385,6 +400,7 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } + /** Information about the source video asset being transformed. */ fun asset(asset: Asset) = asset(JsonField.of(asset)) /** @@ -396,6 +412,7 @@ private constructor( */ fun asset(asset: JsonField) = apply { this.asset = asset } + /** Base information about a video transformation request. */ fun transformation(transformation: Transformation) = transformation(JsonField.of(transformation)) @@ -481,6 +498,7 @@ private constructor( (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, @@ -493,7 +511,7 @@ private constructor( ) : this(url, mutableMapOf()) /** - * Source asset URL. + * 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 @@ -545,7 +563,7 @@ private constructor( additionalProperties = asset.additionalProperties.toMutableMap() } - /** Source asset URL. */ + /** URL to download or access the source video file. */ fun url(url: String) = url(JsonField.of(url)) /** @@ -639,6 +657,7 @@ private constructor( override fun toString() = "Asset{url=$url, additionalProperties=$additionalProperties}" } + /** Base information about a video transformation request. */ class Transformation private constructor( private val type: JsonField, @@ -655,6 +674,11 @@ private constructor( ) : 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). @@ -662,6 +686,8 @@ private constructor( 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). */ @@ -720,6 +746,13 @@ private constructor( 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)) /** @@ -731,6 +764,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Configuration options for video transformations. */ fun options(options: Options) = options(JsonField.of(options)) /** @@ -815,6 +849,12 @@ private constructor( (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 { @@ -951,6 +991,7 @@ private constructor( override fun toString() = value.toString() } + /** Configuration options for video transformations. */ class Options private constructor( private val audioCodec: JsonField, @@ -998,30 +1039,40 @@ private constructor( ) /** + * 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). */ @@ -1029,12 +1080,16 @@ private constructor( 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 or vp9). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -1148,6 +1203,7 @@ private constructor( additionalProperties = options.additionalProperties.toMutableMap() } + /** Audio codec used for encoding (aac or opus). */ fun audioCodec(audioCodec: AudioCodec) = audioCodec(JsonField.of(audioCodec)) /** @@ -1161,6 +1217,7 @@ private constructor( this.audioCodec = audioCodec } + /** Whether to automatically rotate the video based on metadata. */ fun autoRotate(autoRotate: Boolean) = autoRotate(JsonField.of(autoRotate)) /** @@ -1174,6 +1231,7 @@ private constructor( this.autoRotate = autoRotate } + /** Output format for the transformed video or thumbnail. */ fun format(format: Format) = format(JsonField.of(format)) /** @@ -1185,6 +1243,7 @@ private constructor( */ fun format(format: JsonField) = apply { this.format = format } + /** Quality setting for the output video. */ fun quality(quality: Long) = quality(JsonField.of(quality)) /** @@ -1196,6 +1255,7 @@ private constructor( */ fun quality(quality: JsonField) = apply { this.quality = quality } + /** Streaming protocol for adaptive bitrate streaming. */ fun streamProtocol(streamProtocol: StreamProtocol) = streamProtocol(JsonField.of(streamProtocol)) @@ -1210,6 +1270,7 @@ private constructor( this.streamProtocol = streamProtocol } + /** Array of quality representations for adaptive bitrate streaming. */ fun variants(variants: List) = variants(JsonField.of(variants)) /** @@ -1235,6 +1296,7 @@ private constructor( } } + /** Video codec used for encoding (h264 or vp9). */ fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) /** @@ -1329,6 +1391,7 @@ private constructor( (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 { @@ -1465,6 +1528,7 @@ private constructor( override fun toString() = value.toString() } + /** Output format for the transformed video or thumbnail. */ class Format @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1617,6 +1681,7 @@ private constructor( override fun toString() = value.toString() } + /** Streaming protocol for adaptive bitrate streaming. */ class StreamProtocol @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1754,6 +1819,7 @@ private constructor( override fun toString() = value.toString() } + /** Video codec used for encoding (h264 or vp9). */ class VideoCodec @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1965,6 +2031,7 @@ private constructor( "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, @@ -1985,7 +2052,7 @@ private constructor( ) : this(url, xRequestId, userAgent, mutableMapOf()) /** - * URL of the submitted request. + * 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). @@ -1993,7 +2060,7 @@ private constructor( fun url(): String = url.getRequired("url") /** - * Unique ID for the originating request. + * 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). @@ -2001,7 +2068,7 @@ private constructor( fun xRequestId(): String = xRequestId.getRequired("x_request_id") /** - * User-Agent header of the originating request. + * 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). @@ -2073,7 +2140,7 @@ private constructor( additionalProperties = request.additionalProperties.toMutableMap() } - /** URL of the submitted request. */ + /** Full URL of the transformation request that was submitted. */ fun url(url: String) = url(JsonField.of(url)) /** @@ -2085,7 +2152,7 @@ private constructor( */ fun url(url: JsonField) = apply { this.url = url } - /** Unique ID for the originating request. */ + /** Unique identifier for the originating transformation request. */ fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) /** @@ -2097,7 +2164,7 @@ private constructor( */ fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } - /** User-Agent header of the originating request. */ + /** User-Agent header from the original request that triggered the transformation. */ fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) /** 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 009db96d..755c167a 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,6 +21,11 @@ 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, @@ -51,6 +56,8 @@ private constructor( 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). */ @@ -63,6 +70,8 @@ private constructor( 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). */ @@ -169,6 +178,7 @@ private constructor( */ 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)) /** @@ -190,6 +200,7 @@ private constructor( */ 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)) /** @@ -315,6 +326,8 @@ private constructor( ) : 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). */ @@ -383,6 +396,7 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } + /** Information about the source video asset being transformed. */ fun asset(asset: Asset) = asset(JsonField.of(asset)) /** @@ -479,6 +493,7 @@ private constructor( (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, @@ -491,7 +506,7 @@ private constructor( ) : this(url, mutableMapOf()) /** - * Source asset URL. + * 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 @@ -543,7 +558,7 @@ private constructor( additionalProperties = asset.additionalProperties.toMutableMap() } - /** Source asset URL. */ + /** URL to download or access the source video file. */ fun url(url: String) = url(JsonField.of(url)) /** @@ -655,6 +670,11 @@ private constructor( ) : 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). @@ -662,12 +682,16 @@ private constructor( 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). */ @@ -735,6 +759,13 @@ private constructor( 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)) /** @@ -746,6 +777,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Details about the transformation error. */ fun error(error: Error) = error(JsonField.of(error)) /** @@ -757,6 +789,7 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } + /** Configuration options for video transformations. */ fun options(options: Options) = options(JsonField.of(options)) /** @@ -844,6 +877,12 @@ private constructor( (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 { @@ -980,6 +1019,7 @@ private constructor( override fun toString() = value.toString() } + /** Details about the transformation error. */ class Error private constructor( private val reason: JsonField, @@ -994,6 +1034,11 @@ private constructor( ) : 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). @@ -1045,6 +1090,12 @@ private constructor( 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)) /** @@ -1122,6 +1173,12 @@ private constructor( @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 { @@ -1280,6 +1337,7 @@ private constructor( "Error{reason=$reason, additionalProperties=$additionalProperties}" } + /** Configuration options for video transformations. */ class Options private constructor( private val audioCodec: JsonField, @@ -1327,30 +1385,40 @@ private constructor( ) /** + * 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). */ @@ -1358,12 +1426,16 @@ private constructor( 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 or vp9). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -1477,6 +1549,7 @@ private constructor( additionalProperties = options.additionalProperties.toMutableMap() } + /** Audio codec used for encoding (aac or opus). */ fun audioCodec(audioCodec: AudioCodec) = audioCodec(JsonField.of(audioCodec)) /** @@ -1490,6 +1563,7 @@ private constructor( this.audioCodec = audioCodec } + /** Whether to automatically rotate the video based on metadata. */ fun autoRotate(autoRotate: Boolean) = autoRotate(JsonField.of(autoRotate)) /** @@ -1503,6 +1577,7 @@ private constructor( this.autoRotate = autoRotate } + /** Output format for the transformed video or thumbnail. */ fun format(format: Format) = format(JsonField.of(format)) /** @@ -1514,6 +1589,7 @@ private constructor( */ fun format(format: JsonField) = apply { this.format = format } + /** Quality setting for the output video. */ fun quality(quality: Long) = quality(JsonField.of(quality)) /** @@ -1525,6 +1601,7 @@ private constructor( */ fun quality(quality: JsonField) = apply { this.quality = quality } + /** Streaming protocol for adaptive bitrate streaming. */ fun streamProtocol(streamProtocol: StreamProtocol) = streamProtocol(JsonField.of(streamProtocol)) @@ -1539,6 +1616,7 @@ private constructor( this.streamProtocol = streamProtocol } + /** Array of quality representations for adaptive bitrate streaming. */ fun variants(variants: List) = variants(JsonField.of(variants)) /** @@ -1564,6 +1642,7 @@ private constructor( } } + /** Video codec used for encoding (h264 or vp9). */ fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) /** @@ -1658,6 +1737,7 @@ private constructor( (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 { @@ -1794,6 +1874,7 @@ private constructor( override fun toString() = value.toString() } + /** Output format for the transformed video or thumbnail. */ class Format @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1946,6 +2027,7 @@ private constructor( override fun toString() = value.toString() } + /** Streaming protocol for adaptive bitrate streaming. */ class StreamProtocol @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2083,6 +2165,7 @@ private constructor( override fun toString() = value.toString() } + /** Video codec used for encoding (h264 or vp9). */ class VideoCodec @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2297,6 +2380,7 @@ private constructor( "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, @@ -2317,7 +2401,7 @@ private constructor( ) : this(url, xRequestId, userAgent, mutableMapOf()) /** - * URL of the submitted request. + * 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). @@ -2325,7 +2409,7 @@ private constructor( fun url(): String = url.getRequired("url") /** - * Unique ID for the originating request. + * 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). @@ -2333,7 +2417,7 @@ private constructor( fun xRequestId(): String = xRequestId.getRequired("x_request_id") /** - * User-Agent header of the originating request. + * 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). @@ -2405,7 +2489,7 @@ private constructor( additionalProperties = request.additionalProperties.toMutableMap() } - /** URL of the submitted request. */ + /** Full URL of the transformation request that was submitted. */ fun url(url: String) = url(JsonField.of(url)) /** @@ -2417,7 +2501,7 @@ private constructor( */ fun url(url: JsonField) = apply { this.url = url } - /** Unique ID for the originating request. */ + /** Unique identifier for the originating transformation request. */ fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) /** @@ -2429,7 +2513,7 @@ private constructor( */ fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } - /** User-Agent header of the originating request. */ + /** User-Agent header from the original request that triggered the transformation. */ fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) /** 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 49d51e5b..0358af06 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,6 +21,11 @@ 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, @@ -53,6 +58,8 @@ private constructor( 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). */ @@ -65,6 +72,8 @@ private constructor( 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). */ @@ -82,6 +91,8 @@ private constructor( @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). */ @@ -186,6 +197,7 @@ private constructor( */ 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)) /** @@ -207,6 +219,7 @@ private constructor( */ 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)) /** @@ -231,6 +244,7 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** Performance metrics for the transformation process. */ fun timings(timings: Timings) = timings(JsonField.of(timings)) /** @@ -345,6 +359,8 @@ private constructor( ) : 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). */ @@ -413,6 +429,7 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } + /** Information about the source video asset being transformed. */ fun asset(asset: Asset) = asset(JsonField.of(asset)) /** @@ -509,6 +526,7 @@ private constructor( (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, @@ -521,7 +539,7 @@ private constructor( ) : this(url, mutableMapOf()) /** - * Source asset URL. + * 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 @@ -573,7 +591,7 @@ private constructor( additionalProperties = asset.additionalProperties.toMutableMap() } - /** Source asset URL. */ + /** URL to download or access the source video file. */ fun url(url: String) = url(JsonField.of(url)) /** @@ -685,6 +703,11 @@ private constructor( ) : 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). @@ -692,12 +715,16 @@ private constructor( 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). */ @@ -765,6 +792,13 @@ private constructor( 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)) /** @@ -776,6 +810,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Configuration options for video transformations. */ fun options(options: Options) = options(JsonField.of(options)) /** @@ -787,6 +822,7 @@ private constructor( */ fun options(options: JsonField) = apply { this.options = options } + /** Information about the transformed output video. */ fun output(output: Output) = output(JsonField.of(output)) /** @@ -874,6 +910,12 @@ private constructor( (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 { @@ -1010,6 +1052,7 @@ private constructor( override fun toString() = value.toString() } + /** Configuration options for video transformations. */ class Options private constructor( private val audioCodec: JsonField, @@ -1057,30 +1100,40 @@ private constructor( ) /** + * 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). */ @@ -1088,12 +1141,16 @@ private constructor( 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 or vp9). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -1207,6 +1264,7 @@ private constructor( additionalProperties = options.additionalProperties.toMutableMap() } + /** Audio codec used for encoding (aac or opus). */ fun audioCodec(audioCodec: AudioCodec) = audioCodec(JsonField.of(audioCodec)) /** @@ -1220,6 +1278,7 @@ private constructor( this.audioCodec = audioCodec } + /** Whether to automatically rotate the video based on metadata. */ fun autoRotate(autoRotate: Boolean) = autoRotate(JsonField.of(autoRotate)) /** @@ -1233,6 +1292,7 @@ private constructor( this.autoRotate = autoRotate } + /** Output format for the transformed video or thumbnail. */ fun format(format: Format) = format(JsonField.of(format)) /** @@ -1244,6 +1304,7 @@ private constructor( */ fun format(format: JsonField) = apply { this.format = format } + /** Quality setting for the output video. */ fun quality(quality: Long) = quality(JsonField.of(quality)) /** @@ -1255,6 +1316,7 @@ private constructor( */ fun quality(quality: JsonField) = apply { this.quality = quality } + /** Streaming protocol for adaptive bitrate streaming. */ fun streamProtocol(streamProtocol: StreamProtocol) = streamProtocol(JsonField.of(streamProtocol)) @@ -1269,6 +1331,7 @@ private constructor( this.streamProtocol = streamProtocol } + /** Array of quality representations for adaptive bitrate streaming. */ fun variants(variants: List) = variants(JsonField.of(variants)) /** @@ -1294,6 +1357,7 @@ private constructor( } } + /** Video codec used for encoding (h264 or vp9). */ fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) /** @@ -1388,6 +1452,7 @@ private constructor( (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 { @@ -1524,6 +1589,7 @@ private constructor( override fun toString() = value.toString() } + /** Output format for the transformed video or thumbnail. */ class Format @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1676,6 +1742,7 @@ private constructor( override fun toString() = value.toString() } + /** Streaming protocol for adaptive bitrate streaming. */ class StreamProtocol @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1813,6 +1880,7 @@ private constructor( override fun toString() = value.toString() } + /** Video codec used for encoding (h264 or vp9). */ class VideoCodec @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1984,6 +2052,7 @@ private constructor( "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, @@ -2000,6 +2069,8 @@ private constructor( ) : 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). @@ -2007,6 +2078,8 @@ private constructor( 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). */ @@ -2069,6 +2142,7 @@ private constructor( additionalProperties = output.additionalProperties.toMutableMap() } + /** URL to access the transformed video. */ fun url(url: String) = url(JsonField.of(url)) /** @@ -2080,6 +2154,7 @@ private constructor( */ fun url(url: JsonField) = apply { this.url = url } + /** Metadata of the output video file. */ fun videoMetadata(videoMetadata: VideoMetadata) = videoMetadata(JsonField.of(videoMetadata)) @@ -2167,6 +2242,7 @@ private constructor( (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, @@ -2193,6 +2269,8 @@ private constructor( ) : 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). @@ -2200,6 +2278,8 @@ private constructor( 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). @@ -2207,6 +2287,8 @@ private constructor( 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). @@ -2214,6 +2296,8 @@ private constructor( 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). @@ -2304,6 +2388,7 @@ private constructor( additionalProperties = videoMetadata.additionalProperties.toMutableMap() } + /** Bitrate of the output video in bits per second. */ fun bitrate(bitrate: Long) = bitrate(JsonField.of(bitrate)) /** @@ -2315,6 +2400,7 @@ private constructor( */ fun bitrate(bitrate: JsonField) = apply { this.bitrate = bitrate } + /** Duration of the output video in seconds. */ fun duration(duration: Double) = duration(JsonField.of(duration)) /** @@ -2328,6 +2414,7 @@ private constructor( this.duration = duration } + /** Height of the output video in pixels. */ fun height(height: Long) = height(JsonField.of(height)) /** @@ -2339,6 +2426,7 @@ private constructor( */ fun height(height: JsonField) = apply { this.height = height } + /** Width of the output video in pixels. */ fun width(width: Long) = width(JsonField.of(width)) /** @@ -2519,6 +2607,7 @@ private constructor( "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, @@ -2539,7 +2628,7 @@ private constructor( ) : this(url, xRequestId, userAgent, mutableMapOf()) /** - * URL of the submitted request. + * 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). @@ -2547,7 +2636,7 @@ private constructor( fun url(): String = url.getRequired("url") /** - * Unique ID for the originating request. + * 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). @@ -2555,7 +2644,7 @@ private constructor( fun xRequestId(): String = xRequestId.getRequired("x_request_id") /** - * User-Agent header of the originating request. + * 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). @@ -2627,7 +2716,7 @@ private constructor( additionalProperties = request.additionalProperties.toMutableMap() } - /** URL of the submitted request. */ + /** Full URL of the transformation request that was submitted. */ fun url(url: String) = url(JsonField.of(url)) /** @@ -2639,7 +2728,7 @@ private constructor( */ fun url(url: JsonField) = apply { this.url = url } - /** Unique ID for the originating request. */ + /** Unique identifier for the originating transformation request. */ fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) /** @@ -2651,7 +2740,7 @@ private constructor( */ fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } - /** User-Agent header of the originating request. */ + /** User-Agent header from the original request that triggered the transformation. */ fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) /** @@ -2759,6 +2848,7 @@ private constructor( "Request{url=$url, xRequestId=$xRequestId, userAgent=$userAgent, additionalProperties=$additionalProperties}" } + /** Performance metrics for the transformation process. */ class Timings private constructor( private val downloadDuration: JsonField, @@ -2777,7 +2867,8 @@ private constructor( ) : this(downloadDuration, encodingDuration, mutableMapOf()) /** - * Milliseconds spent downloading the source. + * 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). @@ -2785,7 +2876,7 @@ private constructor( fun downloadDuration(): Optional = downloadDuration.getOptional("download_duration") /** - * Milliseconds spent encoding. + * 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). @@ -2844,7 +2935,10 @@ private constructor( additionalProperties = timings.additionalProperties.toMutableMap() } - /** Milliseconds spent downloading the source. */ + /** + * Time spent downloading the source video from your origin or media library, in + * milliseconds. + */ fun downloadDuration(downloadDuration: Long) = downloadDuration(JsonField.of(downloadDuration)) @@ -2859,7 +2953,7 @@ private constructor( this.downloadDuration = downloadDuration } - /** Milliseconds spent encoding. */ + /** Time spent encoding the video, in milliseconds. */ fun encodingDuration(encodingDuration: Long) = encodingDuration(JsonField.of(encodingDuration)) 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 8c7650f5..934ff3f0 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 @@ -23,7 +23,6 @@ internal class ImageOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(ImageOverlay.Type.IMAGE) .encoding(ImageOverlay.Encoding.AUTO) .transformation(listOf()) .build() @@ -35,7 +34,6 @@ internal class ImageOverlayTest { assertThat(imageOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) assertThat(imageOverlay.input()).isEqualTo("input") - assertThat(imageOverlay.type()).isEqualTo(ImageOverlay.Type.IMAGE) assertThat(imageOverlay.encoding()).contains(ImageOverlay.Encoding.AUTO) assertThat(imageOverlay.transformation().getOrNull()).containsExactly() } @@ -54,7 +52,6 @@ internal class ImageOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(ImageOverlay.Type.IMAGE) .encoding(ImageOverlay.Encoding.AUTO) .transformation(listOf()) .build() 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 f3225383..c55bfc42 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 @@ -27,7 +27,6 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .text("text") - .type(TextOverlay.Type.TEXT) .encoding(TextOverlay.Encoding.AUTO) .addTransformation( TextOverlayTransformation.builder() @@ -42,7 +41,7 @@ internal class OverlayTest { .padding(0.0) .radius(0.0) .rotation(0.0) - .typography(TextOverlayTransformation.Typography.B) + .typography("typography") .width(0.0) .build() ) @@ -72,7 +71,6 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .text("text") - .type(TextOverlay.Type.TEXT) .encoding(TextOverlay.Encoding.AUTO) .addTransformation( TextOverlayTransformation.builder() @@ -87,7 +85,7 @@ internal class OverlayTest { .padding(0.0) .radius(0.0) .rotation(0.0) - .typography(TextOverlayTransformation.Typography.B) + .typography("typography") .width(0.0) .build() ) @@ -113,7 +111,6 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(ImageOverlay.Type.IMAGE) .encoding(ImageOverlay.Encoding.AUTO) .transformation(listOf()) .build() @@ -142,7 +139,6 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(ImageOverlay.Type.IMAGE) .encoding(ImageOverlay.Encoding.AUTO) .transformation(listOf()) .build() @@ -167,7 +163,6 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(VideoOverlay.Type.VIDEO) .encoding(VideoOverlay.Encoding.AUTO) .transformation(listOf()) .build() @@ -196,7 +191,6 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(VideoOverlay.Type.VIDEO) .encoding(VideoOverlay.Encoding.AUTO) .transformation(listOf()) .build() @@ -221,7 +215,6 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(SubtitleOverlay.Type.SUBTITLE) .encoding(SubtitleOverlay.Encoding.AUTO) .addTransformation( SubtitleOverlayTransformation.builder() @@ -260,7 +253,6 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(SubtitleOverlay.Type.SUBTITLE) .encoding(SubtitleOverlay.Encoding.AUTO) .addTransformation( SubtitleOverlayTransformation.builder() @@ -295,12 +287,11 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .color("color") - .type(SolidColorOverlay.Type.SOLID_COLOR) .addTransformation( SolidColorOverlayTransformation.builder() .alpha(1.0) .background("background") - .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .height(0.0) .radius(0.0) .width(0.0) @@ -332,12 +323,11 @@ internal class OverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .color("color") - .type(SolidColorOverlay.Type.SOLID_COLOR) .addTransformation( SolidColorOverlayTransformation.builder() .alpha(1.0) .background("background") - .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .height(0.0) .radius(0.0) .width(0.0) 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 81c5191b..7989cf7e 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 @@ -23,12 +23,11 @@ internal class SolidColorOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .color("color") - .type(SolidColorOverlay.Type.SOLID_COLOR) .addTransformation( SolidColorOverlayTransformation.builder() .alpha(1.0) .background("background") - .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .height(0.0) .radius(0.0) .width(0.0) @@ -43,13 +42,12 @@ internal class SolidColorOverlayTest { assertThat(solidColorOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) assertThat(solidColorOverlay.color()).isEqualTo("color") - assertThat(solidColorOverlay.type()).isEqualTo(SolidColorOverlay.Type.SOLID_COLOR) assertThat(solidColorOverlay.transformation().getOrNull()) .containsExactly( SolidColorOverlayTransformation.builder() .alpha(1.0) .background("background") - .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .height(0.0) .radius(0.0) .width(0.0) @@ -71,12 +69,11 @@ internal class SolidColorOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .color("color") - .type(SolidColorOverlay.Type.SOLID_COLOR) .addTransformation( SolidColorOverlayTransformation.builder() .alpha(1.0) .background("background") - .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .height(0.0) .radius(0.0) .width(0.0) 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 d2d418e7..d5802c92 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 @@ -15,7 +15,7 @@ internal class SolidColorOverlayTransformationTest { SolidColorOverlayTransformation.builder() .alpha(1.0) .background("background") - .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .height(0.0) .radius(0.0) .width(0.0) @@ -24,11 +24,7 @@ internal class SolidColorOverlayTransformationTest { assertThat(solidColorOverlayTransformation.alpha()).contains(1.0) assertThat(solidColorOverlayTransformation.background()).contains("background") assertThat(solidColorOverlayTransformation.gradient()) - .contains( - SolidColorOverlayTransformation.Gradient.ofUnionMember0( - SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE - ) - ) + .contains(SolidColorOverlayTransformation.Gradient.ofTrue()) assertThat(solidColorOverlayTransformation.height()) .contains(SolidColorOverlayTransformation.Height.ofNumber(0.0)) assertThat(solidColorOverlayTransformation.radius()) @@ -44,7 +40,7 @@ internal class SolidColorOverlayTransformationTest { SolidColorOverlayTransformation.builder() .alpha(1.0) .background("background") - .gradient(SolidColorOverlayTransformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .height(0.0) .radius(0.0) .width(0.0) 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 9899d6f3..fc2f51e4 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 @@ -25,7 +25,8 @@ internal class SrcOptionsTest { .addTransformation( Transformation.builder() .aiChangeBackground("aiChangeBackground") - .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .aiDropShadowTrue() + .aiEdit("aiEdit") .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) .aiRetouch(Transformation.AiRetouch.TRUE) @@ -47,7 +48,7 @@ internal class SrcOptionsTest { .flip(Transformation.Flip.H) .focus("center") .format(Transformation.Format.AUTO) - .gradient(Transformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .grayscale(Transformation.Grayscale.TRUE) .height(200.0) .lossless(true) @@ -61,12 +62,12 @@ internal class SrcOptionsTest { .radius(20.0) .raw("raw") .rotation(90.0) - .shadow(Transformation.Shadow.UnionMember0.TRUE) - .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .shadowTrue() + .sharpenTrue() .startOffset(0.0) .addStreamingResolution(StreamingResolution._240) - .trim(Transformation.Trim.UnionMember0.TRUE) - .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .trimTrue() + .unsharpMaskTrue() .videoCodec(Transformation.VideoCodec.H264) .width(300.0) .x(0.0) @@ -91,7 +92,8 @@ internal class SrcOptionsTest { .containsExactly( Transformation.builder() .aiChangeBackground("aiChangeBackground") - .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .aiDropShadowTrue() + .aiEdit("aiEdit") .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) .aiRetouch(Transformation.AiRetouch.TRUE) @@ -113,7 +115,7 @@ internal class SrcOptionsTest { .flip(Transformation.Flip.H) .focus("center") .format(Transformation.Format.AUTO) - .gradient(Transformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .grayscale(Transformation.Grayscale.TRUE) .height(200.0) .lossless(true) @@ -127,12 +129,12 @@ internal class SrcOptionsTest { .radius(20.0) .raw("raw") .rotation(90.0) - .shadow(Transformation.Shadow.UnionMember0.TRUE) - .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .shadowTrue() + .sharpenTrue() .startOffset(0.0) .addStreamingResolution(StreamingResolution._240) - .trim(Transformation.Trim.UnionMember0.TRUE) - .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .trimTrue() + .unsharpMaskTrue() .videoCodec(Transformation.VideoCodec.H264) .width(300.0) .x(0.0) @@ -160,7 +162,8 @@ internal class SrcOptionsTest { .addTransformation( Transformation.builder() .aiChangeBackground("aiChangeBackground") - .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .aiDropShadowTrue() + .aiEdit("aiEdit") .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) .aiRetouch(Transformation.AiRetouch.TRUE) @@ -182,7 +185,7 @@ internal class SrcOptionsTest { .flip(Transformation.Flip.H) .focus("center") .format(Transformation.Format.AUTO) - .gradient(Transformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .grayscale(Transformation.Grayscale.TRUE) .height(200.0) .lossless(true) @@ -196,12 +199,12 @@ internal class SrcOptionsTest { .radius(20.0) .raw("raw") .rotation(90.0) - .shadow(Transformation.Shadow.UnionMember0.TRUE) - .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .shadowTrue() + .sharpenTrue() .startOffset(0.0) .addStreamingResolution(StreamingResolution._240) - .trim(Transformation.Trim.UnionMember0.TRUE) - .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .trimTrue() + .unsharpMaskTrue() .videoCodec(Transformation.VideoCodec.H264) .width(300.0) .x(0.0) 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 f618c812..c0f445a6 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 @@ -23,7 +23,6 @@ internal class SubtitleOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(SubtitleOverlay.Type.SUBTITLE) .encoding(SubtitleOverlay.Encoding.AUTO) .addTransformation( SubtitleOverlayTransformation.builder() @@ -45,7 +44,6 @@ internal class SubtitleOverlayTest { assertThat(subtitleOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) assertThat(subtitleOverlay.input()).isEqualTo("input") - assertThat(subtitleOverlay.type()).isEqualTo(SubtitleOverlay.Type.SUBTITLE) assertThat(subtitleOverlay.encoding()).contains(SubtitleOverlay.Encoding.AUTO) assertThat(subtitleOverlay.transformation().getOrNull()) .containsExactly( @@ -75,7 +73,6 @@ internal class SubtitleOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(SubtitleOverlay.Type.SUBTITLE) .encoding(SubtitleOverlay.Encoding.AUTO) .addTransformation( SubtitleOverlayTransformation.builder() 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 index 4cd570f8..1fcf8c66 100644 --- 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 @@ -27,8 +27,7 @@ internal class SubtitleOverlayTransformationTest { assertThat(subtitleOverlayTransformation.fontFamily()).contains("fontFamily") assertThat(subtitleOverlayTransformation.fontOutline()).contains("fontOutline") assertThat(subtitleOverlayTransformation.fontShadow()).contains("fontShadow") - assertThat(subtitleOverlayTransformation.fontSize()) - .contains(SubtitleOverlayTransformation.FontSize.ofNumber(0.0)) + assertThat(subtitleOverlayTransformation.fontSize()).contains(0.0) assertThat(subtitleOverlayTransformation.typography()) .contains(SubtitleOverlayTransformation.Typography.B) } 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 a92907f2..6b3a27b4 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 @@ -23,7 +23,6 @@ internal class TextOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .text("text") - .type(TextOverlay.Type.TEXT) .encoding(TextOverlay.Encoding.AUTO) .addTransformation( TextOverlayTransformation.builder() @@ -38,7 +37,7 @@ internal class TextOverlayTest { .padding(0.0) .radius(0.0) .rotation(0.0) - .typography(TextOverlayTransformation.Typography.B) + .typography("typography") .width(0.0) .build() ) @@ -51,7 +50,6 @@ internal class TextOverlayTest { assertThat(textOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) assertThat(textOverlay.text()).isEqualTo("text") - assertThat(textOverlay.type()).isEqualTo(TextOverlay.Type.TEXT) assertThat(textOverlay.encoding()).contains(TextOverlay.Encoding.AUTO) assertThat(textOverlay.transformation().getOrNull()) .containsExactly( @@ -67,7 +65,7 @@ internal class TextOverlayTest { .padding(0.0) .radius(0.0) .rotation(0.0) - .typography(TextOverlayTransformation.Typography.B) + .typography("typography") .width(0.0) .build() ) @@ -87,7 +85,6 @@ internal class TextOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .text("text") - .type(TextOverlay.Type.TEXT) .encoding(TextOverlay.Encoding.AUTO) .addTransformation( TextOverlayTransformation.builder() @@ -102,7 +99,7 @@ internal class TextOverlayTest { .padding(0.0) .radius(0.0) .rotation(0.0) - .typography(TextOverlayTransformation.Typography.B) + .typography("typography") .width(0.0) .build() ) 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 ed8edaea..f07cd592 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 @@ -24,7 +24,7 @@ internal class TextOverlayTransformationTest { .padding(0.0) .radius(0.0) .rotation(0.0) - .typography(TextOverlayTransformation.Typography.B) + .typography("typography") .width(0.0) .build() @@ -45,8 +45,7 @@ internal class TextOverlayTransformationTest { .contains(TextOverlayTransformation.Radius.ofNumber(0.0)) assertThat(textOverlayTransformation.rotation()) .contains(TextOverlayTransformation.Rotation.ofNumber(0.0)) - assertThat(textOverlayTransformation.typography()) - .contains(TextOverlayTransformation.Typography.B) + assertThat(textOverlayTransformation.typography()).contains("typography") assertThat(textOverlayTransformation.width()) .contains(TextOverlayTransformation.Width.ofNumber(0.0)) } @@ -67,7 +66,7 @@ internal class TextOverlayTransformationTest { .padding(0.0) .radius(0.0) .rotation(0.0) - .typography(TextOverlayTransformation.Typography.B) + .typography("typography") .width(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 87e44a66..3dee6fd4 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 @@ -15,7 +15,8 @@ internal class TransformationTest { val transformation = Transformation.builder() .aiChangeBackground("aiChangeBackground") - .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .aiDropShadowTrue() + .aiEdit("aiEdit") .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) .aiRetouch(Transformation.AiRetouch.TRUE) @@ -37,7 +38,7 @@ internal class TransformationTest { .flip(Transformation.Flip.H) .focus("center") .format(Transformation.Format.AUTO) - .gradient(Transformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .grayscale(Transformation.Grayscale.TRUE) .height(200.0) .lossless(true) @@ -51,12 +52,12 @@ internal class TransformationTest { .radius(20.0) .raw("raw") .rotation(90.0) - .shadow(Transformation.Shadow.UnionMember0.TRUE) - .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .shadowTrue() + .sharpenTrue() .startOffset(0.0) .addStreamingResolution(StreamingResolution._240) - .trim(Transformation.Trim.UnionMember0.TRUE) - .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .trimTrue() + .unsharpMaskTrue() .videoCodec(Transformation.VideoCodec.H264) .width(300.0) .x(0.0) @@ -67,12 +68,8 @@ internal class TransformationTest { .build() assertThat(transformation.aiChangeBackground()).contains("aiChangeBackground") - assertThat(transformation.aiDropShadow()) - .contains( - Transformation.AiDropShadow.ofUnionMember0( - Transformation.AiDropShadow.UnionMember0.TRUE - ) - ) + assertThat(transformation.aiDropShadow()).contains(Transformation.AiDropShadow.ofTrue()) + assertThat(transformation.aiEdit()).contains("aiEdit") assertThat(transformation.aiRemoveBackground()) .contains(Transformation.AiRemoveBackground.TRUE) assertThat(transformation.aiRemoveBackgroundExternal()) @@ -97,10 +94,7 @@ internal class TransformationTest { 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.ofUnionMember0(Transformation.Gradient.UnionMember0.TRUE) - ) + 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) @@ -114,23 +108,13 @@ internal class TransformationTest { 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.ofUnionMember0(Transformation.Shadow.UnionMember0.TRUE)) - assertThat(transformation.sharpen()) - .contains( - Transformation.Sharpen.ofUnionMember0(Transformation.Sharpen.UnionMember0.TRUE) - ) + 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.ofUnionMember0(Transformation.Trim.UnionMember0.TRUE)) - assertThat(transformation.unsharpMask()) - .contains( - Transformation.UnsharpMask.ofUnionMember0( - Transformation.UnsharpMask.UnionMember0.TRUE - ) - ) + 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)) @@ -146,7 +130,8 @@ internal class TransformationTest { val transformation = Transformation.builder() .aiChangeBackground("aiChangeBackground") - .aiDropShadow(Transformation.AiDropShadow.UnionMember0.TRUE) + .aiDropShadowTrue() + .aiEdit("aiEdit") .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) .aiRetouch(Transformation.AiRetouch.TRUE) @@ -168,7 +153,7 @@ internal class TransformationTest { .flip(Transformation.Flip.H) .focus("center") .format(Transformation.Format.AUTO) - .gradient(Transformation.Gradient.UnionMember0.TRUE) + .gradientTrue() .grayscale(Transformation.Grayscale.TRUE) .height(200.0) .lossless(true) @@ -182,12 +167,12 @@ internal class TransformationTest { .radius(20.0) .raw("raw") .rotation(90.0) - .shadow(Transformation.Shadow.UnionMember0.TRUE) - .sharpen(Transformation.Sharpen.UnionMember0.TRUE) + .shadowTrue() + .sharpenTrue() .startOffset(0.0) .addStreamingResolution(StreamingResolution._240) - .trim(Transformation.Trim.UnionMember0.TRUE) - .unsharpMask(Transformation.UnsharpMask.UnionMember0.TRUE) + .trimTrue() + .unsharpMaskTrue() .videoCodec(Transformation.VideoCodec.H264) .width(300.0) .x(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 aad60f9b..caca3a99 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 @@ -23,7 +23,6 @@ internal class VideoOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(VideoOverlay.Type.VIDEO) .encoding(VideoOverlay.Encoding.AUTO) .transformation(listOf()) .build() @@ -35,7 +34,6 @@ internal class VideoOverlayTest { assertThat(videoOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) assertThat(videoOverlay.input()).isEqualTo("input") - assertThat(videoOverlay.type()).isEqualTo(VideoOverlay.Type.VIDEO) assertThat(videoOverlay.encoding()).contains(VideoOverlay.Encoding.AUTO) assertThat(videoOverlay.transformation().getOrNull()).containsExactly() } @@ -54,7 +52,6 @@ internal class VideoOverlayTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") - .type(VideoOverlay.Type.VIDEO) .encoding(VideoOverlay.Encoding.AUTO) .transformation(listOf()) .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 dfd0c0e4..870ff9aa 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.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -86,6 +87,10 @@ internal class UnsafeUnwrapWebhookEventTest { .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 @@ -257,6 +262,10 @@ internal class UnsafeUnwrapWebhookEventTest { 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 @@ -439,6 +448,10 @@ internal class UnsafeUnwrapWebhookEventTest { 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 @@ -528,6 +541,675 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) } + @Test + fun ofUploadPreTransformSuccess() { + val uploadPreTransformSuccess = + UploadPreTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessWebhookEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + .awsAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessWebhookEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + .awsAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessWebhookEvent.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 = + UploadPreTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorWebhookEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorWebhookEvent.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( + UploadPreTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorWebhookEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorWebhookEvent.Data.Transformation + .Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorWebhookEvent.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 = + UploadPostTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessWebhookEvent.Request.builder() + .transformation( + UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessWebhookEvent.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( + UploadPostTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessWebhookEvent.Request.builder() + .transformation( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .builder() + .type( + UploadPostTransformSuccessWebhookEvent.Request + .Transformation + .Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessWebhookEvent.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 = + UploadPostTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorWebhookEvent.Request.builder() + .transformation( + UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorWebhookEvent.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( + UploadPostTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorWebhookEvent.Data.Transformation + .Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorWebhookEvent.Request.builder() + .transformation( + UploadPostTransformErrorWebhookEvent.Request.Transformation + .builder() + .type( + UploadPostTransformErrorWebhookEvent.Request.Transformation + .Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorWebhookEvent.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")), 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 1af001c6..ac1b4b64 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.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -86,6 +87,10 @@ internal class UnwrapWebhookEventTest { .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 @@ -256,6 +261,10 @@ internal class UnwrapWebhookEventTest { 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 @@ -437,6 +446,10 @@ internal class UnwrapWebhookEventTest { 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 @@ -526,6 +539,673 @@ internal class UnwrapWebhookEventTest { assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) } + @Test + fun ofUploadPreTransformSuccess() { + val uploadPreTransformSuccess = + UploadPreTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessWebhookEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + .awsAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessWebhookEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + .awsAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessWebhookEvent.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 = + UploadPreTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorWebhookEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorWebhookEvent.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( + UploadPreTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorWebhookEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorWebhookEvent.Data.Transformation + .Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorWebhookEvent.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 = + UploadPostTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessWebhookEvent.Request.builder() + .transformation( + UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessWebhookEvent.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( + UploadPostTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessWebhookEvent.Request.builder() + .transformation( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .builder() + .type( + UploadPostTransformSuccessWebhookEvent.Request + .Transformation + .Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessWebhookEvent.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 = + UploadPostTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorWebhookEvent.Request.builder() + .transformation( + UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorWebhookEvent.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( + UploadPostTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorWebhookEvent.Data.Transformation + .Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorWebhookEvent.Request.builder() + .transformation( + UploadPostTransformErrorWebhookEvent.Request.Transformation + .builder() + .type( + UploadPostTransformErrorWebhookEvent.Request.Transformation + .Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorWebhookEvent.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")), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEventTest.kt new file mode 100644 index 00000000..f13f7191 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEventTest.kt @@ -0,0 +1,156 @@ +// 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 UploadPostTransformErrorWebhookEventTest { + + @Test + fun create() { + val uploadPostTransformErrorWebhookEvent = + UploadPostTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorWebhookEvent.Request.builder() + .transformation( + UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorWebhookEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + assertThat(uploadPostTransformErrorWebhookEvent.id()).isEqualTo("id") + assertThat(uploadPostTransformErrorWebhookEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(uploadPostTransformErrorWebhookEvent.data()) + .isEqualTo( + UploadPostTransformErrorWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + assertThat(uploadPostTransformErrorWebhookEvent.request()) + .isEqualTo( + UploadPostTransformErrorWebhookEvent.Request.builder() + .transformation( + UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorWebhookEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val uploadPostTransformErrorWebhookEvent = + UploadPostTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorWebhookEvent.Request.builder() + .transformation( + UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorWebhookEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + val roundtrippedUploadPostTransformErrorWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(uploadPostTransformErrorWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUploadPostTransformErrorWebhookEvent) + .isEqualTo(uploadPostTransformErrorWebhookEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEventTest.kt new file mode 100644 index 00000000..874fe9ce --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEventTest.kt @@ -0,0 +1,126 @@ +// 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 UploadPostTransformSuccessWebhookEventTest { + + @Test + fun create() { + val uploadPostTransformSuccessWebhookEvent = + UploadPostTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessWebhookEvent.Request.builder() + .transformation( + UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + assertThat(uploadPostTransformSuccessWebhookEvent.id()).isEqualTo("id") + assertThat(uploadPostTransformSuccessWebhookEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(uploadPostTransformSuccessWebhookEvent.data()) + .isEqualTo( + UploadPostTransformSuccessWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + assertThat(uploadPostTransformSuccessWebhookEvent.request()) + .isEqualTo( + UploadPostTransformSuccessWebhookEvent.Request.builder() + .transformation( + UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessWebhookEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val uploadPostTransformSuccessWebhookEvent = + UploadPostTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessWebhookEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessWebhookEvent.Request.builder() + .transformation( + UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessWebhookEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + val roundtrippedUploadPostTransformSuccessWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(uploadPostTransformSuccessWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUploadPostTransformSuccessWebhookEvent) + .isEqualTo(uploadPostTransformSuccessWebhookEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEventTest.kt new file mode 100644 index 00000000..66f31ad2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEventTest.kt @@ -0,0 +1,112 @@ +// 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 UploadPreTransformErrorWebhookEventTest { + + @Test + fun create() { + val uploadPreTransformErrorWebhookEvent = + UploadPreTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorWebhookEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorWebhookEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + assertThat(uploadPreTransformErrorWebhookEvent.id()).isEqualTo("id") + assertThat(uploadPreTransformErrorWebhookEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(uploadPreTransformErrorWebhookEvent.data()) + .isEqualTo( + UploadPreTransformErrorWebhookEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + assertThat(uploadPreTransformErrorWebhookEvent.request()) + .isEqualTo( + UploadPreTransformErrorWebhookEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val uploadPreTransformErrorWebhookEvent = + UploadPreTransformErrorWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorWebhookEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorWebhookEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorWebhookEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + val roundtrippedUploadPreTransformErrorWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(uploadPreTransformErrorWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUploadPreTransformErrorWebhookEvent) + .isEqualTo(uploadPreTransformErrorWebhookEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEventTest.kt new file mode 100644 index 00000000..8353cca7 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEventTest.kt @@ -0,0 +1,525 @@ +// 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 UploadPreTransformSuccessWebhookEventTest { + + @Test + fun create() { + val uploadPreTransformSuccessWebhookEvent = + UploadPreTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessWebhookEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + .awsAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessWebhookEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + assertThat(uploadPreTransformSuccessWebhookEvent.id()).isEqualTo("id") + assertThat(uploadPreTransformSuccessWebhookEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(uploadPreTransformSuccessWebhookEvent.data()) + .isEqualTo( + UploadPreTransformSuccessWebhookEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + .awsAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + assertThat(uploadPreTransformSuccessWebhookEvent.request()) + .isEqualTo( + UploadPreTransformSuccessWebhookEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val uploadPreTransformSuccessWebhookEvent = + UploadPreTransformSuccessWebhookEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessWebhookEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + .awsAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessWebhookEvent.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( + UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessWebhookEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + val roundtrippedUploadPreTransformSuccessWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(uploadPreTransformSuccessWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUploadPreTransformSuccessWebhookEvent) + .isEqualTo(uploadPreTransformSuccessWebhookEvent) + } +} 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 a8234353..6b3c1c94 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 @@ -125,7 +125,6 @@ internal class ProGuardCompatibilityTest { ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .text("text") - .type(TextOverlay.Type.TEXT) .encoding(TextOverlay.Encoding.AUTO) .addTransformation( TextOverlayTransformation.builder() @@ -140,7 +139,7 @@ internal class ProGuardCompatibilityTest { .padding(0.0) .radius(0.0) .rotation(0.0) - .typography(TextOverlayTransformation.Typography.B) + .typography("typography") .width(0.0) .build() ) From 9eccad08f6c2dffe2b5df5960f49b62d10fab778 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 31 Aug 2025 08:50:44 +0000 Subject: [PATCH 080/125] feat(api): manual updates --- .stats.yml | 4 ++-- .../webhooks/VideoTransformationAcceptedEvent.kt | 12 +++++++++--- .../models/webhooks/VideoTransformationErrorEvent.kt | 12 +++++++++--- .../models/webhooks/VideoTransformationReadyEvent.kt | 12 +++++++++--- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.stats.yml b/.stats.yml index caed6f5a..66a8df1f 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-0cdbdd05084a8219bc003a34670472f198cf91e5f6402cede2cb1094b7bfd98d.yml -openapi_spec_hash: d337c89146f41fa215560bb5aef2e4ec +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-a49f0e337789b1a4368194ed004ac4c1b0c0cd2ce4344e14546422632242d897.yml +openapi_spec_hash: a7f3999c6227aac108cd80253ffc7730 config_hash: 249ee22f294858ab0971b8379f7cb519 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 50f7bc07..f31e7f90 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 @@ -1088,7 +1088,7 @@ private constructor( fun variants(): Optional> = variants.getOptional("variants") /** - * Video codec used for encoding (h264 or vp9). + * 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). @@ -1296,7 +1296,7 @@ private constructor( } } - /** Video codec used for encoding (h264 or vp9). */ + /** Video codec used for encoding (h264, vp9, or av1). */ fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) /** @@ -1819,7 +1819,7 @@ private constructor( override fun toString() = value.toString() } - /** Video codec used for encoding (h264 or vp9). */ + /** Video codec used for encoding (h264, vp9, or av1). */ class VideoCodec @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1841,6 +1841,8 @@ private constructor( @JvmField val VP9 = of("vp9") + @JvmField val AV1 = of("av1") + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) } @@ -1848,6 +1850,7 @@ private constructor( enum class Known { H264, VP9, + AV1, } /** @@ -1864,6 +1867,7 @@ private constructor( enum class Value { H264, VP9, + AV1, /** * An enum member indicating that [VideoCodec] was instantiated with an * unknown value. @@ -1882,6 +1886,7 @@ private constructor( when (this) { H264 -> Value.H264 VP9 -> Value.VP9 + AV1 -> Value.AV1 else -> Value._UNKNOWN } @@ -1898,6 +1903,7 @@ private constructor( when (this) { H264 -> Known.H264 VP9 -> Known.VP9 + AV1 -> Known.AV1 else -> throw ImageKitInvalidDataException("Unknown VideoCodec: $value") } 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 755c167a..ee6f310c 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 @@ -1434,7 +1434,7 @@ private constructor( fun variants(): Optional> = variants.getOptional("variants") /** - * Video codec used for encoding (h264 or vp9). + * 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). @@ -1642,7 +1642,7 @@ private constructor( } } - /** Video codec used for encoding (h264 or vp9). */ + /** Video codec used for encoding (h264, vp9, or av1). */ fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) /** @@ -2165,7 +2165,7 @@ private constructor( override fun toString() = value.toString() } - /** Video codec used for encoding (h264 or vp9). */ + /** Video codec used for encoding (h264, vp9, or av1). */ class VideoCodec @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2187,6 +2187,8 @@ private constructor( @JvmField val VP9 = of("vp9") + @JvmField val AV1 = of("av1") + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) } @@ -2194,6 +2196,7 @@ private constructor( enum class Known { H264, VP9, + AV1, } /** @@ -2210,6 +2213,7 @@ private constructor( enum class Value { H264, VP9, + AV1, /** * An enum member indicating that [VideoCodec] was instantiated with an * unknown value. @@ -2228,6 +2232,7 @@ private constructor( when (this) { H264 -> Value.H264 VP9 -> Value.VP9 + AV1 -> Value.AV1 else -> Value._UNKNOWN } @@ -2244,6 +2249,7 @@ private constructor( when (this) { H264 -> Known.H264 VP9 -> Known.VP9 + AV1 -> Known.AV1 else -> throw ImageKitInvalidDataException("Unknown VideoCodec: $value") } 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 0358af06..82654cde 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 @@ -1149,7 +1149,7 @@ private constructor( fun variants(): Optional> = variants.getOptional("variants") /** - * Video codec used for encoding (h264 or vp9). + * 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). @@ -1357,7 +1357,7 @@ private constructor( } } - /** Video codec used for encoding (h264 or vp9). */ + /** Video codec used for encoding (h264, vp9, or av1). */ fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) /** @@ -1880,7 +1880,7 @@ private constructor( override fun toString() = value.toString() } - /** Video codec used for encoding (h264 or vp9). */ + /** Video codec used for encoding (h264, vp9, or av1). */ class VideoCodec @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1902,6 +1902,8 @@ private constructor( @JvmField val VP9 = of("vp9") + @JvmField val AV1 = of("av1") + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) } @@ -1909,6 +1911,7 @@ private constructor( enum class Known { H264, VP9, + AV1, } /** @@ -1925,6 +1928,7 @@ private constructor( enum class Value { H264, VP9, + AV1, /** * An enum member indicating that [VideoCodec] was instantiated with an * unknown value. @@ -1943,6 +1947,7 @@ private constructor( when (this) { H264 -> Value.H264 VP9 -> Value.VP9 + AV1 -> Value.AV1 else -> Value._UNKNOWN } @@ -1959,6 +1964,7 @@ private constructor( when (this) { H264 -> Known.H264 VP9 -> Known.VP9 + AV1 -> Known.AV1 else -> throw ImageKitInvalidDataException("Unknown VideoCodec: $value") } From 0cb5b3a3c915b12793d0a432d16be8662b52a99d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 05:28:01 +0000 Subject: [PATCH 081/125] feat(api): add signed URL options with expiration settings to enhance security features --- .stats.yml | 4 +- .../com/imagekit/api/models/SrcOptions.kt | 105 +++++++++++++++++- .../com/imagekit/api/models/SrcOptionsTest.kt | 6 + 3 files changed, 112 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 66a8df1f..cb2a3979 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-a49f0e337789b1a4368194ed004ac4c1b0c0cd2ce4344e14546422632242d897.yml -openapi_spec_hash: a7f3999c6227aac108cd80253ffc7730 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d857341f30517b11df568dd6c5a0e9dea3a854930f7f6583718114d311f2d5ee.yml +openapi_spec_hash: db94bfd556220d6244a1b2bbae9d7d00 config_hash: 249ee22f294858ab0971b8379f7cb519 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 09f3b4ce..24c50b25 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 @@ -27,7 +27,9 @@ 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, @@ -39,9 +41,11 @@ private constructor( @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(), @@ -51,7 +55,9 @@ private constructor( ) : this( src, urlEndpoint, + expiresIn, queryParameters, + signed, transformation, transformationPosition, mutableMapOf(), @@ -75,6 +81,23 @@ private constructor( */ 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 @@ -86,6 +109,18 @@ private constructor( 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 @@ -124,6 +159,13 @@ private constructor( */ @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]. * @@ -133,6 +175,13 @@ private constructor( @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]. * @@ -183,7 +232,9 @@ private 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() @@ -192,7 +243,9 @@ private constructor( 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() @@ -228,6 +281,29 @@ private constructor( */ 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 @@ -247,6 +323,23 @@ private constructor( 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 @@ -336,7 +429,9 @@ private constructor( SrcOptions( checkRequired("src", src), checkRequired("urlEndpoint", urlEndpoint), + expiresIn, queryParameters, + signed, (transformation ?: JsonMissing.of()).map { it.toImmutable() }, transformationPosition, additionalProperties.toMutableMap(), @@ -352,7 +447,9 @@ private constructor( src() urlEndpoint() + expiresIn() queryParameters().ifPresent { it.validate() } + signed() transformation().ifPresent { it.forEach { it.validate() } } transformationPosition().ifPresent { it.validate() } validated = true @@ -375,7 +472,9 @@ private constructor( 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) @@ -491,7 +590,9 @@ private constructor( 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 @@ -501,7 +602,9 @@ private constructor( Objects.hash( src, urlEndpoint, + expiresIn, queryParameters, + signed, transformation, transformationPosition, additionalProperties, @@ -511,5 +614,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SrcOptions{src=$src, urlEndpoint=$urlEndpoint, queryParameters=$queryParameters, transformation=$transformation, transformationPosition=$transformationPosition, additionalProperties=$additionalProperties}" + "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/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt index fc2f51e4..a475e8e1 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 @@ -17,11 +17,13 @@ internal class SrcOptionsTest { 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") @@ -82,12 +84,14 @@ internal class SrcOptionsTest { 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() @@ -154,11 +158,13 @@ internal class SrcOptionsTest { 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") From 87b19f4f2b4b361fff298fb0ecc301fcf5b388be Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 08:33:37 +0000 Subject: [PATCH 082/125] feat(api): add new webhook events for upload transformations to enhance event tracking --- .stats.yml | 2 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 94 +++++------- .../api/models/webhooks/UnwrapWebhookEvent.kt | 91 +++++------- ...nt.kt => UploadPostTransformErrorEvent.kt} | 35 +++-- ....kt => UploadPostTransformSuccessEvent.kt} | 39 +++-- ...ent.kt => UploadPreTransformErrorEvent.kt} | 36 +++-- ...t.kt => UploadPreTransformSuccessEvent.kt} | 34 +++-- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 135 ++++++++---------- .../models/webhooks/UnwrapWebhookEventTest.kt | 135 ++++++++---------- ...t => UploadPostTransformErrorEventTest.kt} | 74 +++++----- ...=> UploadPostTransformSuccessEventTest.kt} | 64 ++++----- ...kt => UploadPreTransformErrorEventTest.kt} | 54 ++++--- ... => UploadPreTransformSuccessEventTest.kt} | 92 ++++++------ 13 files changed, 399 insertions(+), 486 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{UploadPostTransformErrorWebhookEvent.kt => UploadPostTransformErrorEvent.kt} (98%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{UploadPostTransformSuccessWebhookEvent.kt => UploadPostTransformSuccessEvent.kt} (97%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{UploadPreTransformErrorWebhookEvent.kt => UploadPreTransformErrorEvent.kt} (97%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{UploadPreTransformSuccessWebhookEvent.kt => UploadPreTransformSuccessEvent.kt} (99%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{UploadPostTransformErrorWebhookEventTest.kt => UploadPostTransformErrorEventTest.kt} (59%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{UploadPostTransformSuccessWebhookEventTest.kt => UploadPostTransformSuccessEventTest.kt} (54%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{UploadPreTransformErrorWebhookEventTest.kt => UploadPreTransformErrorEventTest.kt} (57%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{UploadPreTransformSuccessWebhookEventTest.kt => UploadPreTransformSuccessEventTest.kt} (86%) diff --git a/.stats.yml b/.stats.yml index cb2a3979..6bb89db0 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-d857341f30517b11df568dd6c5a0e9dea3a854930f7f6583718114d311f2d5ee.yml openapi_spec_hash: db94bfd556220d6244a1b2bbae9d7d00 -config_hash: 249ee22f294858ab0971b8379f7cb519 +config_hash: 4ef178e13ecfdb97211f284f13a21e83 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 fb6fb3c3..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 @@ -30,10 +30,10 @@ private constructor( private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, private val videoTransformationReady: VideoTransformationReadyEvent? = null, private val videoTransformationError: VideoTransformationErrorEvent? = null, - private val uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent? = null, - private val uploadPreTransformError: UploadPreTransformErrorWebhookEvent? = null, - private val uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent? = null, - private val uploadPostTransformError: UploadPostTransformErrorWebhookEvent? = 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, ) { @@ -65,14 +65,14 @@ private constructor( * 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 = + 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 = + fun uploadPreTransformError(): Optional = Optional.ofNullable(uploadPreTransformError) /** @@ -80,14 +80,14 @@ private constructor( * 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 = + 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 = + fun uploadPostTransformError(): Optional = Optional.ofNullable(uploadPostTransformError) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -132,14 +132,14 @@ private constructor( * 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(): UploadPreTransformSuccessWebhookEvent = + 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(): UploadPreTransformErrorWebhookEvent = + fun asUploadPreTransformError(): UploadPreTransformErrorEvent = uploadPreTransformError.getOrThrow("uploadPreTransformError") /** @@ -147,14 +147,14 @@ private constructor( * file is now ready and can be accessed via the provided URL. Note that each * post-transformation generates a separate webhook event. */ - fun asUploadPostTransformSuccess(): UploadPostTransformSuccessWebhookEvent = + 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(): UploadPostTransformErrorWebhookEvent = + fun asUploadPostTransformError(): UploadPostTransformErrorEvent = uploadPostTransformError.getOrThrow("uploadPostTransformError") fun _json(): Optional = Optional.ofNullable(_json) @@ -206,25 +206,25 @@ private constructor( } override fun visitUploadPreTransformSuccess( - uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + uploadPreTransformSuccess: UploadPreTransformSuccessEvent ) { uploadPreTransformSuccess.validate() } override fun visitUploadPreTransformError( - uploadPreTransformError: UploadPreTransformErrorWebhookEvent + uploadPreTransformError: UploadPreTransformErrorEvent ) { uploadPreTransformError.validate() } override fun visitUploadPostTransformSuccess( - uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) { uploadPostTransformSuccess.validate() } override fun visitUploadPostTransformError( - uploadPostTransformError: UploadPostTransformErrorWebhookEvent + uploadPostTransformError: UploadPostTransformErrorEvent ) { uploadPostTransformError.validate() } @@ -263,19 +263,19 @@ private constructor( ) = videoTransformationError.validity() override fun visitUploadPreTransformSuccess( - uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + uploadPreTransformSuccess: UploadPreTransformSuccessEvent ) = uploadPreTransformSuccess.validity() override fun visitUploadPreTransformError( - uploadPreTransformError: UploadPreTransformErrorWebhookEvent + uploadPreTransformError: UploadPreTransformErrorEvent ) = uploadPreTransformError.validity() override fun visitUploadPostTransformSuccess( - uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) = uploadPostTransformSuccess.validity() override fun visitUploadPostTransformError( - uploadPostTransformError: UploadPostTransformErrorWebhookEvent + uploadPostTransformError: UploadPostTransformErrorEvent ) = uploadPostTransformError.validity() override fun unknown(json: JsonValue?) = 0 @@ -363,18 +363,16 @@ private constructor( * with the requested transformation and is now available in the Media Library. */ @JvmStatic - fun ofUploadPreTransformSuccess( - uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent - ) = UnsafeUnwrapWebhookEvent(uploadPreTransformSuccess = uploadPreTransformSuccess) + 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: UploadPreTransformErrorWebhookEvent - ) = UnsafeUnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) + fun ofUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent) = + UnsafeUnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) /** * Triggered when a post-transformation completes successfully. The transformed version of @@ -383,7 +381,7 @@ private constructor( */ @JvmStatic fun ofUploadPostTransformSuccess( - uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) = UnsafeUnwrapWebhookEvent(uploadPostTransformSuccess = uploadPostTransformSuccess) /** @@ -391,9 +389,8 @@ private constructor( * requested transformation could not be generated. */ @JvmStatic - fun ofUploadPostTransformError( - uploadPostTransformError: UploadPostTransformErrorWebhookEvent - ) = UnsafeUnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) + fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = + UnsafeUnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) } /** @@ -434,16 +431,14 @@ private constructor( * with the requested transformation and is now available in the Media Library. */ fun visitUploadPreTransformSuccess( - uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + 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: UploadPreTransformErrorWebhookEvent - ): T + fun visitUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent): T /** * Triggered when a post-transformation completes successfully. The transformed version of @@ -451,7 +446,7 @@ private constructor( * post-transformation generates a separate webhook event. */ fun visitUploadPostTransformSuccess( - uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + uploadPostTransformSuccess: UploadPostTransformSuccessEvent ): T /** @@ -459,7 +454,7 @@ private constructor( * requested transformation could not be generated. */ fun visitUploadPostTransformError( - uploadPostTransformError: UploadPostTransformErrorWebhookEvent + uploadPostTransformError: UploadPostTransformErrorEvent ): T /** @@ -498,37 +493,26 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UnsafeUnwrapWebhookEvent(videoTransformationError = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) + tryDeserialize(node, jacksonTypeRef()) ?.let { UnsafeUnwrapWebhookEvent( uploadPreTransformSuccess = it, _json = json, ) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnsafeUnwrapWebhookEvent(uploadPreTransformError = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) + 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, - ) - }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(uploadPostTransformError = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } 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 c2a01846..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 @@ -30,10 +30,10 @@ private constructor( private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, private val videoTransformationReady: VideoTransformationReadyEvent? = null, private val videoTransformationError: VideoTransformationErrorEvent? = null, - private val uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent? = null, - private val uploadPreTransformError: UploadPreTransformErrorWebhookEvent? = null, - private val uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent? = null, - private val uploadPostTransformError: UploadPostTransformErrorWebhookEvent? = 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, ) { @@ -65,14 +65,14 @@ private constructor( * 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 = + 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 = + fun uploadPreTransformError(): Optional = Optional.ofNullable(uploadPreTransformError) /** @@ -80,14 +80,14 @@ private constructor( * 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 = + 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 = + fun uploadPostTransformError(): Optional = Optional.ofNullable(uploadPostTransformError) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -132,14 +132,14 @@ private constructor( * 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(): UploadPreTransformSuccessWebhookEvent = + 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(): UploadPreTransformErrorWebhookEvent = + fun asUploadPreTransformError(): UploadPreTransformErrorEvent = uploadPreTransformError.getOrThrow("uploadPreTransformError") /** @@ -147,14 +147,14 @@ private constructor( * file is now ready and can be accessed via the provided URL. Note that each * post-transformation generates a separate webhook event. */ - fun asUploadPostTransformSuccess(): UploadPostTransformSuccessWebhookEvent = + 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(): UploadPostTransformErrorWebhookEvent = + fun asUploadPostTransformError(): UploadPostTransformErrorEvent = uploadPostTransformError.getOrThrow("uploadPostTransformError") fun _json(): Optional = Optional.ofNullable(_json) @@ -206,25 +206,25 @@ private constructor( } override fun visitUploadPreTransformSuccess( - uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + uploadPreTransformSuccess: UploadPreTransformSuccessEvent ) { uploadPreTransformSuccess.validate() } override fun visitUploadPreTransformError( - uploadPreTransformError: UploadPreTransformErrorWebhookEvent + uploadPreTransformError: UploadPreTransformErrorEvent ) { uploadPreTransformError.validate() } override fun visitUploadPostTransformSuccess( - uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) { uploadPostTransformSuccess.validate() } override fun visitUploadPostTransformError( - uploadPostTransformError: UploadPostTransformErrorWebhookEvent + uploadPostTransformError: UploadPostTransformErrorEvent ) { uploadPostTransformError.validate() } @@ -263,19 +263,19 @@ private constructor( ) = videoTransformationError.validity() override fun visitUploadPreTransformSuccess( - uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + uploadPreTransformSuccess: UploadPreTransformSuccessEvent ) = uploadPreTransformSuccess.validity() override fun visitUploadPreTransformError( - uploadPreTransformError: UploadPreTransformErrorWebhookEvent + uploadPreTransformError: UploadPreTransformErrorEvent ) = uploadPreTransformError.validity() override fun visitUploadPostTransformSuccess( - uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) = uploadPostTransformSuccess.validity() override fun visitUploadPostTransformError( - uploadPostTransformError: UploadPostTransformErrorWebhookEvent + uploadPostTransformError: UploadPostTransformErrorEvent ) = uploadPostTransformError.validity() override fun unknown(json: JsonValue?) = 0 @@ -363,18 +363,16 @@ private constructor( * with the requested transformation and is now available in the Media Library. */ @JvmStatic - fun ofUploadPreTransformSuccess( - uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent - ) = UnwrapWebhookEvent(uploadPreTransformSuccess = uploadPreTransformSuccess) + 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: UploadPreTransformErrorWebhookEvent - ) = UnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) + fun ofUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent) = + UnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) /** * Triggered when a post-transformation completes successfully. The transformed version of @@ -383,7 +381,7 @@ private constructor( */ @JvmStatic fun ofUploadPostTransformSuccess( - uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) = UnwrapWebhookEvent(uploadPostTransformSuccess = uploadPostTransformSuccess) /** @@ -391,9 +389,8 @@ private constructor( * requested transformation could not be generated. */ @JvmStatic - fun ofUploadPostTransformError( - uploadPostTransformError: UploadPostTransformErrorWebhookEvent - ) = UnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) + fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = + UnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) } /** @@ -434,16 +431,14 @@ private constructor( * with the requested transformation and is now available in the Media Library. */ fun visitUploadPreTransformSuccess( - uploadPreTransformSuccess: UploadPreTransformSuccessWebhookEvent + 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: UploadPreTransformErrorWebhookEvent - ): T + fun visitUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent): T /** * Triggered when a post-transformation completes successfully. The transformed version of @@ -451,7 +446,7 @@ private constructor( * post-transformation generates a separate webhook event. */ fun visitUploadPostTransformSuccess( - uploadPostTransformSuccess: UploadPostTransformSuccessWebhookEvent + uploadPostTransformSuccess: UploadPostTransformSuccessEvent ): T /** @@ -459,7 +454,7 @@ private constructor( * requested transformation could not be generated. */ fun visitUploadPostTransformError( - uploadPostTransformError: UploadPostTransformErrorWebhookEvent + uploadPostTransformError: UploadPostTransformErrorEvent ): T /** @@ -494,28 +489,20 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UnwrapWebhookEvent(videoTransformationError = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) + tryDeserialize(node, jacksonTypeRef()) ?.let { UnwrapWebhookEvent(uploadPreTransformSuccess = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnwrapWebhookEvent(uploadPreTransformError = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) + 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) - }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(uploadPostTransformError = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt index dd1cb7eb..f1798541 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt @@ -23,7 +23,7 @@ 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 UploadPostTransformErrorWebhookEvent +class UploadPostTransformErrorEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -129,7 +129,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UploadPostTransformErrorWebhookEvent]. + * [UploadPostTransformErrorEvent]. * * The following fields are required: * ```java @@ -142,7 +142,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UploadPostTransformErrorWebhookEvent]. */ + /** A builder for [UploadPostTransformErrorEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -153,16 +153,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - uploadPostTransformErrorWebhookEvent: UploadPostTransformErrorWebhookEvent - ) = apply { - id = uploadPostTransformErrorWebhookEvent.id - createdAt = uploadPostTransformErrorWebhookEvent.createdAt - data = uploadPostTransformErrorWebhookEvent.data - request = uploadPostTransformErrorWebhookEvent.request - type = uploadPostTransformErrorWebhookEvent.type - additionalProperties = - uploadPostTransformErrorWebhookEvent.additionalProperties.toMutableMap() + 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. */ @@ -242,7 +239,7 @@ private constructor( } /** - * Returns an immutable instance of [UploadPostTransformErrorWebhookEvent]. + * Returns an immutable instance of [UploadPostTransformErrorEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -256,8 +253,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UploadPostTransformErrorWebhookEvent = - UploadPostTransformErrorWebhookEvent( + fun build(): UploadPostTransformErrorEvent = + UploadPostTransformErrorEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -269,7 +266,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UploadPostTransformErrorWebhookEvent = apply { + fun validate(): UploadPostTransformErrorEvent = apply { if (validated) { return@apply } @@ -1674,7 +1671,7 @@ private constructor( return true } - return other is UploadPostTransformErrorWebhookEvent && + return other is UploadPostTransformErrorEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -1690,5 +1687,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UploadPostTransformErrorWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "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/UploadPostTransformSuccessWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt index 0c70ea5f..ca9d87d3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -24,7 +24,7 @@ import kotlin.jvm.optionals.getOrNull * is now ready and can be accessed via the provided URL. Note that each post-transformation * generates a separate webhook event. */ -class UploadPostTransformSuccessWebhookEvent +class UploadPostTransformSuccessEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -130,7 +130,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UploadPostTransformSuccessWebhookEvent]. + * [UploadPostTransformSuccessEvent]. * * The following fields are required: * ```java @@ -143,7 +143,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UploadPostTransformSuccessWebhookEvent]. */ + /** A builder for [UploadPostTransformSuccessEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -154,17 +154,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - uploadPostTransformSuccessWebhookEvent: UploadPostTransformSuccessWebhookEvent - ) = apply { - id = uploadPostTransformSuccessWebhookEvent.id - createdAt = uploadPostTransformSuccessWebhookEvent.createdAt - data = uploadPostTransformSuccessWebhookEvent.data - request = uploadPostTransformSuccessWebhookEvent.request - type = uploadPostTransformSuccessWebhookEvent.type - additionalProperties = - uploadPostTransformSuccessWebhookEvent.additionalProperties.toMutableMap() - } + 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)) @@ -243,7 +242,7 @@ private constructor( } /** - * Returns an immutable instance of [UploadPostTransformSuccessWebhookEvent]. + * Returns an immutable instance of [UploadPostTransformSuccessEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -257,8 +256,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UploadPostTransformSuccessWebhookEvent = - UploadPostTransformSuccessWebhookEvent( + fun build(): UploadPostTransformSuccessEvent = + UploadPostTransformSuccessEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -270,7 +269,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UploadPostTransformSuccessWebhookEvent = apply { + fun validate(): UploadPostTransformSuccessEvent = apply { if (validated) { return@apply } @@ -1271,7 +1270,7 @@ private constructor( return true } - return other is UploadPostTransformSuccessWebhookEvent && + return other is UploadPostTransformSuccessEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -1287,5 +1286,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UploadPostTransformSuccessWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "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/UploadPreTransformErrorWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt index 2265fbb2..40bc5647 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt @@ -21,7 +21,7 @@ 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 UploadPreTransformErrorWebhookEvent +class UploadPreTransformErrorEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -126,8 +126,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UploadPreTransformErrorWebhookEvent]. + * Returns a mutable builder for constructing an instance of [UploadPreTransformErrorEvent]. * * The following fields are required: * ```java @@ -140,7 +139,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UploadPreTransformErrorWebhookEvent]. */ + /** A builder for [UploadPreTransformErrorEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -151,16 +150,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - uploadPreTransformErrorWebhookEvent: UploadPreTransformErrorWebhookEvent - ) = apply { - id = uploadPreTransformErrorWebhookEvent.id - createdAt = uploadPreTransformErrorWebhookEvent.createdAt - data = uploadPreTransformErrorWebhookEvent.data - request = uploadPreTransformErrorWebhookEvent.request - type = uploadPreTransformErrorWebhookEvent.type - additionalProperties = - uploadPreTransformErrorWebhookEvent.additionalProperties.toMutableMap() + 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. */ @@ -240,7 +236,7 @@ private constructor( } /** - * Returns an immutable instance of [UploadPreTransformErrorWebhookEvent]. + * Returns an immutable instance of [UploadPreTransformErrorEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -254,8 +250,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UploadPreTransformErrorWebhookEvent = - UploadPreTransformErrorWebhookEvent( + fun build(): UploadPreTransformErrorEvent = + UploadPreTransformErrorEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -267,7 +263,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UploadPreTransformErrorWebhookEvent = apply { + fun validate(): UploadPreTransformErrorEvent = apply { if (validated) { return@apply } @@ -1085,7 +1081,7 @@ private constructor( return true } - return other is UploadPreTransformErrorWebhookEvent && + return other is UploadPreTransformErrorEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -1101,5 +1097,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UploadPreTransformErrorWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "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/UploadPreTransformSuccessWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index 5b934121..d9712881 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -26,7 +26,7 @@ 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 UploadPreTransformSuccessWebhookEvent +class UploadPreTransformSuccessEvent private constructor( private val id: JsonField, private val createdAt: JsonField, @@ -134,7 +134,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UploadPreTransformSuccessWebhookEvent]. + * [UploadPreTransformSuccessEvent]. * * The following fields are required: * ```java @@ -147,7 +147,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UploadPreTransformSuccessWebhookEvent]. */ + /** A builder for [UploadPreTransformSuccessEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -158,16 +158,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - uploadPreTransformSuccessWebhookEvent: UploadPreTransformSuccessWebhookEvent - ) = apply { - id = uploadPreTransformSuccessWebhookEvent.id - createdAt = uploadPreTransformSuccessWebhookEvent.createdAt - data = uploadPreTransformSuccessWebhookEvent.data - request = uploadPreTransformSuccessWebhookEvent.request - type = uploadPreTransformSuccessWebhookEvent.type + internal fun from(uploadPreTransformSuccessEvent: UploadPreTransformSuccessEvent) = apply { + id = uploadPreTransformSuccessEvent.id + createdAt = uploadPreTransformSuccessEvent.createdAt + data = uploadPreTransformSuccessEvent.data + request = uploadPreTransformSuccessEvent.request + type = uploadPreTransformSuccessEvent.type additionalProperties = - uploadPreTransformSuccessWebhookEvent.additionalProperties.toMutableMap() + uploadPreTransformSuccessEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -248,7 +246,7 @@ private constructor( } /** - * Returns an immutable instance of [UploadPreTransformSuccessWebhookEvent]. + * Returns an immutable instance of [UploadPreTransformSuccessEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -262,8 +260,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UploadPreTransformSuccessWebhookEvent = - UploadPreTransformSuccessWebhookEvent( + fun build(): UploadPreTransformSuccessEvent = + UploadPreTransformSuccessEvent( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("data", data), @@ -275,7 +273,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UploadPreTransformSuccessWebhookEvent = apply { + fun validate(): UploadPreTransformSuccessEvent = apply { if (validated) { return@apply } @@ -3013,7 +3011,7 @@ private constructor( return true } - return other is UploadPreTransformSuccessWebhookEvent && + return other is UploadPreTransformSuccessEvent && id == other.id && createdAt == other.createdAt && data == other.data && @@ -3029,5 +3027,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UploadPreTransformSuccessWebhookEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "UploadPreTransformSuccessEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" } 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 870ff9aa..2e055cb2 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 @@ -544,13 +544,13 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofUploadPreTransformSuccess() { val uploadPreTransformSuccess = - UploadPreTransformSuccessWebhookEvent.builder() + UploadPreTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformSuccessWebhookEvent.Data.builder() + UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + UploadPreTransformSuccessEvent.Data.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -560,32 +560,31 @@ internal class UnsafeUnwrapWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .extensionStatus( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() .awsAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging .SUCCESS ) .googleAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .GoogleAutoTagging .SUCCESS ) .removeBg( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus - .RemoveBg + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg .SUCCESS ) .build() @@ -692,7 +691,7 @@ internal class UnsafeUnwrapWebhookEventTest { .thumbnailUrl("thumbnailUrl") .url("url") .versionInfo( - UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() .id("id") .name("name") .build() @@ -702,7 +701,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - UploadPreTransformSuccessWebhookEvent.Request.builder() + UploadPreTransformSuccessEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -727,13 +726,13 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofUploadPreTransformSuccess( - UploadPreTransformSuccessWebhookEvent.builder() + UploadPreTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformSuccessWebhookEvent.Data.builder() + UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + UploadPreTransformSuccessEvent.Data.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -743,33 +742,31 @@ internal class UnsafeUnwrapWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata - .builder() + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .extensionStatus( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() .awsAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging .SUCCESS ) .googleAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .GoogleAutoTagging .SUCCESS ) .removeBg( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus - .RemoveBg + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg .SUCCESS ) .build() @@ -881,7 +878,7 @@ internal class UnsafeUnwrapWebhookEventTest { .thumbnailUrl("thumbnailUrl") .url("url") .versionInfo( - UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() .id("id") .name("name") .build() @@ -891,7 +888,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - UploadPreTransformSuccessWebhookEvent.Request.builder() + UploadPreTransformSuccessEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -911,18 +908,17 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofUploadPreTransformError() { val uploadPreTransformError = - UploadPreTransformErrorWebhookEvent.builder() + UploadPreTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformErrorWebhookEvent.Data.builder() + UploadPreTransformErrorEvent.Data.builder() .name("name") .path("path") .transformation( - UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPreTransformErrorEvent.Data.Transformation.builder() .error( - UploadPreTransformErrorWebhookEvent.Data.Transformation.Error - .builder() + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() .reason("encoding_failed") .build() ) @@ -931,7 +927,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - UploadPreTransformErrorWebhookEvent.Request.builder() + UploadPreTransformErrorEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -956,18 +952,17 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofUploadPreTransformError( - UploadPreTransformErrorWebhookEvent.builder() + UploadPreTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformErrorWebhookEvent.Data.builder() + UploadPreTransformErrorEvent.Data.builder() .name("name") .path("path") .transformation( - UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPreTransformErrorEvent.Data.Transformation.builder() .error( - UploadPreTransformErrorWebhookEvent.Data.Transformation - .Error + UploadPreTransformErrorEvent.Data.Transformation.Error .builder() .reason("encoding_failed") .build() @@ -977,7 +972,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - UploadPreTransformErrorWebhookEvent.Request.builder() + UploadPreTransformErrorEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -997,28 +992,26 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofUploadPostTransformSuccess() { val uploadPostTransformSuccess = - UploadPostTransformSuccessWebhookEvent.builder() + UploadPostTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformSuccessWebhookEvent.Data.builder() + UploadPostTransformSuccessEvent.Data.builder() .fileId("fileId") .name("name") .url("https://example.com") .build() ) .request( - UploadPostTransformSuccessWebhookEvent.Request.builder() + UploadPostTransformSuccessEvent.Request.builder() .transformation( - UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + UploadPostTransformSuccessEvent.Request.Transformation.builder() .type( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Type + UploadPostTransformSuccessEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Protocol + UploadPostTransformSuccessEvent.Request.Transformation.Protocol .HLS ) .value("value") @@ -1047,30 +1040,26 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofUploadPostTransformSuccess( - UploadPostTransformSuccessWebhookEvent.builder() + UploadPostTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformSuccessWebhookEvent.Data.builder() + UploadPostTransformSuccessEvent.Data.builder() .fileId("fileId") .name("name") .url("https://example.com") .build() ) .request( - UploadPostTransformSuccessWebhookEvent.Request.builder() + UploadPostTransformSuccessEvent.Request.builder() .transformation( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .builder() + UploadPostTransformSuccessEvent.Request.Transformation.builder() .type( - UploadPostTransformSuccessWebhookEvent.Request - .Transformation - .Type + UploadPostTransformSuccessEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformSuccessWebhookEvent.Request - .Transformation + UploadPostTransformSuccessEvent.Request.Transformation .Protocol .HLS ) @@ -1095,18 +1084,18 @@ internal class UnsafeUnwrapWebhookEventTest { @Test fun ofUploadPostTransformError() { val uploadPostTransformError = - UploadPostTransformErrorWebhookEvent.builder() + UploadPostTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformErrorWebhookEvent.Data.builder() + UploadPostTransformErrorEvent.Data.builder() .fileId("fileId") .name("name") .path("path") .transformation( - UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPostTransformErrorEvent.Data.Transformation.builder() .error( - UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + UploadPostTransformErrorEvent.Data.Transformation.Error .builder() .reason("encoding_failed") .build() @@ -1117,16 +1106,15 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - UploadPostTransformErrorWebhookEvent.Request.builder() + UploadPostTransformErrorEvent.Request.builder() .transformation( - UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + UploadPostTransformErrorEvent.Request.Transformation.builder() .type( - UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + UploadPostTransformErrorEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformErrorWebhookEvent.Request.Transformation - .Protocol + UploadPostTransformErrorEvent.Request.Transformation.Protocol .HLS ) .value("value") @@ -1155,19 +1143,18 @@ internal class UnsafeUnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofUploadPostTransformError( - UploadPostTransformErrorWebhookEvent.builder() + UploadPostTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformErrorWebhookEvent.Data.builder() + UploadPostTransformErrorEvent.Data.builder() .fileId("fileId") .name("name") .path("path") .transformation( - UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPostTransformErrorEvent.Data.Transformation.builder() .error( - UploadPostTransformErrorWebhookEvent.Data.Transformation - .Error + UploadPostTransformErrorEvent.Data.Transformation.Error .builder() .reason("encoding_failed") .build() @@ -1178,17 +1165,15 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .request( - UploadPostTransformErrorWebhookEvent.Request.builder() + UploadPostTransformErrorEvent.Request.builder() .transformation( - UploadPostTransformErrorWebhookEvent.Request.Transformation - .builder() + UploadPostTransformErrorEvent.Request.Transformation.builder() .type( - UploadPostTransformErrorWebhookEvent.Request.Transformation - .Type + UploadPostTransformErrorEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformErrorWebhookEvent.Request.Transformation + UploadPostTransformErrorEvent.Request.Transformation .Protocol .HLS ) 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 ac1b4b64..29dcf721 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 @@ -542,13 +542,13 @@ internal class UnwrapWebhookEventTest { @Test fun ofUploadPreTransformSuccess() { val uploadPreTransformSuccess = - UploadPreTransformSuccessWebhookEvent.builder() + UploadPreTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformSuccessWebhookEvent.Data.builder() + UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + UploadPreTransformSuccessEvent.Data.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -558,32 +558,31 @@ internal class UnwrapWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .extensionStatus( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() .awsAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging .SUCCESS ) .googleAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .GoogleAutoTagging .SUCCESS ) .removeBg( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus - .RemoveBg + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg .SUCCESS ) .build() @@ -690,7 +689,7 @@ internal class UnwrapWebhookEventTest { .thumbnailUrl("thumbnailUrl") .url("url") .versionInfo( - UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() .id("id") .name("name") .build() @@ -700,7 +699,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - UploadPreTransformSuccessWebhookEvent.Request.builder() + UploadPreTransformSuccessEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -725,13 +724,13 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofUploadPreTransformSuccess( - UploadPreTransformSuccessWebhookEvent.builder() + UploadPreTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformSuccessWebhookEvent.Data.builder() + UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + UploadPreTransformSuccessEvent.Data.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -741,33 +740,31 @@ internal class UnwrapWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata - .builder() + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .extensionStatus( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() .awsAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging .SUCCESS ) .googleAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .GoogleAutoTagging .SUCCESS ) .removeBg( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus - .RemoveBg + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg .SUCCESS ) .build() @@ -879,7 +876,7 @@ internal class UnwrapWebhookEventTest { .thumbnailUrl("thumbnailUrl") .url("url") .versionInfo( - UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() .id("id") .name("name") .build() @@ -889,7 +886,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - UploadPreTransformSuccessWebhookEvent.Request.builder() + UploadPreTransformSuccessEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -909,18 +906,17 @@ internal class UnwrapWebhookEventTest { @Test fun ofUploadPreTransformError() { val uploadPreTransformError = - UploadPreTransformErrorWebhookEvent.builder() + UploadPreTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformErrorWebhookEvent.Data.builder() + UploadPreTransformErrorEvent.Data.builder() .name("name") .path("path") .transformation( - UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPreTransformErrorEvent.Data.Transformation.builder() .error( - UploadPreTransformErrorWebhookEvent.Data.Transformation.Error - .builder() + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() .reason("encoding_failed") .build() ) @@ -929,7 +925,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - UploadPreTransformErrorWebhookEvent.Request.builder() + UploadPreTransformErrorEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -953,18 +949,17 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofUploadPreTransformError( - UploadPreTransformErrorWebhookEvent.builder() + UploadPreTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformErrorWebhookEvent.Data.builder() + UploadPreTransformErrorEvent.Data.builder() .name("name") .path("path") .transformation( - UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPreTransformErrorEvent.Data.Transformation.builder() .error( - UploadPreTransformErrorWebhookEvent.Data.Transformation - .Error + UploadPreTransformErrorEvent.Data.Transformation.Error .builder() .reason("encoding_failed") .build() @@ -974,7 +969,7 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - UploadPreTransformErrorWebhookEvent.Request.builder() + UploadPreTransformErrorEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -994,28 +989,26 @@ internal class UnwrapWebhookEventTest { @Test fun ofUploadPostTransformSuccess() { val uploadPostTransformSuccess = - UploadPostTransformSuccessWebhookEvent.builder() + UploadPostTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformSuccessWebhookEvent.Data.builder() + UploadPostTransformSuccessEvent.Data.builder() .fileId("fileId") .name("name") .url("https://example.com") .build() ) .request( - UploadPostTransformSuccessWebhookEvent.Request.builder() + UploadPostTransformSuccessEvent.Request.builder() .transformation( - UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + UploadPostTransformSuccessEvent.Request.Transformation.builder() .type( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Type + UploadPostTransformSuccessEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Protocol + UploadPostTransformSuccessEvent.Request.Transformation.Protocol .HLS ) .value("value") @@ -1044,30 +1037,26 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofUploadPostTransformSuccess( - UploadPostTransformSuccessWebhookEvent.builder() + UploadPostTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformSuccessWebhookEvent.Data.builder() + UploadPostTransformSuccessEvent.Data.builder() .fileId("fileId") .name("name") .url("https://example.com") .build() ) .request( - UploadPostTransformSuccessWebhookEvent.Request.builder() + UploadPostTransformSuccessEvent.Request.builder() .transformation( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .builder() + UploadPostTransformSuccessEvent.Request.Transformation.builder() .type( - UploadPostTransformSuccessWebhookEvent.Request - .Transformation - .Type + UploadPostTransformSuccessEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformSuccessWebhookEvent.Request - .Transformation + UploadPostTransformSuccessEvent.Request.Transformation .Protocol .HLS ) @@ -1092,18 +1081,18 @@ internal class UnwrapWebhookEventTest { @Test fun ofUploadPostTransformError() { val uploadPostTransformError = - UploadPostTransformErrorWebhookEvent.builder() + UploadPostTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformErrorWebhookEvent.Data.builder() + UploadPostTransformErrorEvent.Data.builder() .fileId("fileId") .name("name") .path("path") .transformation( - UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPostTransformErrorEvent.Data.Transformation.builder() .error( - UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + UploadPostTransformErrorEvent.Data.Transformation.Error .builder() .reason("encoding_failed") .build() @@ -1114,16 +1103,15 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - UploadPostTransformErrorWebhookEvent.Request.builder() + UploadPostTransformErrorEvent.Request.builder() .transformation( - UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + UploadPostTransformErrorEvent.Request.Transformation.builder() .type( - UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + UploadPostTransformErrorEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformErrorWebhookEvent.Request.Transformation - .Protocol + UploadPostTransformErrorEvent.Request.Transformation.Protocol .HLS ) .value("value") @@ -1151,19 +1139,18 @@ internal class UnwrapWebhookEventTest { val jsonMapper = jsonMapper() val unwrapWebhookEvent = UnwrapWebhookEvent.ofUploadPostTransformError( - UploadPostTransformErrorWebhookEvent.builder() + UploadPostTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformErrorWebhookEvent.Data.builder() + UploadPostTransformErrorEvent.Data.builder() .fileId("fileId") .name("name") .path("path") .transformation( - UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPostTransformErrorEvent.Data.Transformation.builder() .error( - UploadPostTransformErrorWebhookEvent.Data.Transformation - .Error + UploadPostTransformErrorEvent.Data.Transformation.Error .builder() .reason("encoding_failed") .build() @@ -1174,17 +1161,15 @@ internal class UnwrapWebhookEventTest { .build() ) .request( - UploadPostTransformErrorWebhookEvent.Request.builder() + UploadPostTransformErrorEvent.Request.builder() .transformation( - UploadPostTransformErrorWebhookEvent.Request.Transformation - .builder() + UploadPostTransformErrorEvent.Request.Transformation.builder() .type( - UploadPostTransformErrorWebhookEvent.Request.Transformation - .Type + UploadPostTransformErrorEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformErrorWebhookEvent.Request.Transformation + UploadPostTransformErrorEvent.Request.Transformation .Protocol .HLS ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt similarity index 59% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt index f13f7191..e7a4925a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt @@ -8,23 +8,23 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class UploadPostTransformErrorWebhookEventTest { +internal class UploadPostTransformErrorEventTest { @Test fun create() { - val uploadPostTransformErrorWebhookEvent = - UploadPostTransformErrorWebhookEvent.builder() + val uploadPostTransformErrorEvent = + UploadPostTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformErrorWebhookEvent.Data.builder() + UploadPostTransformErrorEvent.Data.builder() .fileId("fileId") .name("name") .path("path") .transformation( - UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPostTransformErrorEvent.Data.Transformation.builder() .error( - UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + UploadPostTransformErrorEvent.Data.Transformation.Error .builder() .reason("encoding_failed") .build() @@ -35,16 +35,15 @@ internal class UploadPostTransformErrorWebhookEventTest { .build() ) .request( - UploadPostTransformErrorWebhookEvent.Request.builder() + UploadPostTransformErrorEvent.Request.builder() .transformation( - UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + UploadPostTransformErrorEvent.Request.Transformation.builder() .type( - UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + UploadPostTransformErrorEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformErrorWebhookEvent.Request.Transformation - .Protocol + UploadPostTransformErrorEvent.Request.Transformation.Protocol .HLS ) .value("value") @@ -55,20 +54,19 @@ internal class UploadPostTransformErrorWebhookEventTest { ) .build() - assertThat(uploadPostTransformErrorWebhookEvent.id()).isEqualTo("id") - assertThat(uploadPostTransformErrorWebhookEvent.createdAt()) + assertThat(uploadPostTransformErrorEvent.id()).isEqualTo("id") + assertThat(uploadPostTransformErrorEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(uploadPostTransformErrorWebhookEvent.data()) + assertThat(uploadPostTransformErrorEvent.data()) .isEqualTo( - UploadPostTransformErrorWebhookEvent.Data.builder() + UploadPostTransformErrorEvent.Data.builder() .fileId("fileId") .name("name") .path("path") .transformation( - UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPostTransformErrorEvent.Data.Transformation.builder() .error( - UploadPostTransformErrorWebhookEvent.Data.Transformation.Error - .builder() + UploadPostTransformErrorEvent.Data.Transformation.Error.builder() .reason("encoding_failed") .build() ) @@ -77,18 +75,17 @@ internal class UploadPostTransformErrorWebhookEventTest { .url("https://example.com") .build() ) - assertThat(uploadPostTransformErrorWebhookEvent.request()) + assertThat(uploadPostTransformErrorEvent.request()) .isEqualTo( - UploadPostTransformErrorWebhookEvent.Request.builder() + UploadPostTransformErrorEvent.Request.builder() .transformation( - UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + UploadPostTransformErrorEvent.Request.Transformation.builder() .type( - UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + UploadPostTransformErrorEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformErrorWebhookEvent.Request.Transformation.Protocol - .HLS + UploadPostTransformErrorEvent.Request.Transformation.Protocol.HLS ) .value("value") .build() @@ -101,19 +98,19 @@ internal class UploadPostTransformErrorWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val uploadPostTransformErrorWebhookEvent = - UploadPostTransformErrorWebhookEvent.builder() + val uploadPostTransformErrorEvent = + UploadPostTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformErrorWebhookEvent.Data.builder() + UploadPostTransformErrorEvent.Data.builder() .fileId("fileId") .name("name") .path("path") .transformation( - UploadPostTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPostTransformErrorEvent.Data.Transformation.builder() .error( - UploadPostTransformErrorWebhookEvent.Data.Transformation.Error + UploadPostTransformErrorEvent.Data.Transformation.Error .builder() .reason("encoding_failed") .build() @@ -124,16 +121,15 @@ internal class UploadPostTransformErrorWebhookEventTest { .build() ) .request( - UploadPostTransformErrorWebhookEvent.Request.builder() + UploadPostTransformErrorEvent.Request.builder() .transformation( - UploadPostTransformErrorWebhookEvent.Request.Transformation.builder() + UploadPostTransformErrorEvent.Request.Transformation.builder() .type( - UploadPostTransformErrorWebhookEvent.Request.Transformation.Type + UploadPostTransformErrorEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformErrorWebhookEvent.Request.Transformation - .Protocol + UploadPostTransformErrorEvent.Request.Transformation.Protocol .HLS ) .value("value") @@ -144,13 +140,13 @@ internal class UploadPostTransformErrorWebhookEventTest { ) .build() - val roundtrippedUploadPostTransformErrorWebhookEvent = + val roundtrippedUploadPostTransformErrorEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(uploadPostTransformErrorWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(uploadPostTransformErrorEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedUploadPostTransformErrorWebhookEvent) - .isEqualTo(uploadPostTransformErrorWebhookEvent) + assertThat(roundtrippedUploadPostTransformErrorEvent) + .isEqualTo(uploadPostTransformErrorEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt similarity index 54% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt index 874fe9ce..eaa86ef2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt @@ -8,33 +8,31 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class UploadPostTransformSuccessWebhookEventTest { +internal class UploadPostTransformSuccessEventTest { @Test fun create() { - val uploadPostTransformSuccessWebhookEvent = - UploadPostTransformSuccessWebhookEvent.builder() + val uploadPostTransformSuccessEvent = + UploadPostTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformSuccessWebhookEvent.Data.builder() + UploadPostTransformSuccessEvent.Data.builder() .fileId("fileId") .name("name") .url("https://example.com") .build() ) .request( - UploadPostTransformSuccessWebhookEvent.Request.builder() + UploadPostTransformSuccessEvent.Request.builder() .transformation( - UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + UploadPostTransformSuccessEvent.Request.Transformation.builder() .type( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Type + UploadPostTransformSuccessEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Protocol + UploadPostTransformSuccessEvent.Request.Transformation.Protocol .HLS ) .value("value") @@ -45,30 +43,28 @@ internal class UploadPostTransformSuccessWebhookEventTest { ) .build() - assertThat(uploadPostTransformSuccessWebhookEvent.id()).isEqualTo("id") - assertThat(uploadPostTransformSuccessWebhookEvent.createdAt()) + assertThat(uploadPostTransformSuccessEvent.id()).isEqualTo("id") + assertThat(uploadPostTransformSuccessEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(uploadPostTransformSuccessWebhookEvent.data()) + assertThat(uploadPostTransformSuccessEvent.data()) .isEqualTo( - UploadPostTransformSuccessWebhookEvent.Data.builder() + UploadPostTransformSuccessEvent.Data.builder() .fileId("fileId") .name("name") .url("https://example.com") .build() ) - assertThat(uploadPostTransformSuccessWebhookEvent.request()) + assertThat(uploadPostTransformSuccessEvent.request()) .isEqualTo( - UploadPostTransformSuccessWebhookEvent.Request.builder() + UploadPostTransformSuccessEvent.Request.builder() .transformation( - UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + UploadPostTransformSuccessEvent.Request.Transformation.builder() .type( - UploadPostTransformSuccessWebhookEvent.Request.Transformation.Type + UploadPostTransformSuccessEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Protocol - .HLS + UploadPostTransformSuccessEvent.Request.Transformation.Protocol.HLS ) .value("value") .build() @@ -81,29 +77,27 @@ internal class UploadPostTransformSuccessWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val uploadPostTransformSuccessWebhookEvent = - UploadPostTransformSuccessWebhookEvent.builder() + val uploadPostTransformSuccessEvent = + UploadPostTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPostTransformSuccessWebhookEvent.Data.builder() + UploadPostTransformSuccessEvent.Data.builder() .fileId("fileId") .name("name") .url("https://example.com") .build() ) .request( - UploadPostTransformSuccessWebhookEvent.Request.builder() + UploadPostTransformSuccessEvent.Request.builder() .transformation( - UploadPostTransformSuccessWebhookEvent.Request.Transformation.builder() + UploadPostTransformSuccessEvent.Request.Transformation.builder() .type( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Type + UploadPostTransformSuccessEvent.Request.Transformation.Type .TRANSFORMATION ) .protocol( - UploadPostTransformSuccessWebhookEvent.Request.Transformation - .Protocol + UploadPostTransformSuccessEvent.Request.Transformation.Protocol .HLS ) .value("value") @@ -114,13 +108,13 @@ internal class UploadPostTransformSuccessWebhookEventTest { ) .build() - val roundtrippedUploadPostTransformSuccessWebhookEvent = + val roundtrippedUploadPostTransformSuccessEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(uploadPostTransformSuccessWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(uploadPostTransformSuccessEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedUploadPostTransformSuccessWebhookEvent) - .isEqualTo(uploadPostTransformSuccessWebhookEvent) + assertThat(roundtrippedUploadPostTransformSuccessEvent) + .isEqualTo(uploadPostTransformSuccessEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt similarity index 57% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt index 66f31ad2..e97ad849 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt @@ -8,23 +8,22 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class UploadPreTransformErrorWebhookEventTest { +internal class UploadPreTransformErrorEventTest { @Test fun create() { - val uploadPreTransformErrorWebhookEvent = - UploadPreTransformErrorWebhookEvent.builder() + val uploadPreTransformErrorEvent = + UploadPreTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformErrorWebhookEvent.Data.builder() + UploadPreTransformErrorEvent.Data.builder() .name("name") .path("path") .transformation( - UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPreTransformErrorEvent.Data.Transformation.builder() .error( - UploadPreTransformErrorWebhookEvent.Data.Transformation.Error - .builder() + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() .reason("encoding_failed") .build() ) @@ -33,26 +32,25 @@ internal class UploadPreTransformErrorWebhookEventTest { .build() ) .request( - UploadPreTransformErrorWebhookEvent.Request.builder() + UploadPreTransformErrorEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() ) .build() - assertThat(uploadPreTransformErrorWebhookEvent.id()).isEqualTo("id") - assertThat(uploadPreTransformErrorWebhookEvent.createdAt()) + assertThat(uploadPreTransformErrorEvent.id()).isEqualTo("id") + assertThat(uploadPreTransformErrorEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(uploadPreTransformErrorWebhookEvent.data()) + assertThat(uploadPreTransformErrorEvent.data()) .isEqualTo( - UploadPreTransformErrorWebhookEvent.Data.builder() + UploadPreTransformErrorEvent.Data.builder() .name("name") .path("path") .transformation( - UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPreTransformErrorEvent.Data.Transformation.builder() .error( - UploadPreTransformErrorWebhookEvent.Data.Transformation.Error - .builder() + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() .reason("encoding_failed") .build() ) @@ -60,9 +58,9 @@ internal class UploadPreTransformErrorWebhookEventTest { ) .build() ) - assertThat(uploadPreTransformErrorWebhookEvent.request()) + assertThat(uploadPreTransformErrorEvent.request()) .isEqualTo( - UploadPreTransformErrorWebhookEvent.Request.builder() + UploadPreTransformErrorEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -72,19 +70,18 @@ internal class UploadPreTransformErrorWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val uploadPreTransformErrorWebhookEvent = - UploadPreTransformErrorWebhookEvent.builder() + val uploadPreTransformErrorEvent = + UploadPreTransformErrorEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformErrorWebhookEvent.Data.builder() + UploadPreTransformErrorEvent.Data.builder() .name("name") .path("path") .transformation( - UploadPreTransformErrorWebhookEvent.Data.Transformation.builder() + UploadPreTransformErrorEvent.Data.Transformation.builder() .error( - UploadPreTransformErrorWebhookEvent.Data.Transformation.Error - .builder() + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() .reason("encoding_failed") .build() ) @@ -93,20 +90,19 @@ internal class UploadPreTransformErrorWebhookEventTest { .build() ) .request( - UploadPreTransformErrorWebhookEvent.Request.builder() + UploadPreTransformErrorEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() ) .build() - val roundtrippedUploadPreTransformErrorWebhookEvent = + val roundtrippedUploadPreTransformErrorEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(uploadPreTransformErrorWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(uploadPreTransformErrorEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedUploadPreTransformErrorWebhookEvent) - .isEqualTo(uploadPreTransformErrorWebhookEvent) + assertThat(roundtrippedUploadPreTransformErrorEvent).isEqualTo(uploadPreTransformErrorEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt index 8353cca7..e6bce8e1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -10,18 +10,18 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class UploadPreTransformSuccessWebhookEventTest { +internal class UploadPreTransformSuccessEventTest { @Test fun create() { - val uploadPreTransformSuccessWebhookEvent = - UploadPreTransformSuccessWebhookEvent.builder() + val uploadPreTransformSuccessEvent = + UploadPreTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformSuccessWebhookEvent.Data.builder() + UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + UploadPreTransformSuccessEvent.Data.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -31,32 +31,31 @@ internal class UploadPreTransformSuccessWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .extensionStatus( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() .awsAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging .SUCCESS ) .googleAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .GoogleAutoTagging .SUCCESS ) .removeBg( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus - .RemoveBg + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg .SUCCESS ) .build() @@ -163,7 +162,7 @@ internal class UploadPreTransformSuccessWebhookEventTest { .thumbnailUrl("thumbnailUrl") .url("url") .versionInfo( - UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() .id("id") .name("name") .build() @@ -173,21 +172,21 @@ internal class UploadPreTransformSuccessWebhookEventTest { .build() ) .request( - UploadPreTransformSuccessWebhookEvent.Request.builder() + UploadPreTransformSuccessEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() ) .build() - assertThat(uploadPreTransformSuccessWebhookEvent.id()).isEqualTo("id") - assertThat(uploadPreTransformSuccessWebhookEvent.createdAt()) + assertThat(uploadPreTransformSuccessEvent.id()).isEqualTo("id") + assertThat(uploadPreTransformSuccessEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(uploadPreTransformSuccessWebhookEvent.data()) + assertThat(uploadPreTransformSuccessEvent.data()) .isEqualTo( - UploadPreTransformSuccessWebhookEvent.Data.builder() + UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + UploadPreTransformSuccessEvent.Data.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -197,32 +196,30 @@ internal class UploadPreTransformSuccessWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .extensionStatus( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() .awsAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus - .AwsAutoTagging + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AwsAutoTagging .SUCCESS ) .googleAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .GoogleAutoTagging .SUCCESS ) .removeBg( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.RemoveBg - .SUCCESS + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg.SUCCESS ) .build() ) @@ -326,7 +323,7 @@ internal class UploadPreTransformSuccessWebhookEventTest { .thumbnailUrl("thumbnailUrl") .url("url") .versionInfo( - UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() .id("id") .name("name") .build() @@ -335,9 +332,9 @@ internal class UploadPreTransformSuccessWebhookEventTest { .width(0.0) .build() ) - assertThat(uploadPreTransformSuccessWebhookEvent.request()) + assertThat(uploadPreTransformSuccessEvent.request()) .isEqualTo( - UploadPreTransformSuccessWebhookEvent.Request.builder() + UploadPreTransformSuccessEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() @@ -347,14 +344,14 @@ internal class UploadPreTransformSuccessWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val uploadPreTransformSuccessWebhookEvent = - UploadPreTransformSuccessWebhookEvent.builder() + val uploadPreTransformSuccessEvent = + UploadPreTransformSuccessEvent.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - UploadPreTransformSuccessWebhookEvent.Data.builder() + UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessWebhookEvent.Data.AiTag.builder() + UploadPreTransformSuccessEvent.Data.AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -364,32 +361,31 @@ internal class UploadPreTransformSuccessWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessWebhookEvent.Data.CustomMetadata.builder() + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessWebhookEvent.Data.EmbeddedMetadata.builder() + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .extensionStatus( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus.builder() + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() .awsAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging .SUCCESS ) .googleAutoTagging( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus + UploadPreTransformSuccessEvent.Data.ExtensionStatus .GoogleAutoTagging .SUCCESS ) .removeBg( - UploadPreTransformSuccessWebhookEvent.Data.ExtensionStatus - .RemoveBg + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg .SUCCESS ) .build() @@ -496,7 +492,7 @@ internal class UploadPreTransformSuccessWebhookEventTest { .thumbnailUrl("thumbnailUrl") .url("url") .versionInfo( - UploadPreTransformSuccessWebhookEvent.Data.VersionInfo.builder() + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() .id("id") .name("name") .build() @@ -506,20 +502,20 @@ internal class UploadPreTransformSuccessWebhookEventTest { .build() ) .request( - UploadPreTransformSuccessWebhookEvent.Request.builder() + UploadPreTransformSuccessEvent.Request.builder() .transformation("transformation") .xRequestId("x_request_id") .build() ) .build() - val roundtrippedUploadPreTransformSuccessWebhookEvent = + val roundtrippedUploadPreTransformSuccessEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(uploadPreTransformSuccessWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(uploadPreTransformSuccessEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedUploadPreTransformSuccessWebhookEvent) - .isEqualTo(uploadPreTransformSuccessWebhookEvent) + assertThat(roundtrippedUploadPreTransformSuccessEvent) + .isEqualTo(uploadPreTransformSuccessEvent) } } From ba4fb51d92827465620dafb256ecf1e45d478ff9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 10:27:46 +0000 Subject: [PATCH 083/125] feat(api): add ai-auto-description field with status options to components schema --- .stats.yml | 4 +- .../beta/v2/files/FileUploadResponse.kt | 194 ++++++++++++++++- .../api/models/files/FileUploadResponse.kt | 194 ++++++++++++++++- .../UploadPreTransformSuccessEvent.kt | 196 +++++++++++++++++- .../beta/v2/files/FileUploadResponseTest.kt | 7 + .../models/files/FileUploadResponseTest.kt | 7 + .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 10 + .../models/webhooks/UnwrapWebhookEventTest.kt | 10 + .../UploadPreTransformSuccessEventTest.kt | 15 ++ 9 files changed, 623 insertions(+), 14 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6bb89db0..bd62087f 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-d857341f30517b11df568dd6c5a0e9dea3a854930f7f6583718114d311f2d5ee.yml -openapi_spec_hash: db94bfd556220d6244a1b2bbae9d7d00 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3d7da4b8ef2ed30aa32c4fb3e98e498e67402e91aaa5fd4c628fc080bfe82ea1.yml +openapi_spec_hash: aaa50fcbccec6f2cf1165f34bc6ac886 config_hash: 4ef178e13ecfdb97211f284f13a21e83 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 998dc5bc..2b6fd59d 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 @@ -1548,6 +1548,7 @@ private constructor( */ class ExtensionStatus private constructor( + private val aiAutoDescription: JsonField, private val awsAutoTagging: JsonField, private val googleAutoTagging: JsonField, private val removeBg: JsonField, @@ -1556,6 +1557,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("ai-auto-description") + @ExcludeMissing + aiAutoDescription: JsonField = JsonMissing.of(), @JsonProperty("aws-auto-tagging") @ExcludeMissing awsAutoTagging: JsonField = JsonMissing.of(), @@ -1565,7 +1569,14 @@ private constructor( @JsonProperty("remove-bg") @ExcludeMissing removeBg: JsonField = JsonMissing.of(), - ) : this(awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + ) : 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 @@ -1587,6 +1598,16 @@ private constructor( */ 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]. * @@ -1635,6 +1656,7 @@ private constructor( /** 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() @@ -1642,12 +1664,27 @@ private constructor( @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)) @@ -1713,6 +1750,7 @@ private constructor( */ fun build(): ExtensionStatus = ExtensionStatus( + aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, @@ -1727,6 +1765,7 @@ private constructor( return@apply } + aiAutoDescription().ifPresent { it.validate() } awsAutoTagging().ifPresent { it.validate() } googleAutoTagging().ifPresent { it.validate() } removeBg().ifPresent { it.validate() } @@ -1749,10 +1788,150 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (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 { @@ -2172,6 +2351,7 @@ private constructor( } return other is ExtensionStatus && + aiAutoDescription == other.aiAutoDescription && awsAutoTagging == other.awsAutoTagging && googleAutoTagging == other.googleAutoTagging && removeBg == other.removeBg && @@ -2179,13 +2359,19 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + Objects.hash( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } /** An object containing the file or file version's `id` (versionId) and `name`. */ 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 bc35d2eb..3323941e 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 @@ -1547,6 +1547,7 @@ private constructor( */ class ExtensionStatus private constructor( + private val aiAutoDescription: JsonField, private val awsAutoTagging: JsonField, private val googleAutoTagging: JsonField, private val removeBg: JsonField, @@ -1555,6 +1556,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("ai-auto-description") + @ExcludeMissing + aiAutoDescription: JsonField = JsonMissing.of(), @JsonProperty("aws-auto-tagging") @ExcludeMissing awsAutoTagging: JsonField = JsonMissing.of(), @@ -1564,7 +1568,14 @@ private constructor( @JsonProperty("remove-bg") @ExcludeMissing removeBg: JsonField = JsonMissing.of(), - ) : this(awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + ) : 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 @@ -1586,6 +1597,16 @@ private constructor( */ 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]. * @@ -1634,6 +1655,7 @@ private constructor( /** 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() @@ -1641,12 +1663,27 @@ private constructor( @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)) @@ -1712,6 +1749,7 @@ private constructor( */ fun build(): ExtensionStatus = ExtensionStatus( + aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, @@ -1726,6 +1764,7 @@ private constructor( return@apply } + aiAutoDescription().ifPresent { it.validate() } awsAutoTagging().ifPresent { it.validate() } googleAutoTagging().ifPresent { it.validate() } removeBg().ifPresent { it.validate() } @@ -1748,10 +1787,150 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (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 { @@ -2171,6 +2350,7 @@ private constructor( } return other is ExtensionStatus && + aiAutoDescription == other.aiAutoDescription && awsAutoTagging == other.awsAutoTagging && googleAutoTagging == other.googleAutoTagging && removeBg == other.removeBg && @@ -2178,13 +2358,19 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + Objects.hash( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } /** An object containing the file or file version's `id` (versionId) and `name`. */ 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 d9712881..98121db9 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 @@ -1895,6 +1895,7 @@ private constructor( */ class ExtensionStatus private constructor( + private val aiAutoDescription: JsonField, private val awsAutoTagging: JsonField, private val googleAutoTagging: JsonField, private val removeBg: JsonField, @@ -1903,6 +1904,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("ai-auto-description") + @ExcludeMissing + aiAutoDescription: JsonField = JsonMissing.of(), @JsonProperty("aws-auto-tagging") @ExcludeMissing awsAutoTagging: JsonField = JsonMissing.of(), @@ -1912,7 +1916,14 @@ private constructor( @JsonProperty("remove-bg") @ExcludeMissing removeBg: JsonField = JsonMissing.of(), - ) : this(awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + ) : 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. @@ -1934,6 +1945,16 @@ private constructor( */ 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]. * @@ -1985,6 +2006,7 @@ private constructor( /** 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() @@ -1992,12 +2014,27 @@ private constructor( @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)) @@ -2066,6 +2103,7 @@ private constructor( */ fun build(): ExtensionStatus = ExtensionStatus( + aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, @@ -2080,6 +2118,7 @@ private constructor( return@apply } + aiAutoDescription().ifPresent { it.validate() } awsAutoTagging().ifPresent { it.validate() } googleAutoTagging().ifPresent { it.validate() } removeBg().ifPresent { it.validate() } @@ -2102,10 +2141,152 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (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 { @@ -2530,6 +2711,7 @@ private constructor( } return other is ExtensionStatus && + aiAutoDescription == other.aiAutoDescription && awsAutoTagging == other.awsAutoTagging && googleAutoTagging == other.googleAutoTagging && removeBg == other.removeBg && @@ -2537,13 +2719,19 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(awsAutoTagging, googleAutoTagging, removeBg, additionalProperties) + Objects.hash( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ExtensionStatus{awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } /** An object containing the file or file version's `id` (versionId) and `name`. */ 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 d20ca12d..9c5cab4e 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 @@ -40,6 +40,9 @@ internal class FileUploadResponseTest { ) .extensionStatus( FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS + ) .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging( FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS @@ -179,6 +182,7 @@ internal class FileUploadResponseTest { 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) @@ -319,6 +323,9 @@ internal class FileUploadResponseTest { ) .extensionStatus( FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUploadResponse.ExtensionStatus.AiAutoDescription.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/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt index 44190124..48c228e3 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 @@ -39,6 +39,9 @@ internal class FileUploadResponseTest { ) .extensionStatus( FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS + ) .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging( FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS @@ -178,6 +181,7 @@ internal class FileUploadResponseTest { 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) @@ -318,6 +322,9 @@ internal class FileUploadResponseTest { ) .extensionStatus( FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUploadResponse.ExtensionStatus.AiAutoDescription.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 2e055cb2..010070a5 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 @@ -573,6 +573,11 @@ internal class UnsafeUnwrapWebhookEventTest { ) .extensionStatus( UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging @@ -755,6 +760,11 @@ internal class UnsafeUnwrapWebhookEventTest { ) .extensionStatus( UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .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 29dcf721..f35cbec4 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 @@ -571,6 +571,11 @@ internal class UnwrapWebhookEventTest { ) .extensionStatus( UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging @@ -753,6 +758,11 @@ internal class UnwrapWebhookEventTest { ) .extensionStatus( UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .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 e6bce8e1..7068d5a9 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 @@ -44,6 +44,11 @@ internal class UploadPreTransformSuccessEventTest { ) .extensionStatus( UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging @@ -209,6 +214,11 @@ internal class UploadPreTransformSuccessEventTest { ) .extensionStatus( UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus.AwsAutoTagging .SUCCESS @@ -374,6 +384,11 @@ internal class UploadPreTransformSuccessEventTest { ) .extensionStatus( UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging From 0ab8a765ae9e5794f3548d684e396113654efc24 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 10:55:16 +0000 Subject: [PATCH 084/125] feat(docs): improve descriptions for private API key and password fields in client settings --- .stats.yml | 2 +- README.md | 30 ++++++++-------- .../api/client/okhttp/ImageKitOkHttpClient.kt | 10 ++++-- .../okhttp/ImageKitOkHttpClientAsync.kt | 10 ++++-- .../com/imagekit/api/core/ClientOptions.kt | 36 +++++++++++-------- 5 files changed, 52 insertions(+), 36 deletions(-) diff --git a/.stats.yml b/.stats.yml index bd62087f..a4e72d08 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: 4ef178e13ecfdb97211f284f13a21e83 +config_hash: 7218b2df6efd609f88bac0ac591a70e9 diff --git a/README.md b/README.md index 84baa02e..a4ba438e 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,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.orgMyPasswordToken` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() @@ -59,8 +59,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.orgMyPasswordToken` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); ``` @@ -83,8 +83,8 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties - // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables + // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis` and `imagekit.baseUrl` system properties + // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables .fromEnv() .privateApiKey("My Private API Key") .build(); @@ -92,11 +92,11 @@ ImageKitClient client = ImageKitOkHttpClient.builder() 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.orgMyPasswordToken` | `ORG_MY_PASSWORD_TOKEN` | false | `"does_not_matter"` | -| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | +| 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"` | +| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | System properties take precedence over environment variables. @@ -145,8 +145,8 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() @@ -166,8 +166,8 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.orgMyPasswordToken` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `ORG_MY_PASSWORD_TOKEN` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() 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 81f5e3f3..7b44daeb 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 @@ -183,15 +183,19 @@ class ImageKitOkHttpClient private constructor() { */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } - /** Your ImageKit private key starts with `private_`. */ + /** + * 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) } /** - * Do not set this, its value is ignored + * ImageKit Basic Auth only uses the username field and ignores the password. This field is + * unused. * - * Defaults to `"does_not_matter"`. + * Defaults to `"do_not_set"`. */ fun password(password: String?) = apply { clientOptions.password(password) } 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 89193a36..23dc7540 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 @@ -183,15 +183,19 @@ class ImageKitOkHttpClientAsync private constructor() { */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } - /** Your ImageKit private key starts with `private_`. */ + /** + * 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) } /** - * Do not set this, its value is ignored + * ImageKit Basic Auth only uses the username field and ignores the password. This field is + * unused. * - * Defaults to `"does_not_matter"`. + * Defaults to `"do_not_set"`. */ fun password(password: String?) = apply { clientOptions.password(password) } 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 140608eb..0e73970c 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 @@ -84,7 +84,10 @@ private constructor( * Defaults to 2. */ @get:JvmName("maxRetries") val maxRetries: Int, - /** Your ImageKit private key starts with `private_`. */ + /** + * 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?, ) { @@ -105,9 +108,10 @@ private constructor( fun baseUrlOverridden(): Boolean = baseUrl != null /** - * Do not set this, its value is ignored + * ImageKit Basic Auth only uses the username field and ignores the password. This field is + * unused. * - * Defaults to `"does_not_matter"`. + * Defaults to `"do_not_set"`. */ fun password(): Optional = Optional.ofNullable(password) @@ -150,7 +154,7 @@ private constructor( private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 private var privateApiKey: String? = null - private var password: String? = "does_not_matter" + private var password: String? = "do_not_set" @JvmSynthetic internal fun from(clientOptions: ClientOptions) = apply { @@ -261,13 +265,17 @@ private constructor( */ fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - /** Your ImageKit private key starts with `private_`. */ + /** + * 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 } /** - * Do not set this, its value is ignored + * ImageKit Basic Auth only uses the username field and ignores the password. This field is + * unused. * - * Defaults to `"does_not_matter"`. + * Defaults to `"do_not_set"`. */ fun password(password: String?) = apply { this.password = password } @@ -361,11 +369,11 @@ private constructor( * * 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.orgMyPasswordToken` |`ORG_MY_PASSWORD_TOKEN` |false |`"does_not_matter"` | - * |`baseUrl` |`imagekit.baseUrl` |`IMAGE_KIT_BASE_URL` |true |`"https://api.imagekit.io"`| + * |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"` | + * |`baseUrl` |`imagekit.baseUrl` |`IMAGE_KIT_BASE_URL` |true |`"https://api.imagekit.io"`| * * System properties take precedence over environment variables. */ @@ -376,8 +384,8 @@ private constructor( (System.getProperty("imagekit.imagekitPrivateApiKey") ?: System.getenv("IMAGEKIT_PRIVATE_API_KEY")) ?.let { privateApiKey(it) } - (System.getProperty("imagekit.orgMyPasswordToken") - ?: System.getenv("ORG_MY_PASSWORD_TOKEN")) + (System.getProperty("imagekit.optionalImagekitIgnoresThis") + ?: System.getenv("OPTIONAL_IMAGEKIT_IGNORES_THIS")) ?.let { password(it) } } From b29dabd2c5fa1a2da51df4cd1ebd8a3466ca1e04 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 12:46:31 +0000 Subject: [PATCH 085/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a4e72d08..93aeb615 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: 7218b2df6efd609f88bac0ac591a70e9 +config_hash: af15f7df8a4590c14cdce4460983aba6 From 15d52711415fb45bbb38159cf5c7411bc9e70248 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:07:39 +0000 Subject: [PATCH 086/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 93aeb615..8599545e 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: af15f7df8a4590c14cdce4460983aba6 +config_hash: 84bf9f929b0248a6cdf2d526331ed8eb From 94f0bed2c3d0a41683bc8a0e44125cb4e647db33 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:14:33 +0000 Subject: [PATCH 087/125] feat(api): manual updates --- .stats.yml | 2 +- README.md | 21 ++++++------- .../api/client/okhttp/ImageKitOkHttpClient.kt | 15 ++++++++++ .../okhttp/ImageKitOkHttpClientAsync.kt | 15 ++++++++++ .../com/imagekit/api/core/ClientOptions.kt | 30 +++++++++++++++++++ 5 files changed, 72 insertions(+), 11 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8599545e..28637701 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: 84bf9f929b0248a6cdf2d526331ed8eb +config_hash: 0f760028496146ece9431573b1ab0e46 diff --git a/README.md b/README.md index a4ba438e..ee8fe401 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,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` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables +// 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() @@ -59,8 +59,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` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables +// 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(); ``` @@ -83,8 +83,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` and `imagekit.baseUrl` system properties - // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables + // 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(); @@ -96,6 +96,7 @@ See this table for the available options: | --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- | | `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. @@ -145,8 +146,8 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables +// 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() @@ -166,8 +167,8 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS` and `IMAGE_KIT_BASE_URL` environment variables +// 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() 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 7b44daeb..2da16e75 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 @@ -202,6 +202,21 @@ class ImageKitOkHttpClient private constructor() { /** 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 { 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 23dc7540..d998ad81 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 @@ -202,6 +202,21 @@ class ImageKitOkHttpClientAsync private constructor() { /** 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 { 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 0e73970c..7b379cd1 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 @@ -90,6 +90,7 @@ private constructor( */ @get:JvmName("privateApiKey") val privateApiKey: String, private val password: String?, + private val webhookSecret: String?, ) { init { @@ -115,6 +116,15 @@ private constructor( */ 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 { @@ -155,6 +165,7 @@ private constructor( 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 { @@ -170,6 +181,7 @@ private constructor( maxRetries = clientOptions.maxRetries privateApiKey = clientOptions.privateApiKey password = clientOptions.password + webhookSecret = clientOptions.webhookSecret } /** @@ -282,6 +294,19 @@ private constructor( /** 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) @@ -373,6 +398,7 @@ private constructor( * |---------------|--------------------------------------|--------------------------------|--------|---------------------------| * |`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. @@ -387,6 +413,9 @@ private constructor( (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) } } /** @@ -446,6 +475,7 @@ private constructor( maxRetries, privateApiKey, password, + webhookSecret, ) } } From 93e8caf328cb1a2527cd6126e0792076af02e9ee 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:39 +0000 Subject: [PATCH 088/125] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 28637701..ad85869b 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: 0f760028496146ece9431573b1ab0e46 +config_hash: cf9d50fe62973f4e91ef65c147aabcc1 From 78d22aa3f07dbfb7ab947f2a55fda23d3512d57c 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 089/125] 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 daecf6dbf9946555edf337cd1a878b0d51e6c60c 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 090/125] 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 12624caff37c9de397a01cae8cab8aa75122e37e 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 091/125] 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 c9677dcf0885b52ca866f455774bd1f841aa6220 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 092/125] 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 b15f21aa3e1e052a3351d0c60a0fbe3608a62c1a 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 093/125] 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 322f4beed3831d4fc1f217fd847ddbef23a5651a 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 094/125] 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 5dc190f5b952a8604bc876d860321215999e6917 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 095/125] 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 c0eee660e7d331d4257dcfa70ae235f4737c8fd4 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 096/125] 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 db6ea6b384ecc78cecedfd9c8660800d349f2f6a 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 097/125] 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 f146987f1813e4994465c45aae60465820cb3e34 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 098/125] 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 2b2944cb39543c735a8a81a9d48aa38a9ffb25a8 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 099/125] 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 f90653d791a2c43efc4fdcd0b79e549f229d395f 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 100/125] 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 c2e49273b42d4aa59547401189ba77f6b060a33c 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 101/125] 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 8f204726066cd17c19a141341063769c1870940b 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 102/125] 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 1bf2ddda379364a04fb44d22f52fcb1bd5f6cba1 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:15:16 +0000 Subject: [PATCH 103/125] 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 f7a61f795e081c66fd35445d49a7dba67e168c10 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 104/125] 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 58d88d8f9b00ff858a7e4564f8b7ad74c3da4310 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 105/125] 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 3891254df9e713c32a8702d2b69ef0a09f6c59a5 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 106/125] 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 1a33ad4051e73c1ee6c4016d00119faa5951dec3 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 107/125] 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 bbb2cc8536a73408a97e38a20733de5bd8204e6a 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 108/125] 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 5084cddab04669e42f58a44d6cd80ad6505d250d 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 109/125] 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 93ad225ae59ef4d8addb99c3d95feeb0c63de734 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 110/125] 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 d3d38947043cec697af04d67fa814bc46d740d91 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 111/125] 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 9d93334c20cd93a4142addea0bcf89935a0b66c8 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 112/125] 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 4aa4d6e52935e542f1c6ec9c779451b0d401395d 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 113/125] 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 11e12c4d9201cc29eb16937c0421a998de2ad10d 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 114/125] 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 2035395ea97c3e7a64a6d91a83cf7aa8c0e9819d 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 115/125] 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 5a391cdf44ae110f28c31a18a852351d50bb21a1 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 116/125] 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 a7e01d47a99685ccee321c623a236b3f7ac7cfef 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 117/125] 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 6c4b6aaa0dbb819c449625ec2b8406a05c3d51da 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 118/125] 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 e50643a4d86160f6bf485e201a5cb8f1950868f9 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 119/125] 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 f03ee8f353bf39c4f96bfd54b33fce42049832fa 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 120/125] 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 064d7d5f06447281cb04fe186d9350748ddf6aeb 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 121/125] 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 60833f20189db85580196828dd57adb7fe503932 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 122/125] 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 4066a118cfda0fa93261d65dab73696c23d3a7c0 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 123/125] 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 c5b750297b8567ebbb8df3f204b4d5b81db70686 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 124/125] 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 6f4c60e12395a9b15f66486f984e1625a4facc28 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 125/125] 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